Эх сурвалжийг харах

Merge remote-tracking branch 'origin/AW-Regular'

Folus Wen 2 жил өмнө
parent
commit
c5f394e269

+ 5 - 2
EVSE/Projects/AW-Regular/Apps/Makefile

@@ -4,7 +4,10 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 #define library variable
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
+Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
+Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c
+
 
 
 all: CopyFile apps
 all: CopyFile apps
 apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_ConfigTools_Task Module_Debug_Task
 apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_ConfigTools_Task Module_Debug_Task
@@ -73,8 +76,8 @@ Module_AlarmDetect_Task:
 Module_CSU_Task:
 Module_CSU_Task:
 	@echo "===== Module_CSU_Task ============================================"
 	@echo "===== Module_CSU_Task ============================================"
 	rm -f main 
 	rm -f main 
-	$(CC) -D $(Project) "-I../../" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
-	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3}
+	$(CC) -D $(Project) "-I../../" "-include../../../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c/json.h" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" "-include../../../Modularization/Module_RatedCurrent.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
+	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} ${Lib_Module_RatedCurrent} ${Lib_JSONC} 
 	rm -f *.o
 	rm -f *.o
 	mv -f main ../Images/root		
 	mv -f main ../Images/root		
 	@echo \
 	@echo \

+ 52 - 39
EVSE/Projects/AW-Regular/Apps/Module_FactoryConfig.c

@@ -15,12 +15,12 @@
 
 
 #include 	<unistd.h>
 #include 	<unistd.h>
 #include 	<stdarg.h>
 #include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <unistd.h>
+#include    <fcntl.h>
+#include    <termios.h>
+#include    <errno.h>
 #include 	<errno.h>
 #include 	<errno.h>
 #include 	<string.h>
 #include 	<string.h>
 #include	<time.h>
 #include	<time.h>
