iot_water_monitor_v2

Dependencies:   easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code

Files at this revision

API Documentation at this revision

Comitter:
DuyLionTran
Date:
Fri Dec 29 19:20:23 2017 +0000
Parent:
24:3de3cf978e60
Child:
26:f40cc4d011b0
Commit message:
version 1.8

Changed in this revision

Simple-MQTT/SimpleMQTT.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Simple-MQTT/SimpleMQTT.h	Fri Dec 29 19:13:03 2017 +0000
+++ b/Simple-MQTT/SimpleMQTT.h	Fri Dec 29 19:20:23 2017 +0000
@@ -41,6 +41,9 @@
     float ADC_PHVal;
     float ADC_DOVal;
     
+    float SENSOR_PHVal;
+    float SENSOR_DOVal;
+    
     int   RELAY_State_1;
     int   RELAY_State_2;
 	
@@ -107,6 +110,15 @@
  */
 int MQTT_PublishADC(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float adcVal_0);
 
+/** brief       Publish sensor values to the server
+ *  param[in]   client        MQTT client 
+ *  param[in]   inputTime     The time when the data is attempt to be sent 
+ *  param[in]   pH        	  pH Value
+ *  param[in]   DO        	  Oxygen value
+ *  retral      returnCode from MQTTClient.h 
+ */
+int MQTT_PublishSensorValue(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float pH, float DO);
+
 /** brief       Publish relay states to the server
  *  param[in]   client        MQTT client 
  *  param[in]   inputTime     The time when the data is attempt to be sent 
@@ -116,7 +128,7 @@
  */
 int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2);
 
-/** brief       Publish relay states to the server
+/** brief       Publish configuration values to the server
  *  param[in]   client        MQTT client 
  *  param[in]   inputTime     The time when the data is attempt to be sent 
  *  param[in]   mode          current mode: automatic (0) or manual (1)
@@ -266,6 +278,10 @@
     return client->publish(pubTopic, message);    
 }
 
+int MQTT_PublishSensorValue(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, float pH, float DO) {
+	
+}
+
 int MQTT_PublishRelayState(MQTT::Client<MQTTNetwork, Countdown, MQTT_MAX_PACKET_SIZE>* client, time_t inputTime, int relay1, int relay2) {
     MQTT::Message message;
     const char* pubTopic = MQTT_EVENT_TOPIC;         
@@ -323,7 +339,7 @@
     switch (uploadType) {
         case (ADC_VALUE): 		retVal = MQTT_PublishADC(client, inputTime, uploadStruct.ADC_PHVal);
             break;
-        case (SENSOR_VALUE): 	retVal =  MQTT::SUCCESS;
+        case (SENSOR_VALUE): 	retVal =  MQTT_PublishSensorValue(client, inputTime, uploadStruct.SENSOR_PHVal, uploadStruct.SENSOR_DOVal);
             break;
         case (RELAY_STATE):		retVal = MQTT_PublishRelayState(client, inputTime, uploadStruct.RELAY_State_1, uploadStruct.RELAY_State_2);
             break;
--- a/main.cpp	Fri Dec 29 19:13:03 2017 +0000
+++ b/main.cpp	Fri Dec 29 19:20:23 2017 +0000
@@ -23,7 +23,7 @@
 uint32_t    uploadPeriod        = 4;  /* Period between each time upload all data = uploadPeriod*readSecond = 20 s */
 uint32_t    uploadPeriodCounter = 0;
 
-struct UploadValue DataStruct = {17, 18, 0, 1, 0, 65, 80, 10};
+struct UploadValue DataStruct = {17, 18, 25, 27, 0, 1, 0, 65, 80, 10};
 
 /* Analog Handles */
 float ADC_PHVal;