Temperature sensor anomaly IoTHub sample

Dependencies:   C12832 EthernetInterface LM75B NTPClient iothub_client iothub_http_transport mbed-rtos mbed serializer wolfSSL azure_c_shared_utility

This sample showcases the usage of Azure IoT client libraries to build an application sample that uploads temperature data and reacts to an alert for a temperature anomaly sent by a cloud service.

Revision:
13:c5cd6fb5205b
Parent:
9:0aae2d7a398b
--- a/main.cpp	Tue Sep 29 01:46:04 2015 +0000
+++ b/main.cpp	Tue Sep 29 17:02:33 2015 -0700
@@ -11,6 +11,10 @@
 #include "LM75B.h"
 #include "NTPClient.h"
 
+#ifdef MBED_BUILD_TIMESTAMP
+#include "certs.h"
+#endif // MBED_BUILD_TIMESTAMP
+
 C12832 lcd(D11, D13, D12, D7, D10);
 LM75B sensor(D14, D15);
 DigitalIn Fire(D4);
@@ -286,6 +290,7 @@
          (void)printf("Failed EthernetInterface::init();\r\n");
          return -1;
     }
+        
     (void)printf("done doing a one time EthernetInterface::init();\r\n");
 
     if (setupRealTime() != 0)
@@ -328,6 +333,14 @@
         }
         else
         {
+#ifdef MBED_BUILD_TIMESTAMP
+        	// For mbed add the certificate information
+        	if (IoTHubClient_LL_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK)
+        	{
+            	printf("failure to set option \"TrustedCerts\"\r\n");
+        	}
+#endif // MBED_BUILD_TIMESTAMP
+
             unsigned int minimumPollingTime = 9; /*because it can poll "after 9 seconds" polls will happen effectively at ~10 seconds*/
             if (IoTHubClient_LL_SetOption(iotHubClientHandle, "MinimumPollingTime", &minimumPollingTime) != IOTHUB_CLIENT_OK)
             {
@@ -429,4 +442,6 @@
         }
         serializer_deinit();
     }
+    
+    EthernetInterface::disconnect();
 }