@@ -264,23 +264,25 @@ int main(int argc, char *argv[])
 	{
 	{
 		memcpy((char*)SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
 		memcpy((char*)SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
 		memcpy((char*)SysConfig.SerialNumber, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
 		memcpy((char*)SysConfig.SerialNumber, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
+		memcpy((char*)SysConfig.CsuBootLoadFwRev, ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev));
 
 
 		DEBUG_INFO("InitShareMemory OK.\n");
 		DEBUG_INFO("InitShareMemory OK.\n");
 	}
 	}
 	
 	
 	sprintf((char*)SysConfig.SystemId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	sprintf((char*)SysConfig.SystemId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	sprintf((char*)SysConfig.SystemDateTime, "%d-%d-%d %d:%d:%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
 	sprintf((char*)SysConfig.SystemDateTime, "%d-%d-%d %d:%d:%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
-	SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-	SysConfig.DefaultLanguage  = 0;		// 0:English	1:Big5				2: GB			3: JN		4: Français 	5: Italiano		6: Español		7: Deutsch		8: Nederland	9: Norsk	10: Suomalainen		11: Svenska		12: Pусский		13: ไทย
-	SysConfig.RfidCardNumEndian = 0;	// 0: Little endian		1: Big endian
+	SysConfig.AuthorisationMode = 0;		// 0: enable, 1: disable
+	SysConfig.DefaultLanguage  = 0;			// 0: English 1: Big5 2: GB 3: JN 4: Français 5: Italiano 6: Español 7: Deutsch 8: Nederland 9: Norsk 10: Suomalainen 11: Svenska 12: Pусский 13: ไทย
+	SysConfig.RfidCardNumEndian = 0;		// 0: Little endian 1: Big endian
+	SysConfig.BillingData.isBilling = 0;	// 0: not for business	1: for business
 
 
 	// Charging configuration
 	// Charging configuration
-	SysConfig.MaxChargingEnergy = 0;	// 0: No limit	Other: 1~65536 KWH
-	SysConfig.MaxChargingPower = 0;		// 0: No limit	Other: 1~65536 KW
-	SysConfig.MaxChargingCurrent = 0;	// 0: Rating value	Other: 1~Rating A
-	SysConfig.MaxChargingDuration = 0;	// 0: No limit	Other: 1~65536 Minute
-	SysConfig.PhaseLossPolicy = 0;		// 0: Charging	1: Stop charging
-	SysConfig.AcPhaseCount = 1;			// 1: One phase	3: Three phase
+	SysConfig.MaxChargingEnergy = 0;		// 0: No limit	Other: 1~65536 KWH
+	SysConfig.MaxChargingPower = 0;			// 0: No limit	Other: 1~65536 KW
+	SysConfig.MaxChargingCurrent = 0;		// 0: Rating value	Other: 1~Rating A
+	SysConfig.MaxChargingDuration = 0;		// 0: No limit	Other: 1~65536 Minute
+	SysConfig.PhaseLossPolicy = 0;			// 0: Charging	1: Stop charging
+	SysConfig.AcPhaseCount = 1;				// 1: One phase	3: Three phase
 
 
 	// Network configuration
 	// Network configuration
 	strcpy((char*)SysConfig.FtpServer, "");
 	strcpy((char*)SysConfig.FtpServer, "");
@@ -294,26 +296,37 @@ int main(int argc, char *argv[])
 	strcpy((char*)SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char*)SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char*)SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
 	strcpy((char*)SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
 
 
-	SysConfig.AthInterface.WifiMode = 2;		// 0: Disable	1: Infrastructure client	2: Infrastructure server	3: Ad-Hoc
-	SysConfig.AthInterface.WifiRssi = 0;		// Wifi rssi value
-	SysConfig.AthInterface.WifiDhcpServer = 0;	// 0: Enable	1: Disable
-	SysConfig.AthInterface.WifiDhcpClient = 0;	// 0: Enable	1: Disable
-
-	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");
-	SysConfig.TelecomInterface.TelcomEnabled = 1; 	//0: disable, 1: enable
-	SysConfig.TelecomInterface.TelcomSimStatus = 0;	// SIM card status
-	SysConfig.TelecomInterface.TelcomModemMode = 0;	//0: No services	1: CDMA		2: GSM/GPRS	3: WCDMA	4: GSM/WCDMA	5: TD_SCDMA		6: Unknown
+	// Wifi configuration
+	SysConfig.AthInterface.WifiMode = 2;								// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+	SysConfig.AthInterface.WifiRssi = 0;								// Wifi rssi value
+	strcpy((char *) SysConfig.AthInterface.WifiSsid, "");				// default: Null
+	strcpy((char *) SysConfig.AthInterface.WifiPassword, "");			// default: Null
+	SysConfig.AthInterface.WifiDhcpServer = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiDhcpClient = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiBroadcastSsid = 1;						// 0: hidden 1: broadcast
+
+	// Telecom configuration
+	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");			// default: Null
+	SysConfig.TelecomInterface.TelcomEnabled = 1; 						// 0: disable, 1: enable
+	SysConfig.TelecomInterface.TelcomRssi = 0;							// default: 0
+	SysConfig.TelecomInterface.TelcomSimStatus = 0;						// SIM card status
+	SysConfig.TelecomInterface.TelcomModemMode = 0;						// 0: No services 1: CDMA 2: GSM/GPRS 3: WCDMA 4: GSM/WCDMA 5: TD_SCDMA 6: Unknown
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");		// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");		// default: Null
 
 
 	// Backend configuration
 	// Backend configuration
 	strcpy((char*)SysConfig.OcppServerURL, "");
 	strcpy((char*)SysConfig.OcppServerURL, "");
 	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-	strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+	strcpy((char *)SysConfig.chargePointVendor, "");					// default: Null
 	strcpy((char*)SysConfig.MaintainServerURL, "");
 	strcpy((char*)SysConfig.MaintainServerURL, "");
-	SysConfig.BackendConnTimeout=300; 		// 300 seconds
-	SysConfig.OfflinePolicy = 2;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
-	SysConfig.OfflineMaxChargeEnergy = 0;	// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
-	SysConfig.OfflineMaxChargeDuration = 0; // 0: Same as MaxChargeDuration Other: 1~65535 minutes
-	//SysConfig.isReqFirstUpgrade = 1;		// 0: Skip first upgrade, 	1: Process first upgrade
+	SysConfig.BackendConnTimeout=300; 									// 300 seconds
+	SysConfig.OfflinePolicy = 2;										// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+	SysConfig.OfflineMaxChargeEnergy = 0;								// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
+	SysConfig.OfflineMaxChargeDuration = 0; 							// 0: Same as MaxChargeDuration Other: 1~65535 minutes
+	//SysConfig.isReqFirstUpgrade = 1;									// 0: Skip first upgrade, 	1: Process first upgrade
 
 
 	// Customization configuration item
 	// Customization configuration item
 	if(SysConfig.ModelName[12] == 'P')
 	if(SysConfig.ModelName[12] == 'P')
@@ -321,16 +334,16 @@ int main(int argc, char *argv[])
 		// Phihong standard configuration
 		// Phihong standard configuration
 		strcpy((char*)SysConfig.OcppServerURL, "");
 		strcpy((char*)SysConfig.OcppServerURL, "");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-		strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+		strcpy((char *)SysConfig.chargePointVendor, "");				// default: Null
 		strcpy((char*)SysConfig.MaintainServerURL, "wss://ocpp.phihong.com.tw:2013/");
 		strcpy((char*)SysConfig.MaintainServerURL, "wss://ocpp.phihong.com.tw:2013/");
 	}
 	}
 	else if(SysConfig.ModelName[12] == 'A')
 	else if(SysConfig.ModelName[12] == 'A')
 	{
 	{
 		// ChargeLab customization configuration
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
 		
@@ -339,15 +352,15 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	}
 	else if(SysConfig.ModelName[12] == 'T')
 	else if(SysConfig.ModelName[12] == 'T')
 	{
 	{
 		// ChargeLab customization configuration
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
 		
@@ -356,7 +369,7 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	}
 	else
 	else
 	{
 	{

+ 125 - 3
EVSE/Projects/AW-Regular/Apps/main.c

@@ -91,6 +91,7 @@ struct timeb					endChargingTime[AC_QUANTITY];
 sqlite3 *localDb;
 sqlite3 *localDb;
 
 
 struct SysConfigData			SysConfigOrg;
 struct SysConfigData			SysConfigOrg;
+ParsingRatedCur 				modelnameInfo={0};
 
 
 struct PreviousData
 struct PreviousData
 {
 {
@@ -432,6 +433,31 @@ int getEth0MacAddress()
 	return result;
 	return result;
 }
 }
 
 
+int isUap0up(void)
+{
+	int result = FAIL;
+
+	FILE *fp;
+	char cmd[256];
+	char buf[512];
+
+	strcpy(cmd, "ifconfig uap0");;
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			if(strstr(buf, "uap0") > 0)
+			{
+				result = PASS;
+			}
+		}
+	}
+	pclose(fp);
+
+	return result;
+}
+
 //======================================================
 //======================================================
 // OCPP routine
 // OCPP routine
 //======================================================
 //======================================================
@@ -1729,13 +1755,20 @@ void InitGPIO()
 	system("echo \"out\" > /sys/class/gpio/gpio65/direction");
 	system("echo \"out\" > /sys/class/gpio/gpio65/direction");
 	system("echo 0 > /sys/class/gpio/gpio65/value");
 	system("echo 0 > /sys/class/gpio/gpio65/value");
 
 
-	/*POWER (4G/WIFI) RST:GPIO3_14 => H:ON; L:OFF*/
+	/*(FOR ACCSU-01-RW) 4G POWER RST:GPIO3_14 => H:ON; L:OFF*/
 	system("echo 110 > /sys/class/gpio/export");
 	system("echo 110 > /sys/class/gpio/export");
 	system("echo \"out\" > /sys/class/gpio/gpio110/direction");
 	system("echo \"out\" > /sys/class/gpio/gpio110/direction");
 	system("echo 1 > /sys/class/gpio/gpio110/value");
 	system("echo 1 > /sys/class/gpio/gpio110/value");
 	sleep(3);
 	sleep(3);
 	system("echo 0 > /sys/class/gpio/gpio110/value");
 	system("echo 0 > /sys/class/gpio/gpio110/value");
 
 
+	/*(FOR ACCSU3P5-01-RW) 4G POWER RST:GPIO3_18 => H:ON; L:OFF*/
+	system("echo 114 > /sys/class/gpio/export");
+	system("echo \"out\" > /sys/class/gpio/gpio114/direction");
+	system("echo 1 > /sys/class/gpio/gpio114/value");
+	sleep(3);
+	system("echo 0 > /sys/class/gpio/gpio114/value");
+
 	DEBUG_INFO("Initial GPIO OK\n");
 	DEBUG_INFO("Initial GPIO OK\n");
 }
 }
 
 
@@ -1972,6 +2005,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	}
 	}
 
 
 	DEBUG_INFO("Load SysConfigData OK\n");
 	DEBUG_INFO("Load SysConfigData OK\n");
+	
+	RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
 
 
 	return PASS;
 	return PASS;
 }
 }
