Explorar o código

2021.03.19 / Jerry Wang

Actions:
Merge branch 'master' into DD360Audi
Jerry_Wang %!s(int64=4) %!d(string=hai) anos
pai
achega
52739c150d

+ 58 - 36
EVSE/Modularization/Module_4g.c

@@ -39,14 +39,16 @@
 #define DONGLE_QUECTEL	1
 #define DONGLE_UBLOX	2
 
-// Define Module mode
-#define NO_SERVICE		0
-#define CDMA			1
-#define GMS_GPRS		2
-#define WCDMA			3
-#define GMS_WCDMA		4
-#define TD_SCDMA		5
-#define UNKNOW			6
+// Define Module network mode
+#define NET_MODE_NO_SERVICE		0
+#define NET_MODE_CDMA			1
+#define NET_MODE_GMS_GPRS		2
+#define NET_MODE_WCDMA			3
+#define NET_MODE_GSM_WCDMA		4
+#define NET_MODE_TD_SCDMA		5
+#define NET_MODE_HSPA			6
+#define NET_MODE_LTE			7
+#define NET_MODE_UNKNOWN		9
 
 // Define interval
 #define SystemInterval				30	// Seconds
@@ -80,7 +82,7 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 
 char *portName[3] 				= {"/dev/ttyUSB2", "/dev/ttyUSB2", "/dev/ttyACM2"};
 char *valid_Internet[2] 		= {"8.8.8.8", "180.76.76.76"};
-char *Version_And_Date[2]		= {"V0.09","2021-03-11"};
+char *Version_And_Date[2]		= {"V0.10","2021-03-16"};
 pid_t	pid;
 
 struct dongle_info
@@ -286,7 +288,6 @@ int isReadInfo(void)
 	char rx[512];
 	char tmp[512];
 	char Length;
-	int modeStatus;
 
 	if((uart = openPort(portName[Dongle.Model])) != FAIL)
 	{
@@ -411,31 +412,30 @@ int isReadInfo(void)
 				//==============================
 				// Read Mode
 				//==============================
-				Length = at_command(uart, "at+qcfg= \"nwscanmode\"\r", rx);
+				Length = at_command(uart, "at+qnwinfo\r", rx);
 				if(Length > 0)
 				{
 					memset(tmp, 0, sizeof tmp);
-					memcpy(tmp, rx, strcspn(rx,"OK"));
-					strncpy(rx, tmp + strcspn(tmp,",")+1, 1);
-
-					modeStatus = atoi(rx);
-
-					if(modeStatus == 0)
-						Dongle.MODE = UNKNOW;
-					else if(modeStatus == 1)
-						Dongle.MODE = GMS_GPRS;
-					else if(modeStatus == 2)
-						Dongle.MODE = WCDMA;
-					else if(modeStatus == 3)
-						Dongle.MODE = UNKNOW;
-					else if(modeStatus == 4)
-						Dongle.MODE = TD_SCDMA;
-					else if(modeStatus == 5)
-						Dongle.MODE = UNKNOW;
-					else if(modeStatus == 6)
-						Dongle.MODE = CDMA;
+
+					strncpy(tmp, &rx[strcspn(rx,":")+2], strcspn(rx,",")-(strcspn(rx,":")+2));
+
+
+					if(strstr(tmp, "CDMA") != NULL)
+						Dongle.MODE = NET_MODE_CDMA;
+					else if((strstr(tmp, "GPRS") != NULL) || (strstr(tmp, "EDGE") != NULL))
+						Dongle.MODE = NET_MODE_GMS_GPRS;
+					else if(strstr(tmp, "WCDMA") != NULL)
+						Dongle.MODE = NET_MODE_WCDMA;
+					else if(strstr(tmp, "GSM") != NULL)
+						Dongle.MODE = NET_MODE_GSM_WCDMA;
+					else if(strstr(tmp, "TDSCDMA") != NULL)
+						Dongle.MODE = NET_MODE_TD_SCDMA;
+					else if(strstr(tmp, "LTE") != NULL)
+						Dongle.MODE = NET_MODE_LTE;
+					else if((strstr(tmp, "HSDPA") != NULL) || (strstr(tmp, "HSUPA") != NULL) || (strstr(tmp, "HSPA+") != NULL))
+						Dongle.MODE = NET_MODE_HSPA;
 					else
-						Dongle.MODE = UNKNOW;
+						Dongle.MODE = NET_MODE_UNKNOWN;
 				}
 				else
 					result = FAIL;
@@ -1174,6 +1174,28 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
 	dest[cnt] = 0;
 }
 
