Local copy

Dependencies:   C12832_lcd ConfigFile EthernetInterface LM75B MMA7660 MQTTPacket mbed-rtos mbed

Fork of IBMIoTClientExampleForLPC1768 by Sam Danbury

Revision:
13:65e87bd958bd
Parent:
11:0fa63599f5a0
--- a/src/main.cpp	Wed Jul 02 12:02:47 2014 +0000
+++ b/src/main.cpp	Wed Jul 02 15:07:40 2014 +0000
@@ -18,7 +18,7 @@
 #include "LM75B.h"
 #include "MMA7660.h"
 #include "C12832_lcd.h"
-#include "QuickstartClient.h"
+#include "ExampleClient.h"
 #include "cJSON.h"
 
 #include <string>
@@ -53,7 +53,7 @@
 AnalogIn ain2(p20);
 float pot1;
 float pot2;
-QuickstartClient* c;
+ExampleClient* c;
 LocalFileSystem local("local");
 
 int getdata(char* buf, int count)
@@ -80,11 +80,10 @@
     Thread jThd(joystickThread);
     joystickPos = "CENTRE";
     
-    //QuickstartClient* c = new QuickstartClient(mac);
-    c = new QuickstartClient(mac);
+    //ExampleClient* c = new ExampleClient(mac);
+    c = new ExampleClient(mac);
     (c->mysock).set_blocking(true, 50000);
     int res = MQTTPacket_read(buf, buflen, getdata);
-    lcd.printf("res, %d\n", res);
     if ( res == CONNACK)
     {
         int connack_rc;
@@ -103,8 +102,6 @@
     
     int rc = c->subscribe();
     res = MQTTPacket_read(buf, buflen, getdata);
-    lcd.printf("res, %d\n", res);
-    wait(2.0);
     if (res == SUBACK)    /* wait for suback */
     {
         int submsgid;
@@ -165,7 +162,6 @@
         led1 = 0;
         //TODO get subscription working consistently
         res = MQTTPacket_read(buf, buflen, getdata);
-        lcd.printf("pub res : %d",res);
         if (  res == PUBLISH )
         {
             int dup;
@@ -179,8 +175,6 @@
 
             rc = MQTTDeserialize_publish(&dup, &qos, &retained, &msgid, &receivedTopic,
                     &payload_in, &payloadlen_in, buf, buflen);
-            lcd.printf("message arrived %s\n", payload_in);
-             wait(4.0);
             char message[50];
             int i =0, charNums = 0;
             while(*payload_in && charNums <2) {
@@ -196,10 +190,6 @@
                 payload_in++;
             }
             message[i] = '\0';
-            lcd.cls();
-            lcd.locate(0,0);
-            lcd.printf(" Message %s", message);
-            wait(4.0);
             int count = getCount(payload_in);
             lcd.printf("Count %d\n", count);
             while(count) {
@@ -211,7 +201,7 @@
             }
             
         }
-        wait(4.0);
+        wait(1.0);
     }
 exit:
     eth.disconnect();