@@ -2045,6 +2080,11 @@ void InitEthernet()
 	char tmpbuf[256];
 	char tmpbuf[256];
 	unsigned int natInterface = 0;
 	unsigned int natInterface = 0;
 
 
+	// Detele bridge interface
+	system("/sbin/ifconfig uap0 down");
+	system("/sbin/ifconfig br0 down");
+	system("/usr/sbin/brctl delbr br0");
+
 	//Init Eth0 for internet
 	//Init Eth0 for internet
 	memset(tmpbuf,0,256);
 	memset(tmpbuf,0,256);
 	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
 	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
@@ -2266,17 +2306,34 @@ void InitEthernet()
 
 
 			// Check is need to reset WIFI/4G module power
 			// Check is need to reset WIFI/4G module power
 			if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
 			if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-			   ((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))) &&
-			   ((system("pidof -s Module_4g > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) || ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
+			
+			   ((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))) &&
+				
+			    ((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(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
 				if(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
 				{
 				{
 					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					{
 					{
 						DEBUG_WARN("WIFI/4G module reset.\n");
 						DEBUG_WARN("WIFI/4G module reset.\n");
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 1 > /sys/class/gpio/gpio110/value");
 						system("echo 1 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 1 > /sys/class/gpio/gpio114/value");
 						sleep(3);
 						sleep(3);
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 0 > /sys/class/gpio/gpio110/value");
 						system("echo 0 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 0 > /sys/class/gpio/gpio114/value");
 					}
 					}
 
 
 					ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 					ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
@@ -2287,6 +2344,33 @@ void InitEthernet()
 				ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 				ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 			}
 			}
 
 
+			// Bridge ethernet to uap0 to get dynamic ip address
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS) &&
+			  (access("/sys/class/net/br0/address", F_OK) == -1))
+			{
+				sleep(10);
+				system("/usr/sbin/brctl addbr br0");
+				system("/usr/sbin/brctl addif br0 eth0");
+				system("/usr/sbin/brctl addif br0 uap0");
+				system("/sbin/ifconfig br0 192.168.10.200 up");
+				system("/bin/sed -i '/interface/d' /etc/udhcpd.conf");
+				system("/bin/echo 'interface	br0' >> /etc/udhcpd.conf");
+				system("kill udhcpd");
+				system("/usr/sbin/udhcpd /etc/udhcpd.conf");
+
+				DEBUG_INFO("Bridge uap0 & eth0 for local power sharing by ethernet.\n");
+			}
+
+			// Change uap0 to low priority
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS))
+			{
+				system("/sbin/ifmetric uap0 1");
+			}
+
 			sleep(5);
 			sleep(5);
 		}
 		}
 	}
 	}