+int csq2rssi(int csq)
+{
+	int result = 0;
+
+	switch(csq)
+	{
+		case 0 ... 31:
+			result = -113+(2*csq);
+			break;
+		case 100 ... 191:
+			result = -116 + (csq-102);
+			break;
+		case 99:
+		case 199:
+		default:
+			result = csq;
+			break;
+	}
+
+	return result;
+}
+
 //==========================================
 // Main process
 //==========================================
@@ -1232,7 +1254,7 @@ TOP:
 							memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei));
 						memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei, Dongle.IMEI, sizeof Dongle.IMEI);
 
-						ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = Dongle.CSQ;
+						ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = csq2rssi(Dongle.CSQ);
 						ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode = Dongle.MODE;
 
 						DEBUG_INFO("========================================\n");
@@ -1242,7 +1264,7 @@ TOP:
 						DEBUG_INFO("Device MODEL: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName);
 						DEBUG_INFO("Device REVISION: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer);
 						DEBUG_INFO("Device IMEI: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei);
-						DEBUG_INFO("Device RSSI: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
+						DEBUG_INFO("Device RSSI: %d dBm (CSQ:%d)\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi, Dongle.CSQ);
 						DEBUG_INFO("Device MODE: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode);
 						DEBUG_INFO("========================================\n");
 						
@@ -1289,7 +1311,7 @@ TOP:
 									if(CheckSignalRssi() != PASS)
 										DEBUG_INFO("No RSSI\n");
 									else
-										ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = Dongle.CSQ;
+										ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = csq2rssi(Dongle.CSQ);
 
 									DEBUG_INFO("========================================\n");
 									DEBUG_INFO("Status: 4G Device connecting...\n");
@@ -1409,7 +1431,7 @@ TOP:
 					{
 						DEBUG_ERROR("Device info read error fail: %d\n", Dongle.cnt_ReadInfoFail);
 						
-						Dongle.MODE = NO_SERVICE;
+						Dongle.MODE = NET_MODE_NO_SERVICE;
 						memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName, 0, sizeof ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName);
 						memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer, 0, sizeof ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer);
 						memset(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, 0, sizeof ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev);
@@ -1423,7 +1445,7 @@ TOP:
 						DEBUG_INFO("Device MODEL: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName);
 						DEBUG_INFO("Device REVISION: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer);
 						DEBUG_INFO("Device IMEI: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei);
-						DEBUG_INFO("Device RSSI: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
+						DEBUG_INFO("Device RSSI: %d dBm (CSQ:%d)\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi, Dongle.CSQ);
 						DEBUG_INFO("Device MODE: %d\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode);
 						DEBUG_INFO("========================================\n");
 

+ 9 - 5
EVSE/Modularization/Module_Wifi.c

@@ -630,7 +630,11 @@ int isConnectAP()
 			if(strstr(buf, "Not-Associated") > 0)
 			{
 				result = FAIL;
-				DEBUG_INFO("AP check: Not-Associated.\n");
+			}
+
+			if(strstr(buf, "Access Point") > 0)
+			{
+				DEBUG_INFO("Link AP info: %s", &buf[strcspn(buf, "Mode")]);
 			}
 		}
 	}
@@ -782,7 +786,7 @@ int setWPAconf()
 					strcat(buffer, "network={\n    ssid=\"");
 					strcat(buffer, (char*)Wifi_A.ssid);
 					strcat(buffer, "\"\n    key_mgmt=WPA-EAP WPA-PSK \n");
-					strcat(buffer, "    bgscan=\"simple:10:-65:60\" \n");
+					strcat(buffer, "    bgscan=\"simple:10:-65:3600\" \n");
 					strcat(buffer, "    psk=\"");
 					strcat(buffer, (char*)Wifi_A.passwd);
 					strcat(buffer, "\"\n}\n\n");
@@ -796,14 +800,14 @@ int setWPAconf()
 					strcat(buffer, "    wep_key0=\"");
 					strcat(buffer, (char*)Wifi_A.passwd);
 					strcat(buffer, "\"\n    auth_alg=OPEN SHARED\n");
-					strcat(buffer, "    bgscan=\"simple:10:-65:60\"\n");
+					strcat(buffer, "    bgscan=\"simple:10:-65:3600\"\n");
 					strcat(buffer, "\n}\n\n");
 				}
 
 				strcat(buffer, "network={\n    ssid=\"");
 				strcat(buffer, (char*)Wifi_A.ssid);
 				strcat(buffer, "\"\n    key_mgmt=NONE");
-				strcat(buffer, "\n    bgscan=\"simple:10:-65:60\"");
+				strcat(buffer, "\n    bgscan=\"simple:10:-65:3600\"");
 				strcat(buffer, "\n}");
 			}
 			else
@@ -811,7 +815,7 @@ int setWPAconf()
 				strcat(buffer, "network={\n    ssid=\"");
 				strcat(buffer, (char*)Wifi_A.ssid);
 				strcat(buffer, "\"\n    key_mgmt=NONE");
-				strcat(buffer, "\n    bgscan=\"simple:10:-65:60\"");
+				strcat(buffer, "\n    bgscan=\"simple:10:-65:3600\"");
 				strcat(buffer, "\n}");
 			}
 

+ 12 - 0
EVSE/Modularization/WebService.c

@@ -990,6 +990,7 @@ int main(int argc, char *argv[]) {
 			char *OcppServerURL=NULL;
 			char *ChargeBoxId=NULL;
 			char *chargePointVendor=NULL;
+			int isEnableLocalPowerSharging=0;
 
 			if( json_object_object_get_ex(jobj, "BackendConnTimeout", &val_obj) ) {
 				BackendConnTimeout = json_object_get_int(val_obj);
@@ -1019,6 +1020,10 @@ int main(int argc, char *argv[]) {
 				chargePointVendor = (char*)json_object_get_string(val_obj);
 				strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor,chargePointVendor);
 			}
+			if( json_object_object_get_ex(jobj, "isEnableLocalPowerSharging", &val_obj) ) {
+				isEnableLocalPowerSharging = json_object_get_int(val_obj);
+				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging = isEnableLocalPowerSharging;
+			}
 
 		}
 		struct SysConfigData 	SysConfig;
@@ -1546,6 +1551,7 @@ int main(int argc, char *argv[]) {
 		struct json_object *OcppServerURL;
 		struct json_object *ChargeBoxId;
 		struct json_object *chargePointVendor;
+		struct json_object *isEnableLocalPowerSharging;
 
 		jobj1=json_object_new_object();
 		jobj2=json_object_new_object();
@@ -2087,6 +2093,9 @@ int main(int argc, char *argv[]) {
 		OcppServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL);
 		ChargeBoxId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 		chargePointVendor = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+		if(strcmp(IsDO, "AX") == 0){
+			isEnableLocalPowerSharging = json_object_new_int(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
+		}
 
 		//system
 		json_object_object_add(jobj1,"ModelName",ModelName);
@@ -2421,6 +2430,9 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"OcppServerURL",OcppServerURL);
 		json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
 		json_object_object_add(jobj4,"chargePointVendor",chargePointVendor);
+		if(strcmp(IsDO, "AX") == 0){
+			json_object_object_add(jobj4,"isEnableLocalPowerSharging",isEnableLocalPowerSharging);
+		}
 		printf("%s\n", json_object_to_json_string(jobj4));
 		json_object_put(jobj4);
 	}

+ 6 - 1
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -11535,7 +11535,7 @@ void createFirmwareVersionByDataTransfer(void)
 		json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
 	}
 
-	sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
+	sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 	sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
 	sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
 }
@@ -16638,6 +16638,11 @@ int isConnectorInitMode(int gun_index)
 	return result;
 }
 
+void refreshProcDogTimer()
+{
+	ShmOCPP20Data->procDogTime = time((time_t*)NULL);
+}
+
 void InitialSystemValue(void)
 {
 	int connectorIndex = 0;

+ 1 - 0
EVSE/Modularization/ocpp20/MessageHandler.h

@@ -1006,6 +1006,7 @@ void splitstring(char *src,const char *separator,char **dest,int *num);
 int GetWebSocketPingInterval(void);
 int GetInternetConn(void);
 int isConnectorInitMode(int gun_index);
+void refreshProcDogTimer();
 int GetServerSign(void);
 void SetServerSign(int value);
 int GetBootNotificationInterval(void);

+ 2 - 0
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -1225,6 +1225,8 @@ int main(void)
 		{
 			lws_service(context, 0);//timeout_ms
 		}while((SendBufLen>0) && (context!=NULL) && GetInternetConn());
+
+		refreshProcDogTimer();
 		usleep(100000);
 	}
 	pthread_join(tid_ProcQueue, NULL);

+ 7 - 2
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -3936,7 +3936,7 @@ S_FAULT                 =12
 
 	//it's option
 	strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Timestamp, buf);
-	strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].VendorId, "PhihongTechnology");
+	strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].VendorId, (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 	strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[currentStatus]);
 
 	random_uuid(guid);
