TeamE7
Dependencies: EthernetInterface HTTPServer RemoteIR SDFileSystem mbed-rpc mbed-rtos mbed
Fork of SmartRemote by
Diff: main.cpp
- Revision:
- 13:12749822ba56
- Parent:
- 12:20ba5378ede2
- Child:
- 14:2b63c0f795cb
--- a/main.cpp Tue Dec 03 15:12:46 2013 +0000 +++ b/main.cpp Tue Dec 03 16:02:15 2013 +0000 @@ -68,12 +68,13 @@ printf("Setting up Apache...\n \r"); HTTPFsRequestHandler::mount("/local/", "/"); + HTTPFsRequestHandler::mount("/sd/", "/sd/"); svr.addHandler<HTTPFsRequestHandler>("/"); svr.addHandler<HTTPRpcRequestHandler>("/rpc"); EthernetInterface eth; eth.init(); //Use DHCP - eth.connect(30000); + eth.connect(); // Now start the server on port 80. if (!svr.start(80, ð)) { @@ -93,7 +94,9 @@ char tuple_code[128]; char tuple_name[128]; char tuple_bitlength[128]; - char tuple_format[128]; + char tuple_format[128]; + char temp[20]; + /* db_insert_tuple(code, name); @@ -128,7 +131,7 @@ if (Learn) { // Debug LED led1 = 1; - + // Receive the code { bitlength1 = receive(&format, buf1, sizeof(buf1)); @@ -139,19 +142,31 @@ display_data(buf1, bitlength1); //display_format(format); } - - // Set up the variables - sprintf(tuple_name, "%s", "TEST"); - sprintf(tuple_code, "%s", buf1); - sprintf(tuple_bitlength, "%d", bitlength1); - sprintf(tuple_format, "%s", format); - - // Insert into DB - db_insert_tuple(tuple_name, tuple_code, tuple_bitlength, tuple_format); - // Reset led1 = 0; Learn = 0; + + + + // Set up the variables + sprintf(tuple_name, "%c%c%c%c%c%c%c%c%c%c", Learn_name0,Learn_name1,Learn_name2,Learn_name3,Learn_name4,Learn_name5,Learn_name6,Learn_name7,Learn_name8,Learn_name9); + //sprintf(tuple_code, "%X", buf1); + sprintf(tuple_bitlength, "%d", bitlength1); + sprintf(tuple_format, "%d", format); + for (int i = 0; i < 10; i++) { + if (tuple_name[i] == '~') tuple_name[i] = ' '; + } + + const int n = bitlength1 / 8 + (((bitlength1 % 8) != 0) ? 1 : 0); + strcpy(tuple_code, ""); + for (int i = 0; i < n; i++) { + sprintf(temp, "%02X", buf1[i]); + strcat(tuple_code, temp); + } + + // Insert into DB + db_insert_tuple(tuple_name, tuple_code, tuple_bitlength, tuple_format); + } }