Groep E3 - EMDEV

Dependencies:   EthernetInterface HTTPServer RemoteIR SDFileSystem mbed-rpc mbed-rtos mbed

Fork of SmartRemote by Sam Kirsch

Revision:
14:2b63c0f795cb
Parent:
13:12749822ba56
Child:
15:c8074f5f241a
diff -r 12749822ba56 -r 2b63c0f795cb main.cpp
--- a/main.cpp	Tue Dec 03 16:02:15 2013 +0000
+++ b/main.cpp	Tue Dec 03 16:21:52 2013 +0000
@@ -6,6 +6,7 @@
 #include "rtos.h"
 
 DigitalOut led1(LED1);
+DigitalOut led2(LED2);
 
 //Start IR
 #include "ReceiverIR.h"
@@ -94,16 +95,8 @@
     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);
-    FILE *fread = fopen("/sd/SmartRemote/db.txt", "r");
-    db_find_tuple(fread, Request, results_name, results_code);
-    fclose(fread);
-    */
     //End DB init
 
 
@@ -156,12 +149,12 @@
             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); 
+                strcat(tuple_code, temp);
             }
 
             // Insert into DB
@@ -169,6 +162,25 @@
 
         }
 
+        if ( Request != 0) {
+            led2 = 1;
+            db_find_tuple(Request, tuple_name, tuple_code, tuple_bitlength, tuple_format);
+            {
+                RemoteIR::Format f = static_cast<RemoteIR::Format>(atoi(tuple_format));
+                bitlength1 = transmit(f, (uint8_t *)atoi(tuple_code), 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);
+            }
+            led2 = 0;
+            Request = 0;
+
+        }
+
     }
 
     return 0;