@@ -3462,6 +3546,13 @@ void checkTask()
 		DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
 		DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
 		system ("/root/Module_ProduceUtils &");
 		system ("/root/Module_ProduceUtils &");
 	}
 	}
+
+	if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
+		ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+	{
+		DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
+		system ("/root/Module_PowerSharing &");
+	}
 }
 }
 
 
 void checkConnectionTimeout()
 void checkConnectionTimeout()
@@ -3801,6 +3892,20 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 		}
 		}
 	}
 	}
 
 
+	// Charging session target current check if OCPP disconnect and power sharing server connected
+	if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+	{
+		if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+		   ShmCharger->gun_info[gun_index].targetCurrent = ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index]>ShmCharger->gun_info[gun_index].primaryMcuState.rating_current?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index];
+		else
+		{
+			if(ShmCharger->gun_info[gun_index].targetCurrent != 0)
+				DEBUG_WARN("Disconnect from power sharing server, target current set to 0.\n");
+
+			ShmCharger->gun_info[gun_index].targetCurrent = 0;
+		}
+	}
+
 	switch(system_mode)
 	switch(system_mode)
 	{
 	{
 		case SYS_MODE_IDLE:
 		case SYS_MODE_IDLE:
@@ -4236,6 +4341,23 @@ int main(void)
 			}
 			}
 		}
 		}
 
 
