瀏覽代碼

2021-04-09 / Eason Yang
Action
1. Synchronize improve issue from AW-Regular to AW-ChargeLab
2. Customization : Customized factory configuration.

File
1. main.c
Action 1

2.Module_FactoryConfig.c
Action 2

Version : V0.68.XX.XXXX.AX

8009 4 年之前
父節點
當前提交
fc95e329de
共有 2 個文件被更改,包括 80 次插入45 次删除
  1. 14 12
      EVSE/Projects/AW-ChargeLab/Apps/Module_FactoryConfig.c
  2. 66 33
      EVSE/Projects/AW-ChargeLab/Apps/main.c

+ 14 - 12
EVSE/Projects/AW-ChargeLab/Apps/Module_FactoryConfig.c

@@ -283,8 +283,8 @@ int main(int argc, char *argv[])
 	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);
 	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.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 = 1;	// 0: Little endian	1: Big endian
 
 	// Charging configuration
 	SysConfig.MaxChargingEnergy = 0;	// 0: No limit	Other: 1~65536 KWH
@@ -306,29 +306,31 @@ int main(int argc, char *argv[])
 	strcpy((char*)SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	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.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+	strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
+	strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 	SysConfig.AthInterface.WifiRssi = 0;		// Wifi rssi value
-	SysConfig.AthInterface.WifiDhcpServer = 0;	// 0: Enable	1: Disable
-	SysConfig.AthInterface.WifiDhcpClient = 0;	// 0: Enable	1: Disable
+	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
+	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "m2minternet.apn");
+	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
+	SysConfig.TelecomInterface.TelcomModemMode = 0;	// 0: No services 1: CDMA 2: GSM/GPRS 3: WCDMA 4: GSM/WCDMA	5: TD_SCDMA	6: Unknown
 
 	// Backend configuration
 	strcpy((char*)SysConfig.OcppServerURL, "");
 	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	SysConfig.BackendConnTimeout=300; 		// 300 seconds
-	SysConfig.OfflinePolicy = 2;			// 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
 	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.isReqFirstUpgrade = 1;		// 0: Skip first upgrade, 1: Process first upgrade
 
 	// Customization configuration item
-	if(strstr((char*)&SysConfig.ModelName[12], "P0") != NULL)
+	if(SysConfig.ModelName[12] == 'A')
 	{
-		strcpy((char*)SysConfig.OcppServerURL, "");
+		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	}
 	else

+ 66 - 33
EVSE/Projects/AW-ChargeLab/Apps/main.c

@@ -677,22 +677,28 @@ uint8_t ocpp_get_starttransaction_result(uint8_t gun_index)
 
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
-		if((strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Blocked")==0) ||
-		   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Expired")==0) ||
-		   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid")==0))
-			result = NO;
+		if(strstr((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "TRUE"))
+		{
+			if((strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Blocked")==0) ||
+			   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Expired")==0) ||
+			   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid")==0))
+				result = NO;
+		}
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
-		if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Blocked")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Expired")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Invalid")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NoCredit")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAllowedTypeEVSE")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisLocation")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisTime")==0) ||
-		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Unknown")==0))
-			result = NO;
+		if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "TRUE"))
+		{			
+			if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Blocked")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Expired")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Invalid")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NoCredit")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAllowedTypeEVSE")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisLocation")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisTime")==0) ||
+			   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Unknown")==0))
+				result = NO;
+		}
 	}
 
 	return result;
@@ -1690,7 +1696,7 @@ void InitEthernet()
 		{
 			if(isRouteFail())
 			{
-				DEBUG_ERROR("eth0 not in route, restart eth0.\n");
+				//DEBUG_ERROR("eth0 not in route, restart eth0.\n");
 				system("/sbin/ifconfig eth0 down;/sbin/ifconfig eth0 up");
 
 				if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
@@ -2050,7 +2056,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.67.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.68.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -2978,6 +2984,8 @@ void checkReset()
 				ShmOCPP16Data->MsMsg.bits.ResetConf = ON;
 
 				DEBUG_INFO("%s reset request by OCPP.\n", ShmOCPP16Data->Reset.Type);
+				for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
+					setChargerMode(gun_index, SYS_MODE_BOOTING);
 				if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard") == 0)
 				{
 					system("sync");
@@ -3007,6 +3015,8 @@ void checkReset()
 				ShmOCPP20Data->MsMsg.bits.ResetConf = ON;
 
 				DEBUG_INFO("%s reset request by OCPP.\n", ShmOCPP20Data->Reset.type);
+				for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
+					setChargerMode(gun_index, SYS_MODE_BOOTING);
 				if(strcmp((char*)ShmOCPP20Data->Reset.type, "Immediate") == 0)
 				{
 
@@ -3233,24 +3243,32 @@ void checkStopReason(uint8_t gun_index)
 {
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
-		if(ShmOCPP16Data->MsMsg.bits.ResetReq)
+		if(!ocpp_get_starttransaction_result(gun_index))
+		{
+			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "DeAuthorized");
+		}
+		else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
+		{
+			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EmergencyStop");
+		}
+		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		{
+			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+		}
+		else if(ShmOCPP16Data->MsMsg.bits.ResetReq)
 		{
 			if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
 				sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "HardReset");
 			else
 				sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "SoftReset");
 		}
-		else if(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq)
-		{
-			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Remote");
-		}
 		else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
 		{
 			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
 		}
-		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		else if(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq)
 		{
-			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Remote");
 		}
 		else if(ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON)
 		{
@@ -3268,24 +3286,40 @@ void checkStopReason(uint8_t gun_index)
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
-		if(ShmOCPP20Data->MsMsg.bits.ResetReq)
+		if(!ocpp_get_starttransaction_result(gun_index))
 		{
-			if(strcmp((char*)ShmOCPP20Data->Reset.type, "Hard")==0)
-				sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "HardReset");
-			else
-				sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "SoftReset");
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "DeAuthorized");
 		}
-		else if(ShmOCPP20Data->CsMsg.bits[gun_index].RequestStopTransactionReq)
+		else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
 		{
-			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "Remote");
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EmergencyStop");
+		}
+		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		{
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EVDisconnected");
+		}
+		else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
+		{
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "GroundFault");
+		}
+		else if(ShmOCPP20Data->MsMsg.bits.ResetReq)
+		{
+			if(strcmp((char*)ShmOCPP20Data->Reset.type, "Immediate")==0)
+				sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "ImmediateReset");
+			else
+				sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "OnIdle");
 		}
 		else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
 		{
 			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "Local");
 		}
-		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_CURRENT))
 		{
-			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EVDisconnected");
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "OvercurrentFault");
+		}
+		else if(ShmOCPP20Data->CsMsg.bits[gun_index].RequestStopTransactionReq)
+		{
+			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "Remote");
 		}
 		else if(ShmCharger->gun_info[ShmOCPP20Data->UnlockConnector[gun_index].connectorId-1].isUnlockerConnetor == ON)
 		{
@@ -4236,6 +4270,7 @@ int main(void)
 						// If relay is off, the system should change to complete mode
 						if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
 						{
+							checkStopReason(gun_index);
 							setChargerMode(gun_index, SYS_MODE_COMPLETE);
 						}
 					}
@@ -4398,8 +4433,6 @@ int main(void)
 						sleep(3);
 					}
 
-					checkStopReason(gun_index);
-
 					ShmCharger->gun_info[gun_index].rfidReq = OFF;
 					ShmCharger->gun_info[gun_index].isAuthPassEnd = OFF;
 					ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;