@@ -7589,7 +7589,7 @@ void createFirmwareVersionByDataTransfer(void)
 		json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
 	}
 
-	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "Phihong Technology");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId, "ID_FirmwareVersion");
 	sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
 	json_object_put(FirmwareDataTransfer);
@@ -16695,6 +16695,11 @@ int isConnectorInitMode(int gun_index)
 	return result;
 }
 
+void refreshProcDogTimer()
+{
+	ShmOCPP16Data->procDogTime = time((time_t*)NULL);
+}
+
 void InitialSystemValue(void)
 {
 	int connectorIndex = 0;

+ 1 - 0
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -552,6 +552,7 @@ void splitstring(char *src,const char *separator,char **dest,int *num);
 int GetWebSocketPingInterval(void);
 int GetInternetConn(void);
 int isConnectorInitMode(int gun_index);
+void refreshProcDogTimer();
 int GetServerSign(void);
 void SetServerSign(int value);
 int GetBootNotificationInterval(void);

+ 2 - 0
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -1546,6 +1546,8 @@ int main(void)
 		{
 			lws_service(context, 0);//timeout_ms
 		}while((SendBufLen>0) && (context!=NULL) && GetOcppConnStatus());
+
+		refreshProcDogTimer();
 		usleep(100000);
 	}
 	pthread_join(tid_ProcQueue, NULL);

