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:
Thu Nov 19 12:50:08 2015 +0000
Parent:
20:14a61a65afba
Child:
22:e6b69714b59a
Commit message:
v2.0 working i2c only publishing when gets data from i2c

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Nov 13 13:15:31 2015 +0000
+++ b/main.cpp	Thu Nov 19 12:50:08 2015 +0000
@@ -36,7 +36,7 @@
 
 // Configuration values needed to connect to IBM IoT Cloud
 #define ORG "jfzeoz"             // For a registered connection, replace with your org
-#define ID "mbedGateway"                        // For a registered connection, replace with your id
+#define ID "homeExample"                        // 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
 
@@ -232,8 +232,11 @@
                  az   = ((uint16_t)buf[19] << 8) | buf[20];       //pospeškometer az
                  az = (az >> 6);
                  
-                 deviceID   = ((uint16_t)buf[3] << 8) | buf[3];       //device ID from whom the message was received 
-                 deviceID = (deviceID >> 6);
+                 int tmp = 48;
+                 deviceID = 0;
+                 //sprintf(tmp, "%c%c", buf[3],buf[4]);
+                 deviceID   =  (buf[3]-tmp)*10;      //device ID from whom the message was received 
+                 deviceID += (buf[4]-tmp);
                  respond = 1;
                  //rh   = ((uint16_t)buf[4] << 8) | buf[5];
                  
@@ -528,8 +531,8 @@
     faz = abs(faz);
           
     sprintf(buf,
-     "{\"d\":{\"myName\":\"IoT mbed\",\"lux\":%d,\"accelX\":%0.3f,\"accelY\":%0.3f,\"accelZ\":%0.3f,\"temp\":%0.1f,\"deviceID\":\"%d\"}}",
-            lux, fax, fay, faz, tempC, deviceID);
+     "{\"d\":{\"myName\":\"IoT mbed\",\"lux\":%d,\"accelX\":%0.3f,\"accelY\":%0.3f,\"accelZ\":%0.3f,\"temp\":%0.1f,\"deviceID%d\":%d}}",
+            lux, fax, fay, faz, tempC, deviceID, lux);
     message.qos = MQTT::QOS0;
     message.retained = false;
     message.dup = false;