+		//==============================================
+		// Check Local Power Sharing Communication
+		//==============================================
+		if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+		{
+			if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == ON)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = OFF;
+			}
+			else
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == OFF)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = ON;
+			}
+		}
+
 		//==============================================
 		//==============================================
 		// Connector loop
 		// Connector loop
 		//==============================================
 		//==============================================

+ 1 - 1
Makefile

@@ -547,7 +547,7 @@ AW-Regular-uboot:
 	@echo    Building U-boot
 	@echo    Building U-boot
 	@echo ===================================
 	@echo ===================================
 	@cp -f $(UBOOT_INSTALL_DIR)/arch/arm/dts/[AW-Regular]am335x-evm.dts $(UBOOT_INSTALL_DIR)/arch/arm/dts/am335x-evm.dts
 	@cp -f $(UBOOT_INSTALL_DIR)/arch/arm/dts/[AW-Regular]am335x-evm.dts $(UBOOT_INSTALL_DIR)/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65910
+	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65217
 	@cp -f $(UBOOT_INSTALL_DIR)/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/u-boot.img EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/u-boot.img EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/

+ 44 - 53
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/[AW-Regular]am335x-evm.dts

@@ -25,7 +25,7 @@
 
 
 	cpus {
 	cpus {
 		cpu@0 {
 		cpu@0 {
-			cpu0-supply = <&vdd1_reg>;
+			cpu0-supply = <&dcdc2_reg>;
 		};
 		};
 	};
 	};
 
 
@@ -65,7 +65,7 @@
 		
 		
 			/** Offset: 0x800 */
 			/** Offset: 0x800 */
 			/** GPIO 0 */ 
 			/** GPIO 0 */ 
-			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
+			0x144 (PIN_INPUT | MUX_MODE7)    		/* RMII1_REF_CLK	=>	GPIO0_29 */	/*USB 0 OCP detection*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
 			/** GPIO 1 */			
 			/** GPIO 1 */			
@@ -80,6 +80,7 @@
 			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
 			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
 			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
 			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
 			/** GPIO 3 */
 			/** GPIO 3 */
+			0x1A0 (PIN_OUTPUT | MUX_MODE7)          /* MCASP0_AXR1  =>  GPIO3_18 */ /*control 4G reset pin*/
 			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 		>;
 		>;
 	};
 	};
@@ -323,8 +324,8 @@
 	status = "okay";
 	status = "okay";
 	clock-frequency = <400000>;
 	clock-frequency = <400000>;
 
 
-	tps: tps@2d {
-		reg = <0x2d>;
+	tps: tps@24 {
+		reg = <0x24>;
 	};
 	};
 
 
 /*	rtc0: rtc@51 {
 /*	rtc0: rtc@51 {
@@ -406,7 +407,7 @@
 	pinctrl-0 = <&nandflash_pins_default>;
 	pinctrl-0 = <&nandflash_pins_default>;
 	pinctrl-1 = <&nandflash_pins_sleep>;
 	pinctrl-1 = <&nandflash_pins_sleep>;
 	/*ranges = <0 0 0x08000000 0x10000000>;*/	/* CS0: NAND */
 	/*ranges = <0 0 0x08000000 0x10000000>;*/	/* CS0: NAND */
-	ranges = <0 0 0x08000000 0x80000000>;	/*+++ vern,NAND,20181030 ---*/
+	ranges = <0 0 0x08000000 0x40000000>;	/*+++ vern,NAND,20181030 ---*/
 	nand@0,0 {
 	nand@0,0 {
 		compatible = "ti,omap2-nand";
 		compatible = "ti,omap2-nand";
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
@@ -500,85 +501,74 @@
 		};
 		};
 		partition@13 {
 		partition@13 {
 			label = "Storage";
 			label = "Storage";
-			reg = <0x0A200000 0x75E00000>;
+			reg = <0x0A200000 0x35E00000>;
 		};
 		};
 	};
 	};
 };
 };
 
 