+ 34 - 0
EVSE/Projects/AW-CCS/Apps/main.c

@@ -1749,6 +1749,26 @@ void InitEthernet()
 				if(cnt_pingDNS_Fail >= 3)
 				{
 					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
+					if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
+						system(tmpbuf);
+					}
+					else
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
+								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
+								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
+						system(tmpbuf);
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"route add default gw %s eth0 &",
+						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
+						system(tmpbuf);
+					}
+					cnt_pingDNS_Fail = 0;
 				}
 				else
 				{
@@ -2975,6 +2995,13 @@ void checkTask()
 	{
 		if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 		{
+			if((time((time_t*)NULL) - ShmOCPP16Data->procDogTime) > 180)
+			{
+				DEBUG_WARN("OcppBackend watch dog timeout task restart.\n");
+				ShmOCPP16Data->procDogTime =  time((time_t*)NULL);
+				system("pkill OcppBackend");
+			}
+
 			if(system("pidof -s OcppBackend > /dev/null") != 0)
 			{
 				DEBUG_INFO("OcppBackend not running, restart it.\n");
@@ -2983,6 +3010,13 @@ void checkTask()
 		}
 		else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 		{
+			if((time((time_t*)NULL) - ShmOCPP20Data->procDogTime) > 180)
+			{
+				DEBUG_WARN("OcppBackend20 watch dog timeout task restart.\n");
+				ShmOCPP16Data->procDogTime =  time((time_t*)NULL);
+				system("pkill OcppBackend20");
+			}
+
 			if(system("pidof -s OcppBackend20 > /dev/null") != 0)
 			{
 				DEBUG_INFO("OcppBackend20 not running, restart it.\n");

+ 37 - 1
EVSE/Projects/AW-Regular/Apps/main.c

@@ -1641,6 +1641,8 @@ void InitEthernet()
 	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
 	ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
 	ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
+	DEBUG_INFO("eth0 config as ip: %s, netmask: %s\n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
+													   ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
 	system(tmpbuf);
 	memset(tmpbuf,0,256);
 	sprintf(tmpbuf,"route add default gw %s eth0 &",
@@ -1701,7 +1703,7 @@ void InitEthernet()
 				{
 					system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
 					memset(tmpbuf,0,256);
-				        sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
+					sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
 					        ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
 					        ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
 					system(tmpbuf);
@@ -1722,6 +1724,26 @@ void InitEthernet()
 				if(cnt_pingDNS_Fail >= 3)
 				{
 					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
+					if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
+						system(tmpbuf);
+					}
+					else
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
+								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
+								ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
+						system(tmpbuf);
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"route add default gw %s eth0 &",
+						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
+						system(tmpbuf);
+					}
+					cnt_pingDNS_Fail = 0;
 				}
 				else
 				{
@@ -2846,6 +2868,13 @@ void checkTask()
 	{
 		if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 		{
+			if((time((time_t*)NULL) - ShmOCPP16Data->procDogTime) > 180)
+			{
+				DEBUG_WARN("OcppBackend watch dog timeout task restart.\n");
+				ShmOCPP16Data->procDogTime =  time((time_t*)NULL);
+				system("pkill OcppBackend");
+			}
+			
 			if(system("pidof -s OcppBackend > /dev/null") != 0)
 			{
 				DEBUG_INFO("OcppBackend not running, restart it.\n");
@@ -2854,6 +2883,13 @@ void checkTask()
 		}
 		else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 		{
+			if((time((time_t*)NULL) - ShmOCPP20Data->procDogTime) > 180)
+			{
+				DEBUG_WARN("OcppBackend20 watch dog timeout task restart.\n");
+				ShmOCPP16Data->procDogTime =  time((time_t*)NULL);
+				system("pkill OcppBackend20");
+			}
+			
 			if(system("pidof -s OcppBackend20 > /dev/null") != 0)
 			{
 				DEBUG_INFO("OcppBackend20 not running, restart it.\n");

BIN=BIN
EVSE/Projects/AW-Regular/Images/FactoryDefaultConfig.bin


BIN=BIN
EVSE/Projects/AW-Regular/Images/ramdisk.gz


+ 28 - 1
EVSE/Projects/Noodoe/Apps/main.c

@@ -1023,6 +1023,26 @@ void InitEthernet()
 				if(cnt_pingDNS_Fail >= 3)
 				{
 					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
+					if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
+						system(tmpbuf);
+					}
+					else
+					{
+						system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
+						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
+						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
+						system(tmpbuf);
+						memset(tmpbuf,0,256);
+						sprintf(tmpbuf,"route add default gw %s eth0 &",
+						ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
+						system(tmpbuf);
+					}
+					cnt_pingDNS_Fail = 0;
 				}
 				else
 				{
@@ -2067,6 +2087,13 @@ void checkTask()
 
 	if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0)
 	{
+		if((time((time_t*)NULL) - ShmOCPP16Data->procDogTime) > 180)
+		{
+			DEBUG_WARN("OcppBackend watch dog timeout task restart.\n");
+			ShmOCPP16Data->procDogTime =  time((time_t*)NULL);
+			system("pkill OcppBackend");
+		}
+
 		if(system("pidof -s OcppBackend > /dev/null") != 0)
 		{
 			DEBUG_INFO("OcppBackend not running, restart it.\n");
@@ -3811,4 +3838,4 @@ int main(void)
 	}
 
 	return FAIL;
-}
+}

BIN=BIN
EVSE/Projects/Noodoe/Images/root/Module_AlarmDetect


BIN=BIN
EVSE/Projects/Noodoe/Images/root/Module_FactoryConfig


BIN=BIN
EVSE/Projects/Noodoe/Images/root/Module_InternalComm


+ 3 - 1
EVSE/Projects/define.h

@@ -342,7 +342,7 @@ struct TeleConfigData
 	unsigned char		TelcomSimImsi[16];			//default: Null
 	unsigned char		TelcomSimIccid[22];			//default: Null
 	unsigned char		TelcomSimStatus;			//0: no SIM card is found, 1: valid SIM card, 2: invalid SIM card
-	unsigned char		TelcomModemMode;			//0: No services, 1: CDMA, 2: GSM/GPRS, 3: WCDMA, 4: GSM/WCDMA, 5: TD_SCDMA mode, 6: Unknow
+	unsigned char		TelcomModemMode;			//0: No services, 1: CDMA, 2: GSM/GPRS, 3: WCDMA, 4: GSM/WCDMA, 5: TD_SCDMA, 6: HSPA, 7: LTE 9: Unknown
 	unsigned char		TelcomIpAddress[16];		//default: Null
 	unsigned char		TelcomNetworkConn;			//0: disconnected, 1: connected
 	unsigned char		TelcomEnabled;				//0: disable, 1: enable
@@ -4206,6 +4206,7 @@ struct OCPP16Data
     unsigned char                           OcppConnStatus;         //0: disconnected, 1: connected
     unsigned int                            Timeout_Secs;
     unsigned short                          Ping_Pong_Interval;
+    unsigned int 							procDogTime;			// Process watch dog refresh timer
     union
     {
         //Operations Initiated by Charge Point
@@ -5476,6 +5477,7 @@ struct OCPP20Data
 	unsigned char 							OcppConnStatus;			//0: disconnected, 1: connected
 	unsigned int 							Timeout_Secs;
 	unsigned short 							Ping_Pong_Interval;
+	unsigned int 							procDogTime;			// Process watch dog refresh timer
 	struct ReportDataType                   ControllerComponentVariable[CtrlrVariable_CNT];
 	struct NetworkConnectionProfile_20      NetworkConnectionProfile[10];
 

BIN=BIN
EVSE/rootfs/lib/modules/mt7601u_nat.ko


BIN=BIN
EVSE/rootfs/root/OcppBackend20


+ 33 - 3
EVSE/rootfs/var/www/set_backend.php

@@ -3,6 +3,8 @@
 	$tag_header = 'set';
 	include 'head.php';
 	$obj = json_decode(trim($output[3]));//var_dump($obj);
+	$system = json_decode(trim($output[0]));
+	$ModelName = $system->{'ModelName'};
 	$OcppConnStatus='';
 	switch ($obj->{'OcppConnStatus'}){
 		case 0:
@@ -98,6 +100,15 @@ img {
 											<label>Charge Point Vendor</label>
 											<input type="text" name="chargePointVendor" id="chargePointVendor" class="form-control" value="<?php echo $obj->{'chargePointVendor'};?>">
 										</div>
+<?php if(substr($ModelName,0,2)=="AX"){?>
+										<div class="form-group" style="display:block">
+											<label>Local Loading Balance</label>
+											<select class="form-control" id="isEnableLocalPowerSharging" name="isEnableLocalPowerSharging" onChange="isEnableLocalPowerSharging_changed()">
+												<option value="0" <?php echo $obj->{'isEnableLocalPowerSharging'}=="0"?"selected":""?>>disable</option>
+												<option value="1" <?php echo $obj->{'isEnableLocalPowerSharging'}=="1"?"selected":""?>>enable</option>
+											</select>
+										</div>
+<?php } ?>
 									</section>
 								</article>
 								<article class="envor-sorting-item css">
@@ -116,7 +127,11 @@ img {
 ?>
 
 <script type="text/JavaScript">
-
+<?php if(substr($ModelName,0,2)=="AX"){?>
+	$(document).ready(function(){
+		isEnableLocalPowerSharging_changed();
+	});
+<?php } ?>
 	document.getElementById("save").onclick = function() {
 		if(formCheck())
 		{
@@ -135,7 +150,9 @@ img {
 						"&OcppServerURL=" + document.getElementById("OcppServerURL").value+
 						"&ChargeBoxId=" + document.getElementById("ChargeBoxId").value+
 						"&chargePointVendor=" + document.getElementById("chargePointVendor").value;
-			
+<?php if(substr($ModelName,0,2)=="AX"){?>
+				data += "&isEnableLocalPowerSharging=" + document.getElementById("isEnableLocalPowerSharging").value;
+<?php } ?>
 			// POST 請求必須設置表頭在 open() 下面,send() 上面
 			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 			request.send(data);
@@ -186,7 +203,20 @@ img {
 		}
 		return true;
 	}
-
+<?php if(substr($ModelName,0,2)=="AX"){?>
+	function isEnableLocalPowerSharging_changed(){
+		if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1){
+			document.getElementById("OcppServerURL").setAttribute("readOnly","true");
+			document.getElementById("ChargeBoxId").setAttribute("readOnly","true");
+			document.getElementById("chargePointVendor").setAttribute("readOnly","true");
+		}
+		else{
+			document.getElementById("OcppServerURL").removeAttribute("readOnly");
+			document.getElementById("ChargeBoxId").removeAttribute("readOnly");
+			document.getElementById("chargePointVendor").removeAttribute("readOnly");
+		}
+	}
+<?php } ?>
 	function isNumberKey(evt)
 	{
 		var charCode = (evt.which) ? evt.which : event.keyCode

+ 4 - 0
EVSE/rootfs/var/www/set_backend_action.php

@@ -45,6 +45,10 @@
 		if(isset($_POST['chargePointVendor'])){
 			$json['chargePointVendor']				= $_POST['chargePointVendor'];
 		}
+		if(isset($_POST['isEnableLocalPowerSharging'])){
+			checkValue("isEnableLocalPowerSharging");
+			$json['isEnableLocalPowerSharging']		= (int)$_POST['isEnableLocalPowerSharging'];
+		}
 //		ob_start();
 		
 		shell_exec('sync;sync;sync');

+ 7 - 1
EVSE/rootfs/var/www/set_network.php

@@ -66,7 +66,13 @@
 			$TelcomModemMode='TD_SCDMA mode';
 			break;
 		case 6:
-			$TelcomModemMode='Unknow';
+                        $TelcomModemMode='HSPA';
+                        break;
+		case 7:
+                        $TelcomModemMode='LTE';
+                        break;
+		case 9:
+			$TelcomModemMode='Unknown';
 			break;
 	}
 ?>

+ 0 - 2
EVSE/rootfs/var/www/set_system.php

@@ -119,7 +119,6 @@ img {
 												</span>
 											</div>
 										</div>
-<?php if(substr($ModelName,0,2)!="DO"){?>
 										<div class="form-group" style="display:<?php echo $am001;?>">
 											<label>AC Phase Loss Policy</label>
 											<select class="form-control" id="PhaseLossPolicy" name="PhaseLossPolicy">
@@ -127,7 +126,6 @@ img {
 												<option value="1" <?php echo $obj->{'PhaseLossPolicy'}=="1"?"selected":""?>>stop charging</option>
 											</select>
 										</div>
-<?php } ?>
 										<div class="form-group" style="display:<?php echo $am111;?>">
 											<label>
 											<input type="checkbox" id="FactoryConfiguration" name="FactoryConfiguration" <?php echo $obj->{'FactoryConfiguration'}==1?"checked":"";?>>