IoT Starter Kit Code

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
icraggs
Date:
Tue Sep 30 15:57:57 2014 +0000
Parent:
0:0777b6b0c36f
Commit message:
Removed conditional compilation for IoT registration settings

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 29 11:44:51 2014 +0000
+++ b/main.cpp	Tue Sep 30 15:57:57 2014 +0000
@@ -26,18 +26,10 @@
 #include "K64F.h"
 
 // Configuration values needed to connect to IBM IoT Cloud
-#define QUICKSTARTMODE 1
-#if (QUICKSTARTMODE)
-#define ORG "quickstart"
-#define ID ""
-#define AUTH_TOKEN ""
-#define TYPE DEFAULT_TYPE_NAME
-#else
-#define ORG "Replace with your org"
-#define ID "Replace with your id"
-#define TYPE "Replace with your type"
-#define AUTH_TOKEN "Replace with your auth-token"
-#endif
+#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 MQTT_PORT 1883
 #define MQTT_TLS_PORT 8883
@@ -45,7 +37,7 @@
 
 #define MQTT_MAX_PACKET_SIZE 250
 
-bool quickstartMode = (QUICKSTARTMODE) ? true : false;
+bool quickstartMode = true;
 char org[11] = ORG;  
 char type[30] = TYPE;
 char id[30] = ID;                 // mac without colons
@@ -195,6 +187,7 @@
     MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
     data.MQTTVersion = 3;
     data.clientID.cstring = clientId;
+    data.keepAliveInterval = 5;
     
     if (!quickstartMode) 
     {        
@@ -322,6 +315,8 @@
 
 int main()
 {    
+    quickstartMode = (strcmp(org, "quickstart") == 0);
+
     lcd.set_font((unsigned char*) Arial12x12);  // Set a nice font for the LCD screen
     
     led2 = LED2_OFF; // turn off the main board LED