Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: iothub_client EthernetInterface iothub_http_transport mbed-rtos mbed wolfSSL azure_c_shared_utility NTPClient
Diff: iothub_client_sample_http.c
- Revision:
- 68:a8c0f61d8478
- Parent:
- 62:2320ad565fc3
- Child:
- 76:e9a30712b6d7
--- a/iothub_client_sample_http.c Fri Apr 21 14:51:47 2017 -0700 +++ b/iothub_client_sample_http.c Mon May 08 10:52:00 2017 -0700 @@ -123,6 +123,8 @@ EVENT_INSTANCE messages[MESSAGE_COUNT]; double avgWindSpeed = 10.0; + double minTemperature = 20.0; + double minHumidity = 60.0; int receiveContext = 0; g_continueRunning = true; @@ -180,11 +182,15 @@ /* Now that we are ready to receive commands, let's send some messages */ size_t iterator = 0; + double temperature = 0; + double humidity = 0; do { if (iterator < MESSAGE_COUNT) { - sprintf_s(msgText, sizeof(msgText), "{\"deviceId\": \"myFirstDevice\",\"windSpeed\": %.2f}", avgWindSpeed + (rand() % 4 + 2)); + temperature = minTemperature + (rand() % 10); + humidity = minHumidity + (rand() % 20); + sprintf_s(msgText, sizeof(msgText), "{\"deviceId\":\"myFirstDevice\",\"windSpeed\":%.2f,\"temperature\":%.2f,\"humidity\":%.2f}", avgWindSpeed + (rand() % 4 + 2), temperature, humidity); if ((messages[iterator].messageHandle = IoTHubMessage_CreateFromByteArray((const unsigned char*)msgText, strlen(msgText))) == NULL) { (void)printf("ERROR: iotHubMessageHandle is NULL!\r\n"); @@ -196,8 +202,8 @@ messages[iterator].messageTrackingId = iterator; propMap = IoTHubMessage_Properties(messages[iterator].messageHandle); - (void)sprintf_s(propText, sizeof(propText), "PropMsg_%zu", iterator); - if (Map_AddOrUpdate(propMap, "PropName", propText) != MAP_OK) + (void)sprintf_s(propText, sizeof(propText), temperature > 28 ? "true" : "false"); + if (Map_AddOrUpdate(propMap, "temperatureAlert", propText) != MAP_OK) { (void)printf("ERROR: Map_AddOrUpdate Failed!\r\n"); }