blah
Dependencies: EthernetInterface HTTPServer SDFileSystem mbed-rpc mbed RemoteIR mbed-rtos
Fork of HTTPServerHelloWorld by
Diff: main.cpp
- Revision:
- 16:2d23297857bc
- Parent:
- 15:c8074f5f241a
--- a/main.cpp Wed Dec 04 17:04:12 2013 +0000 +++ b/main.cpp Wed Dec 04 17:44:29 2013 +0000 @@ -4,6 +4,7 @@ #include "FsHandler.h" #include "RpcHandler.h" #include "rtos.h" +#include <string> DigitalOut led1(LED1); DigitalOut led2(LED2); @@ -106,6 +107,7 @@ uint8_t buf2[32]; int bitlength1; int bitlength2; + char tempstr[3]; RemoteIR::Format format; memset(buf1, 0x00, sizeof(buf1)); memset(buf2, 0x00, sizeof(buf2)); @@ -169,19 +171,25 @@ n = atoi(tuple_bitlength) / 8 + (((atoi(tuple_bitlength) % 8) != 0) ? 1 : 0); memset(buf1, 0x00, sizeof(buf1)); - for (int i = 0; i < n; i++) { + int j = 0 ; + for (int i = 0; i < 2*n; i+=2) { + // printf("%02X", buf[i]); // buf1[i] = (uint8_t)(atoi( tuple_code.substr(i, 2) )); - printf("%d", atoi( tuple_code.substr(i, 2) )); + sprintf(tempstr,"%c%c", tuple_code[i],tuple_code[i+1] ); + printf("%s - ", tempstr); + printf("%02X\n", (uint8_t)strtol(tempstr,NULL,16) ); + buf1[j] = (uint8_t)strtol(tempstr,NULL,16); + j++; } + display_data(buf1,atoi(tuple_bitlength)); { RemoteIR::Format f = static_cast<RemoteIR::Format>(atoi(tuple_format)); - bitlength1 = transmit(f, (uint8_t *)atoi(tuple_code), atoi(tuple_bitlength)); + bitlength1 = transmit(f, buf1, atoi(tuple_bitlength)); if (bitlength1 < 0) { continue; } - printf("%d", (uint8_t *)atoi(tuple_code)); display_status("TRAN", bitlength1); //display_data(buf1, bitlength1); //display_format(format);