Example for AV_MQTT

Dependencies:   AV_MQTT mbed

Files at this revision

API Documentation at this revision

Comitter:
Nim65s
Date:
Tue Aug 13 13:38:27 2013 +0000
Parent:
5:e08272218162
Child:
7:66ff43202f50
Commit message:
JSON is now parsed in AV_MQTT

Changed in this revision

AV_MQTT.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
picojson.lib Show diff for this revision Revisions of this file
--- a/AV_MQTT.lib	Mon Aug 12 15:34:07 2013 +0000
+++ b/AV_MQTT.lib	Tue Aug 13 13:38:27 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Nim65s/code/AV_MQTT/#cf6e5a36006f
+http://mbed.org/users/Nim65s/code/AV_MQTT/#da5d90052cec
--- a/main.cpp	Mon Aug 12 15:34:07 2013 +0000
+++ b/main.cpp	Tue Aug 13 13:38:27 2013 +0000
@@ -2,18 +2,14 @@
 #include "rtos.h"
 #include "AV_MQTT.h"
 #include "EthernetInterface.h"
-#include "picojson.h"
 
 EthernetInterface eth;
 
 DigitalIn jdown(p12), jleft(p13), jcenter(p14), jup(p15), jright(p16);
 DigitalOut l1(LED1), l2(LED2), l3(LED3), l4(LED4);
 
-void callback(char *topic, char *message) {
-    picojson::value v;
-    picojson::parse(v, message, message + strlen(message));
-    
-    int led = atoi(v.get<picojson::array>()[0].get("write").get<picojson::array>()[0].get("mbed_mqtt_example.led_settings").to_str().c_str());
+void callback(const char *key, const char *value) {
+    int led = atoi(value);
     l2 = (led & 4) >> 2;
     l3 = (led & 2) >> 1;
     l4 = led & 1;
@@ -26,6 +22,7 @@
     
     AV_MQTT client("10.41.240.6", callback, "MBED_MQTT_EXAMPLE", "mbed_password", "id", 1883, false);
     
+    
     while(true) {
         
         if (jdown)        client.pub("button", "1");
--- a/picojson.lib	Mon Aug 12 15:34:07 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://mbed.org/users/mimil/code/picojson/#2bb500b021e2