iot_water_monitor_v2
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
Diff: Simple-MQTT/SimpleMQTT.h
- Revision:
- 36:d0b628087ac8
- Parent:
- 35:fc800d35c1ba
- Child:
- 39:a5ee98bd0050
--- a/Simple-MQTT/SimpleMQTT.h Wed Feb 14 04:28:24 2018 +0000 +++ b/Simple-MQTT/SimpleMQTT.h Wed Feb 14 14:45:35 2018 +0000 @@ -45,7 +45,7 @@ float ADC_DOVal; float SENSOR_PHVal; - float SENSOR_D0Val; + float SENSOR_DOVal; uint8_t RELAY_State_1; uint8_t RELAY_State_2; @@ -126,7 +126,7 @@ * param[in] pHVal The pHVal value to be sent * retral returnCode from MQTTClient.h */ -int MQTT_PublishSensorVal(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float pHVal); +int MQTT_PublishSensorVal(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float DOVal); /** brief Publish relay states to the server * param[in] client MQTT client @@ -135,7 +135,7 @@ * param[in] relay2 Relay 2 state * retral returnCode from MQTTClient.h */ -int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2); +int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2, int relay3); /** brief Publish relay states to the server * param[in] client MQTT client @@ -367,7 +367,7 @@ return client->publish(pubTopic, message); } -int MQTT_PublishSensorVal(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float pHVal) { +int MQTT_PublishSensorVal(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float DOVal) { MQTT::Message message; const char* pubTopic = MQTT_EVENT_TOPIC; @@ -379,8 +379,8 @@ } strftime(timeBuf, 50, "%Y/%m/%d %H:%M:%S", localtime(&inputTime)); - sprintf(buf, "{\"type\":2,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"pH0\":%.1f}", - timeBuf, commandID, pHVal); + sprintf(buf, "{\"type\":2,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"DO\":%.2f}", + timeBuf, commandID, DOVal); message.qos = MQTT::QOS0; message.retained = false; message.dup = false; @@ -394,7 +394,7 @@ return client->publish(pubTopic, message); } -int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2) { +int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2, int relay3) { MQTT::Message message; const char* pubTopic = MQTT_EVENT_TOPIC; char buf[MQTT_MAX_PAYLOAD_SIZE]; @@ -405,8 +405,8 @@ return MQTT::FAILURE; } strftime(timeBuf, 50, "%Y/%m/%d %H:%M:%S", localtime(&inputTime)); - sprintf(buf, "{\"type\":3,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"relay1\":%d,\"relay2\":%d}", - timeBuf, commandID, relay1, relay2); + sprintf(buf, "{\"type\":3,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"relay1\":%d,\"relay2\":%d,\"relay3\":%d}", + timeBuf, commandID, relay1, relay2, relay3); message.qos = MQTT::QOS0; message.retained = false; message.dup = false; @@ -449,11 +449,11 @@ int MQTT_PublishAll(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, uint8_t uploadType, struct UploadValue uploadStruct) { int retVal; switch (uploadType) { - case (ADC_VALUE): retVal = MQTT_PublishADC(client, inputTime, uploadStruct.ADC_PHVal); + case (ADC_VALUE): retVal = MQTT_PublishADC(client, inputTime, uploadStruct.ADC_DOVal); break; - case (SENSOR_VALUE): retVal = MQTT_PublishSensorVal(client, inputTime, uploadStruct.SENSOR_PHVal); + case (SENSOR_VALUE): retVal = MQTT_PublishSensorVal(client, inputTime, uploadStruct.SENSOR_DOVal); break; - case (RELAY_STATE): retVal = MQTT_PublishRelayState(client, inputTime, uploadStruct.RELAY_State_1, uploadStruct.RELAY_State_2); + case (RELAY_STATE): retVal = MQTT_PublishRelayState(client, inputTime, uploadStruct.RELAY_State_1, uploadStruct.RELAY_State_2, uploadStruct.RELAY_State_3); break; case (CONFIG_VALUE): retVal = MQTT_PublishConfigValue(client, inputTime, uploadStruct.CONFIG_Mode, uploadStruct.CONFIG_MinOxi, uploadStruct.CONFIG_MaxOxi); break;