-#include "tps65910.dtsi"
+/include/ "tps65217.dtsi"
 
 
 &tps {
 &tps {
-	vcc1-supply = <&vbat>;
-	vcc2-supply = <&vbat>;
-	vcc3-supply = <&vbat>;
-	vcc4-supply = <&vbat>;
-	vcc5-supply = <&vbat>;
-	vcc6-supply = <&vbat>;
-	vcc7-supply = <&vbat>;
-	vccio-supply = <&vbat>;
+	/*
+	 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
+	 * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
+	 * mode and risk hardware damage if this mode is entered.
+	 *
+	 * For details, see linux-omap mailing list May 2015 thread
+	 *	[PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
+	 * In particular, messages:
+	 *	http://www.spinics.net/lists/linux-omap/msg118585.html
+	 *	http://www.spinics.net/lists/linux-omap/msg118615.html
+	 *
+	 * You can override this later with
+	 *	&tps {  /delete-property/ ti,pmic-shutdown-controller;  }
+	 * if you want to use RTC-only mode and made sure you are not affected
+	 * by the hardware problems. (Tip: double-check by performing a current
+	 * measurement after shutdown: it should be less than 1 mA.)
+	 */
+	ti,pmic-shutdown-controller;
 
 
 	regulators {
 	regulators {
-		vrtc_reg: regulator@0 {
+		dcdc1_reg: regulator@0 {
+			regulator-name = "vdds_dpr";
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vio_reg: regulator@1 {
-			regulator-always-on;
-		};
-
-		vdd1_reg: regulator@2 {
-			/* VDD_MPU voltage limits 0.95V - 1.325V with +/-4% tolerance */
+		dcdc2_reg: regulator@1 {
+			/* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
 			regulator-name = "vdd_mpu";
 			regulator-name = "vdd_mpu";
-			regulator-min-microvolt = <912500>;
-			regulator-max-microvolt = <1378000>;
+			regulator-min-microvolt = <1100000>;
+			regulator-max-microvolt = <1351500>;
 			regulator-boot-on;
 			regulator-boot-on;
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vdd2_reg: regulator@3 {
+		dcdc3_reg: regulator@2 {
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			regulator-name = "vdd_core";
 			regulator-name = "vdd_core";
-			regulator-min-microvolt = <912500>;
+			regulator-min-microvolt = <925000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-boot-on;
 			regulator-boot-on;
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vdd3_reg: regulator@4 {
-			regulator-always-on;
-		};
-
-		vdig1_reg: regulator@5 {
+		ldo1_reg: regulator@3 {
+			regulator-name = "vio,vrtc,vdds";
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vdig2_reg: regulator@6 {
+		ldo2_reg: regulator@4 {
+			regulator-name = "vdd_3v3aux";
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vpll_reg: regulator@7 {
+		ldo3_reg: regulator@5 {
+			regulator-name = "vdd_1v8";
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 
 
-		vdac_reg: regulator@8 {
-			regulator-always-on;
-		};
-
-		vaux1_reg: regulator@9 {
-			regulator-always-on;
-		};
-
-		vaux2_reg: regulator@10 {
-			regulator-always-on;
-		};
-
-		vaux33_reg: regulator@11 {
-			regulator-always-on;
-		};
-
-		vmmc_reg: regulator@12 {
-			regulator-min-microvolt = <1800000>;
-			regulator-max-microvolt = <3300000>;
+		ldo4_reg: regulator@6 {
+			regulator-name = "vdd_3v3a";
 			regulator-always-on;
 			regulator-always-on;
 		};
 		};
 	};
 	};
@@ -604,6 +594,7 @@
  	phy-mode = "mii";
  	phy-mode = "mii";
 
 
 };
 };
+
 #if 0
 #if 0
 &cpsw_emac1 {
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
 	phy_id = <&davinci_mdio>, <2>;
@@ -628,7 +619,7 @@
 
 
 &mmc1 {
 &mmc1 {
 	status = "okay";
 	status = "okay";
-	vmmc-supply = <&vmmc_reg>;
+	vmmc-supply = <&ldo4_reg>;
 	bus-width = <4>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins_default>;
 	pinctrl-0 = <&mmc1_pins_default>;

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.byteswap.cmd

@@ -0,0 +1 @@
+cmd_MLO.byteswap := ./tools/mkimage -T omapimage -n byteswap -a 0x402F0400 -d spl/u-boot-spl.bin MLO.byteswap  >/dev/null

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.cmd

@@ -0,0 +1 @@
+cmd_MLO := ./tools/mkimage -T omapimage -a 0x402F0400 -d spl/u-boot-spl.bin MLO  >/dev/null