ControllerBox directs electromechanical equipment in restaurants to display information.

Dependencies:   EthernetInterface HTTPClient_KVplus MbedJSONValue SDFileSystem TextLCD mbed-rtos mbed picojson

Revision:
3:21c8adb97c8f
Parent:
2:ad4509a9d051
--- a/main.cpp	Tue Dec 02 20:51:18 2014 +0000
+++ b/main.cpp	Thu Dec 04 22:26:30 2014 +0000
@@ -4,6 +4,7 @@
 #include "Controller.h"
 #include "EthernetInterface.h"
 #include "HTTPClient.h"
+#include "picojson.h"
 //#include "SDFileSystem.h" Needed if config files are going to be implemented
 #include <string>
 
@@ -39,6 +40,7 @@
 //SDFileSystem sdfs(p11,p12,p13,p14, "sdCard");
 
 
+
 //Controller mainly directs the program. It directs data and also controls the lcd output.
 Controller c(&lcd);
 
@@ -55,15 +57,21 @@
 *****************/
 int main()
 {
+    printf("\r\n\r\nBuild  ");
+    printf(__DATE__);
+    printf(" - ");
+    printf(__TIME__);
+    printf("\r\n\r\n");
     setup();
     c.lcd->cls();
     //the LCD is cleared using function .cls()
     lcd.cls();
 
+    c.printCommandList();
     pc.printf("Entering loop\r\n");
 
     //the endless loop keeps mbed in low power mode
-    runProgram();
+//    runProgram();
 }
 
 /*************************
@@ -77,8 +85,8 @@
     rfd.baud(9600);
 
     //Initialize Ethernet
-    eth.init();
-    eth.connect();
+//    eth.init();
+//    eth.connect();
     wait_ms(200);
 }
 
@@ -88,30 +96,46 @@
     c.lcd->locate(0,0);
     c.displayStatus();
 //    c.printDesc(1);
-    string ip = eth.getIPAddress();
-    string mStr = "IP: " + ip + "\r\n";
-    c.lcdWriteLine(3, mStr);
-    pc.printf("%s", ip);
+//    string ip = eth.getIPAddress();
+//    string mStr = "IP: " + ip + "\r\n";
+//    c.lcdWriteLine(3, mStr);
+//    pc.printf("%s", ip);
+////
+//
 //
-
-
-        //GET data
-    printf("\nTrying to fetch page...\r\n");
-    int ret = http.get("http://core.motiv.jvanbaarsen.com/v1/tables/7", str, 128);
-    if (!ret)
-    {
-      printf("Page fetched successfully - read %d characters\r\n", strlen(str));
-      printf("Result: %s\r\n", str);
-      c.lcdWriteLine(1, str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
-
-
+//        //GET data
+//    printf("\nTrying to fetch page...\r\n");
+//    int ret = http.get("http://core.motiv.jvanbaarsen.com/v1/tables/7", str, 128);
+//    if (!ret)
+//    {
+//      printf("Page fetched successfully - read %d characters\r\n", strlen(str));
+//      printf("Result: %s\r\n", str);
+//      c.lcdWriteLine(1, str);
+//    }
+//    else
+//    {
+//      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+//    }
+//
+//    picojson::value jsonVal;
+//    char *json = (char*) malloc(strlen(str)+1);
+//    strcpy(json, str);
+//    string err = picojson::parse(jsonVal, json, json + strlen(json));
+//    printf("res error? %s\r\n", err.c_str());
+//    
+//    string code = jsonVal.get("table").get("code").get<string>();
+//    
+//    
+////    int dinner_stat = json["table"];
+////    string code = table["code"];
+////    
+////    printf("The status of the dinner is: %d\r\n", dinner_stat);
+//    printf("Code: %s\r\n", code); 
+    
     c.setStatus(Controller::READY);
     pc.printf("Controller ready\r\n");
+    
+    c.printCommandList();
 
     //Reset flower
     rfd.putc(2);
@@ -120,8 +144,6 @@
     rfd.putc(';');
     wait_ms(2000);
 
-    char received = 'a';
-
     string str = "";
     int counter = 0;
     int counterLast = -1;