This is a program that turns your mbed device into a FireFly gateway, that publishes data from FireFly BLE modules to the IBM Watson IoT Platform.

Dependencies:   C12832 EthernetInterface MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Files at this revision

API Documentation at this revision

Comitter:
skoda
Date:
Mon Nov 09 13:33:45 2015 +0000
Parent:
18:94da9de96d54
Child:
20:14a61a65afba
Commit message:
hello world

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Aug 12 20:50:56 2015 +0000
+++ b/main.cpp	Mon Nov 09 13:33:45 2015 +0000
@@ -35,10 +35,10 @@
 #define __APP_SW_REVISION__ "18"
 
 // Configuration values needed to connect to IBM IoT Cloud
-#define ORG "quickstart"             // For a registered connection, replace with your org
-#define ID ""                        // For a registered connection, replace with your id
-#define AUTH_TOKEN ""                // For a registered connection, replace with your auth-token
-#define TYPE DEFAULT_TYPE_NAME       // For a registered connection, replace with your type
+#define ORG "jfzeoz"             // For a registered connection, replace with your org
+#define ID "mbedFly"                        // For a registered connection, replace with your id
+#define AUTH_TOKEN "123456789"                // For a registered connection, replace with your auth-token
+#define TYPE "FireFly"       // For a registered connection, replace with your type
 
 #define MQTT_PORT 1883
 #define MQTT_TLS_PORT 8883
@@ -80,6 +80,7 @@
 char* gateway_addr = "";
 char* host_addr = "";
 int connectTimeout = 1000;
+char* MSGpayload = "";
 
 // If we wanted to manually set the MAC address,
 // this is how to do it. In this example, we take
@@ -228,6 +229,10 @@
             sprintf(line1, "Current Timeout:");
             sprintf(line2, "%d ms", connectTimeout);
             break;
+        case 10:
+            sprintf(line1, "Message payload:");
+            sprintf(line2, "%s", MSGpayload);
+            break;
     }
     
     if (strcmp(line1, last_line1) != 0 || strcmp(line2, last_line2) != 0)
@@ -250,7 +255,7 @@
     if (Down)
     {
         joystickPos = "DOWN";
-        if (menuItem >= 0 && menuItem < 9)
+        if (menuItem >= 0 && menuItem < 10)
             printMenu(++menuItem);
     } 
     else if (Left)
@@ -260,7 +265,7 @@
     else if (Up)
     {
         joystickPos = "UP";
-        if (menuItem <= 9 && menuItem > 0)
+        if (menuItem <= 10 && menuItem > 0)
             printMenu(--menuItem);
     }
     else if (Right)
@@ -436,9 +441,12 @@
     char topic[md.topicName.lenstring.len + 1];
     
     sprintf(topic, "%.*s", md.topicName.lenstring.len, md.topicName.lenstring.data);
+    if(topic != NULL){
+        MSGpayload = topic;
+    }
     
     LOG("Message arrived on topic %s: %.*s\n",  topic, message.payloadlen, message.payload);
-          
+    
     // Command topic: iot-2/cmd/blink/fmt/json - cmd is the string between cmd/ and /fmt/
     char* start = strstr(topic, "/cmd/") + 5;
     int len = strstr(topic, "/fmt/") - start;
@@ -447,7 +455,7 @@
     {
         char payload[message.payloadlen + 1];
         sprintf(payload, "%.*s", message.payloadlen, (char*)message.payload);
-    
+        
         char* pos = strchr(payload, '}');
         if (pos != NULL)
         {