瀏覽代碼

2021-12-30 / Eason Yang
Action
1. Improve: Reset wifi power logic for wifi mode is access point.

File
1. main.c
Action 1

FIRMWARE VERSION: B0.59.XX.XXXX.NX

8009 3 年之前
父節點
當前提交
060a690abb
共有 1 個文件被更改,包括 42 次插入12 次删除
  1. 42 12
      EVSE/Projects/AW-CCS/Apps/main.c

+ 42 - 12
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			300
+#define TIMEOUT_SPEC_RESET_WIFI_MODULE			180
 
 //==========================
 // GPIO constant define
@@ -2578,23 +2578,53 @@ void InitEthernet()
 			}
 
 			// Reset wifi function
-			if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-			   (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON) &&
-			   (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1))
+			if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1))
 			{
-				if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
+				if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) && 
+				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON) &&
+				   (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
 				{
-					DEBUG_INFO("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");
+					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");
+						
+						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]);
+					}
+					else
+					{}
+				}
+				else
+				{
 					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
+				}	
+			}
+			else if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2))
+			{
+				if((ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
+				{
+					if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
+					{
+						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]);
+					}
+					else
+					{}
 				}
 				else
-				{}
+				{
+					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
+				}	
 			}
 			else
 			{