ソースを参照

[Improve][Modularization][Module_OcppBackend/Module_Wifi]

2020.12.22 / Folus Wen

Actions:
1. Module_Wifi.c interface restart when connect AP retry fail or ping internet retry fail over 3 times.
2. Module_OcppBackend MessageHandler.c allow TxProfile set when charging in MODE_TERMINATING.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 年 前
コミット
e392096bd4

+ 23 - 2
EVSE/Modularization/Module_Wifi.c

@@ -470,8 +470,6 @@ int isFindInterface()
 
 	struct ifaddrs *ifaddr, *ifa;
 
-	//refreshUSB();
-
 	if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == WIFI_MODE_AP)
 	{
 		if (getifaddrs(&ifaddr) != FAIL)
@@ -4399,6 +4397,27 @@ int restartWPA(void)
 	return result;
 }
 
+int resetModule(void)
+{
+	//refreshUSB();
+
+	#ifdef UBLOX
+		system("ifconfig mlan0 down");
+		sleep(1);
+		system("ifconfig mlan0 up");
+	#endif
+
+	#ifdef MT7601U
+		system("ifconfig wlan0 down");
+		sleep(1);
+		system("ifconfig wlan0 up");
+	#endif
+
+	DEBUG_WARN("Wifi interface restart.\n");
+
+	return PASS;
+}
+
 void proc_sta()
 {
 	switch(Wifi_module_sts)
@@ -4446,6 +4465,7 @@ void proc_sta()
 				DEBUG_INFO("Fail to connect to the AP %d times...\n",cnt_getAP_Fail);
 				if(cnt_getAP_Fail>=3)
 				{
+					resetModule();
 					Wifi_module_sts = STA_STATE_INIT;
 					cnt_getAP_Fail = 0;
 
@@ -4491,6 +4511,7 @@ void proc_sta()
 				memset(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress, 0, sizeof ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress);
 				memset(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress, 0, sizeof ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress);
 
+				resetModule();
 				if(isFindInterface() == PASS)
 				{
 					DEBUG_INFO("Wifi interface: %s\n", Wifi.currentInterface);

+ 10 - 5
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -9967,7 +9967,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -9993,7 +9994,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10020,7 +10022,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10039,7 +10042,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10066,7 +10070,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{