Paolo Patierno / Mbed 2 deprecated sht15_remote_monitoring

Dependencies:   EthernetInterface NTPClient SHTx iothub_amqp_transport iothub_client mbed-rtos mbed proton-c-mbed serializer wolfSSL

Fork of remote_monitoring by Azure IoT

Files at this revision

API Documentation at this revision

Comitter:
ppatierno
Date:
Sun Nov 15 15:34:16 2015 +0000
Parent:
22:afe08a0ed332
Commit message:
Added real SHTx sensor to get temperature and humidity; Added new command to set temperature scale change; Removed "mock" commands to set temperature and humidity values

Changed in this revision

SHTx.lib Show annotated file Show diff for this revision Revisions of this file
iothub_amqp_transport.lib Show annotated file Show diff for this revision Revisions of this file
iothub_client.lib Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
remote_monitoring.c Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHTx.lib	Sun Nov 15 15:34:16 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/ppatierno/code/SHTx/#7505a67001b4
--- a/iothub_amqp_transport.lib	Fri Nov 13 16:08:20 2015 -0800
+++ b/iothub_amqp_transport.lib	Sun Nov 15 15:34:16 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/AzureIoTClient/code/iothub_amqp_transport/#57e049bce51e
+https://developer.mbed.org/users/AzureIoTClient/code/iothub_amqp_transport/#71bb8c60ca57
--- a/iothub_client.lib	Fri Nov 13 16:08:20 2015 -0800
+++ b/iothub_client.lib	Sun Nov 15 15:34:16 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/AzureIoTClient/code/iothub_client/#6622b8a07df3
+https://developer.mbed.org/users/AzureIoTClient/code/iothub_client/#bad609c1b5b3
--- a/mbed-rtos.lib	Fri Nov 13 16:08:20 2015 -0800
+++ b/mbed-rtos.lib	Sun Nov 15 15:34:16 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/mbed_official/code/mbed-rtos/#12552ef4e980
+https://developer.mbed.org/users/mbed_official/code/mbed-rtos/#6d90423c236e
--- a/mbed.bld	Fri Nov 13 16:08:20 2015 -0800
+++ b/mbed.bld	Sun Nov 15 15:34:16 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file
--- a/remote_monitoring.c	Fri Nov 13 16:08:20 2015 -0800
+++ b/remote_monitoring.c	Sun Nov 15 15:34:16 2015 +0000
@@ -12,10 +12,19 @@
 #include "certs.h"
 #endif // MBED_BUILD_TIMESTAMP
 
+#include "SHTx/sht15_export.h"
+
+/*
 static const char* deviceId = "[Device Id]";
 static const char* deviceKey = "[Device Key]";
 static const char* hubName = "[IoTHub Name]";
 static const char* hubSuffix = "[IoTHub Suffix, i.e. azure-devices.net]";
+*/
+
+static const char* deviceId = "frdm-k64f";
+static const char* deviceKey = "BoiNPBlt1odSFfl/wQQtrrzuBLBGeqTqpiOsRKBecus=";
+static const char* hubName = "ppatiernoiothub";
+static const char* hubSuffix = "azure-devices.net";
 
 // Define the Model
 BEGIN_NAMESPACE(Contoso);
@@ -46,12 +55,23 @@
     WITH_DATA(ascii_char_ptr_no_quotes, Commands),
 
     /* Commands implemented by the device */
-    WITH_ACTION(SetTemperature, double, temperature),
-	WITH_ACTION(SetHumidity, double, humidity)
+    //WITH_ACTION(SetTemperature, double, temperature),
+	//WITH_ACTION(SetHumidity, double, humidity)
+	WITH_ACTION(SetScale, bool, scale)
 );
 
 END_NAMESPACE(Contoso);
 
+// { "Name" : "SetScale", "Parameters": { "scale" : false } }
+EXECUTE_COMMAND_RESULT SetScale(Thermostat* thermostat, bool scale)
+{
+	(void)printf("Received scale %d\r\n", scale);
+	SHT15_setScale(scale);
+	return EXECUTE_COMMAND_SUCCESS;
+}
+
+/*
+// { "Name" : "SetTemperature", "Parameters": { "temperature" : 10 } }
 EXECUTE_COMMAND_RESULT SetTemperature(Thermostat* thermostat, double temperature)
 {
     (void)printf("Received temperature %.02fs\r\n", temperature);
@@ -59,12 +79,14 @@
     return EXECUTE_COMMAND_SUCCESS;
 }
 
+// { "Name" : "SetHumidity", "Parameters": { "humidity" : 20 } }
 EXECUTE_COMMAND_RESULT SetHumidity(Thermostat* thermostat, double humidity)
 {
 	(void)printf("Received humidity %.02fs\r\n", humidity);
 	thermostat->Humidity = humidity;
 	return EXECUTE_COMMAND_SUCCESS;
 }
+*/
 
 static void sendMessage(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const unsigned char* buffer, size_t size)
 {
@@ -217,10 +239,18 @@
 					thermostat->Humidity = 50.0;
 					thermostat->DeviceId = (char*)deviceId;
 
+					SHT15_init();
+
                     while (1)
                     {
                         unsigned char*buffer;
                         size_t bufferSize;
+                        
+                        SHT15_update();
+                        
+                        thermostat->Temperature = SHT15_getTemperature();
+                        thermostat->ExternalTemperature = SHT15_getTemperature();
+                        thermostat->Humidity = SHT15_getHumidity();
 
 						(void)printf("Sending sensor value Temperature = %02f, Humidity = %02f\r\n", thermostat->Temperature, thermostat->Humidity);