Duy tran / Mbed OS 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:
Wed Feb 14 04:28:24 2018 +0000
Parent:
34:601effb7b7fe
Child:
36:d0b628087ac8
Commit message:
* version 2.5 02-14-2017: 3rd relay and remote time setting are added

Changed in this revision

Application/CommandExecution.cpp Show annotated file Show diff for this revision Revisions of this file
Application/CommandExecution.h Show annotated file Show diff for this revision Revisions of this file
Application/main.cpp Show annotated file Show diff for this revision Revisions of this file
Flash/flash_programming.cpp Show annotated file Show diff for this revision Revisions of this file
Simple-MQTT/SimpleMQTT.h Show annotated file Show diff for this revision Revisions of this file
--- a/Application/CommandExecution.cpp	Wed Feb 14 03:56:34 2018 +0000
+++ b/Application/CommandExecution.cpp	Wed Feb 14 04:28:24 2018 +0000
@@ -10,3 +10,8 @@
     relay2 = Relay2State;  
     relay3 = Relay3State;
 }
+
+void CE_SetRTCTime(uint32_t CurrentEpochTime) {
+    printf("New local time value set");
+    set_time(CurrentEpochTime);
+}
\ No newline at end of file
--- a/Application/CommandExecution.h	Wed Feb 14 03:56:34 2018 +0000
+++ b/Application/CommandExecution.h	Wed Feb 14 04:28:24 2018 +0000
@@ -1,10 +1,13 @@
 #ifndef __COMMANDEXECUTION_H__
 #define __COMMANDEXECUTION_H__
 
+#include <stdint.h>
+
 #define RELAY_1_PIN   (D10)
 #define RELAY_2_PIN   (D11)
 #define RELAY_3_PIN   (D12)
 
 void CE_HandleRelays(int Relay1State, int Relat2State, int Relat3State);
+void CE_SetRTCTime(uint32_t CurrentEpochTime);
 
 #endif /* __COMMANDEXECUTION_H__ */
\ No newline at end of file
--- a/Application/main.cpp	Wed Feb 14 03:56:34 2018 +0000
+++ b/Application/main.cpp	Wed Feb 14 04:28:24 2018 +0000
@@ -2,7 +2,7 @@
   * Revision
   * version 1.0
   * ....
-  * version 2.5 02-14-2017: 3rd relay is added
+  * version 2.5 02-14-2017: 3rd relay and remote time setting are added
   */
 
 /***************************************************************
@@ -81,7 +81,6 @@
    	espEn = 1;
    	espRs = 1;
    	lastRead = 0;
-//   set_time(1517270400);
    	pc.printf("\r\nX-NUCLEO-IDW01M1 mbed Application\r\n");     
    	pc.printf("\r\nconnecting to AP\r\n");            
 
--- a/Flash/flash_programming.cpp	Wed Feb 14 03:56:34 2018 +0000
+++ b/Flash/flash_programming.cpp	Wed Feb 14 04:28:24 2018 +0000
@@ -77,6 +77,7 @@
                                    else {
                                         printf("Write Relay 2 State failed, error num %d\r\n", HAL_FLASH_GetError());
                                    }
+            break;
             case (RELAY3_ADDRESS): if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, CurrentAddress, RelayState3) == HAL_OK) {
                                         printf("Write Relay 3 State OK\r\n");
                                    }
--- a/Simple-MQTT/SimpleMQTT.h	Wed Feb 14 03:56:34 2018 +0000
+++ b/Simple-MQTT/SimpleMQTT.h	Wed Feb 14 04:28:24 2018 +0000
@@ -210,7 +210,8 @@
             			CE_HandleRelays(relayState1, relayState2, relayState3);
             	break;
             	
-            	case 4: int mode, minOxiVal, maxOxiVal, uploadInterval;
+            	case 4: int mode, minOxiVal, maxOxiVal, uploadInterval, setRTCTime;
+            	
             			KeyIndex      = json.findKeyIndexIn("cmdID", 0);
             			KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
             			ret = json.tokenIntegerValue(KeyValueIndex, receiveCmdID); 
@@ -229,13 +230,18 @@
             		
             			KeyIndex      = json.findKeyIndexIn("uploadInterval", 0);
             			KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
-            			ret = json.tokenIntegerValue(KeyValueIndex, uploadInterval);     
+            			ret = json.tokenIntegerValue(KeyValueIndex, uploadInterval);  
+            		
+            			KeyIndex      = json.findKeyIndexIn("setRTCTime", 0);
+            			KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
+            			ret = json.tokenIntegerValue(KeyValueIndex, setRTCTime);      
             			
             			DataStruct.CONFIG_Mode   		 = mode;   
             			DataStruct.CONFIG_MinOxi 		 = minOxiVal;   
             			DataStruct.CONFIG_MaxOxi 		 = maxOxiVal;   
             			DataStruct.CONFIG_UploadInterval = uploadInterval;			
-            			FP_WriteConfigValues(DataStruct.CONFIG_Mode, DataStruct.CONFIG_MinOxi, DataStruct.CONFIG_MaxOxi, DataStruct.CONFIG_UploadInterval);  			
+            			FP_WriteConfigValues(DataStruct.CONFIG_Mode, DataStruct.CONFIG_MinOxi, DataStruct.CONFIG_MaxOxi, DataStruct.CONFIG_UploadInterval);  	
+            			CE_SetRTCTime(setRTCTime);		
             	break;
             	
             	default: break;