Browse Source

[Improve][AW-CCS][main.c]
2022-04-27 / EASON YANG
Action
1. Improve: Check is need to reset WIFI/4G module power.
2. Improve: Reset time changed from 180s to 300s.

File
1. main.c
Action 1

FIRMWARE VERSION: B0.62.XX.XXXX.PX

8009 2 years ago
parent
commit
9b09ff5f2c
1 changed files with 18 additions and 42 deletions
  1. 18 42
      EVSE/Projects/AW-CCS/Apps/main.c

+ 18 - 42
EVSE/Projects/AW-CCS/Apps/main.c

@@ -34,7 +34,7 @@
 #define TIMEOUT_SPEC_POWERSAVING_METER			120
 #define TIMEOUT_SPEC_POWERSAVING_LED_STATUS		120
 #define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION	15
-#define TIMEOUT_SPEC_RESET_WIFI_MODULE			180
+#define TIMEOUT_SPEC_RESET_WIFI_MODULE			300
 
 //==========================
 // GPIO constant define
@@ -44,7 +44,7 @@
 #define GPIO_OUT_RST_QCA				115
 #define GPIO_OUT_RST_ETH				56
 #define GPIO_IN_WAKEUP					63
-#define GPIO_OUT_RST_PWR				59
+#define GPIO_OUT_RST_4G_WIFI			59
 
 #define MtdBlockSize 					0x300000
 
@@ -2631,52 +2631,28 @@ void InitEthernet()
 				}
 			}
 
-			// Reset wifi function
-			if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1))
-			{
-				if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON) &&
-				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
-				{
-					if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
-					{
-						DEBUG_INFO("Wifi [Station] mode: Reset wifi power. \n");
-						DEBUG_INFO("The wifi interface may not be found. \n");
+			// Check is need to reset WIFI/4G module power
+			if(!ShmSysConfigAndInfo->SysInfo.OcppConnStatus &&
 
-						system("echo 1 > /sys/class/gpio/gpio59/value");
-						sleep(3);
-						system("echo 0 > /sys/class/gpio/gpio59/value");
+			   ((system("pidof -s Module_Wifi > /dev/null") != 0) ||
+				(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) ||
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) ||
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
 
-						refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
-					}
-					else
-					{}
-				}
-				else
-				{
-					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
-				}
-			}
-			else if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2))
+			   ((system("pidof -s Module_4g > /dev/null") != 0) ||
+				(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) ||
+				((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
 			{
-				if((ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
+				if(getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE)
 				{
-					if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
+					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					{
-						DEBUG_INFO("Wifi [Access Point] mode: reset wifi power. \n");
-						DEBUG_INFO("The wifi interface may not be found. \n");
-
-						system("echo 1 > /sys/class/gpio/gpio59/value");
-						sleep(3);
-						system("echo 0 > /sys/class/gpio/gpio59/value");
-
-						refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
+						DEBUG_WARN("WIFI/4G module reset.\n");
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, ON);
+						sleep(1);
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, OFF);
 					}
-					else
-					{}
-				}
-				else
-				{
+
 					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
 				}
 			}