iot_water_monitor_v2
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
Revision 54:d8dda8394353, committed 2018-03-23
- Comitter:
- DuyLionTran
- Date:
- Fri Mar 23 17:18:08 2018 +0000
- Parent:
- 53:64982aa7d08b
- Child:
- 55:c405323f8d5a
- Commit message:
- minor bugs fixed
Changed in this revision
Application/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Application/main.cpp Fri Mar 23 07:50:54 2018 +0000 +++ b/Application/main.cpp Fri Mar 23 17:18:08 2018 +0000 @@ -255,26 +255,9 @@ if(connected == true) { /* Upload for the first time */ if (isFirstUpload) { - printf("First upload time %ds\r\n", DataStruct.CONFIG_UploadInterval); - for (uint8_t firstUploadType = 1; firstUploadType < 4; firstUploadType++) { - seconds = time(NULL); - wd.Service(); - if (MQTT_PublishAll(&client, seconds, firstUploadType, DataStruct) == MQTT::SUCCESS) { - myled = 1; - } - else { - myled = 0; - } - wait(5); - if (firstUploadType == CONFIG_VALUE) { - uploadType = SENSOR_VALUE; - isFirstUpload = false; - lastRead = UploadTimer.read(); - } - } - lastRead = UploadTimer.read(); + MQTT_PublishAll(&client, seconds, CONFIG_VALUE, DataStruct); + isFirstUpload = false; } - else { /* Periodic upload */ if ((uint32_t)(UploadTimer.read() - lastRead) >= READ_SECOND) { // Read timer every readSecond(s) printf("Periodic upload time %ds\r\n", DataStruct.CONFIG_UploadInterval); @@ -317,8 +300,7 @@ } } lastRead = UploadTimer.read(); - } - } + } /* allow the MQTT client to receive subscribe messages and manage keep alive */ wd.Service(); client.yield(500);