Procházet zdrojové kódy

[Added][AW-CCS][main.h][main.c][Module_LcmControl.c]
2022-05-27 / EASON YANG
Action
1. Added: Clean EvCCID timeout flag logic.
2. Added: Check EvCCID communication error logic.
3. Added: CLEAN isRemoteStartWait flag logic.
4. Added: Logic for EvCCID charging process.
5. Added: Start method for EVCCID constant.
6. Added: Time for CLEAN_REMOTE_START_WAIT.
7. Added: Flags [isGetEvCCID], [isGetEvCCIDTimeout], [isRemoteStartWait] & [isEvCCIDAuthorizeFail].
8. Added: setPrechargingTimerToDefualt() function.
9. Added: setPrechargingEnergyToDefault() function.
10. Added: setPrechargingSessionFeeToDefault() funciton.
11. Added: setPrechargingParkingFeeToDefault() function.
12. Added: setPrechargingCostToDefualt() function.
13. Added: setCleanPrechargingValueToEmpty() function.
14. Added: Logic for EvCCID display process.

File
1. main.c
Action 1
Action 2
Action 3
Action 4

2. main.h
Action 5
Action 6
Action 7

3. Module_LcmControl.c
Action 8
Action 9
Action 10
Actino 11
Action 12
Action 13
Action 14

FIRMWARE VERSION: B0.62.XX.XXXX.PX
LCM VERSION: V0.29

8009 před 2 roky
rodič
revize
6f56d1cd42

+ 190 - 20
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,9 +2,9 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2022-04-27
+ * Update on : 2022-05-27
  * Author : Folus Wen, Eason Yang
- * Version : V0.28
+ * Version : V0.29
  *
  */
 
@@ -82,6 +82,13 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode);
 void setPresentChargedEnergy(uint8_t gun_index, uint8_t system_mode);
 void setMarqueeControl(uint16_t address, uint8_t gun_index, uint8_t type);
 
+void setPrechargingTimerToDefault();
+void setPrechargingEnergyToDefault();
+void setPrechargingSessionFeeToDefault();
+void setPrechargingParkingFeeToDefault();
+void setPrechargingCostToDefault();
+void setPrechargingPowerToDefault();
+void setClearPrechargingValueToEmpty();
 //=======================================
 // Declare Timer
 //=======================================
@@ -125,7 +132,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.28", "2022-04-27", "REV.03.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.29", "2022-05-27", "REV.03.00"};
 
 //=======================================
 // Common routine
@@ -339,11 +346,20 @@ void page_booting()
 		DEBUG_INFO("Setting page to booting.\n");
 	}
 	else
-	{}
+	{
+		setClearPrechargingValueToEmpty();
+	}
 }
 
 void page_idle(uint8_t gun_index, uint8_t system_mode)
 {
+	setPrechargingTimerToDefault();
+	setPrechargingEnergyToDefault();
+	setPrechargingSessionFeeToDefault();
+	setPrechargingParkingFeeToDefault();
+	setPrechargingCostToDefault();
+	setPrechargingPowerToDefault();
+
 	if(ocpp_get_isRemoteStartWait())
 	{
 		if((getCurrentPage() != SYSTEM_SCREEN_PREPARING))
@@ -400,17 +416,38 @@ void page_idle(uint8_t gun_index, uint8_t system_mode)
 				}
 				else
 				{
-					if((getCurrentPage() != SYSTEM_SCREEN_IDLE) && (ShmCharger->gun_info[gun_index].resultAuthorization != VALIDATED_RFID))
+					if((ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID && (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE)) &&
+					   (ShmCharger->isCcsEnable) &&
+					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
+					   (ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout == OFF) && 
+					   (ShmCharger->gun_info[gun_index].resultAuthorization != VALIDATED_RFID) &&
+					   (ShmCharger->gun_info[gun_index].isRemoteStartWait != ON) &&
+					   (ShmCharger->gun_info[gun_index].isEvCCIDAuthorizeFail != YES))
 					{
-						setCurrentPage(SYSTEM_SCREEN_IDLE);
-						setDefaultValue(gun_index, system_mode);
-						DEBUG_INFO("Setting page to idle.\n");
+						if((getCurrentPage() != SYSTEM_SCREEN_PREPARE_FOR_EVSE))
+						{
+							setCurrentPage(SYSTEM_SCREEN_PREPARE_FOR_EVSE);
+							DEBUG_INFO("Setting page to EVCCID. \n");
+						}
+						else
+						{
+							setConnectionAnimation(gun_index, system_mode);
+						}
 					}
 					else
 					{
-						setRfidIcon();
-						setQRCodeIcon();
-						setConnectionAnimation(gun_index, system_mode);
+						if((getCurrentPage() != SYSTEM_SCREEN_IDLE) && (ShmCharger->gun_info[gun_index].resultAuthorization != VALIDATED_RFID))
+						{
+							setCurrentPage(SYSTEM_SCREEN_IDLE);
+							setDefaultValue(gun_index, system_mode);
+							DEBUG_INFO("Setting page to idle.\n");
+						}
+						else
+						{
+							setRfidIcon();
+							setQRCodeIcon();
+							setConnectionAnimation(gun_index, system_mode);
+						}
 					}
 				}
 			}
@@ -459,6 +496,12 @@ void page_preparing(uint8_t gun_index, uint8_t system_mode)
 		}
 		else
 		{
+			setPrechargingTimerToDefault();
+			setPrechargingEnergyToDefault();
+			setPrechargingSessionFeeToDefault();
+			setPrechargingParkingFeeToDefault();
+			setPrechargingCostToDefault();
+			setPrechargingPowerToDefault();
 			setConnectionAnimation(gun_index, system_mode);
 			setPresentChargedEnergy(gun_index, system_mode);
 		}
@@ -496,6 +539,8 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 		setConnectionAnimation(gun_index, system_mode);
 		setPresentChargedDuration(gun_index);
 		setPresentChargedgPower(gun_index);
+		setTimeTitle(ON);
+		setEnergyTitle(ON);
 
 		if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 		{
@@ -625,6 +670,8 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 
 	setPresentChargedDuration(gun_index);
 	setPresentChargedEnergy(gun_index, system_mode);
+	setTimeTitle(ON);
+	setEnergyTitle(ON);
 
 	if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 	{
@@ -704,6 +751,8 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
 		setPresentChargedDuration(gun_index);
 		setPresentChargedEnergy(gun_index, system_mode);
 		setPresentChargedgPower(gun_index);
+		setTimeTitle(ON);
+		setEnergyTitle(ON);
 
 		if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 		{
@@ -1982,11 +2031,13 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
 				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_1);
+					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 					CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 				}
 				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_2);
+					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_2);
 					CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
 					refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 				}
@@ -2379,13 +2430,13 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
 //=======================================
 void setTextToEmpty(uint8_t gun_index)
 {
-	uint8_t data[32];
-	uint8_t text_empty[32];
+	uint8_t data[16];
+	uint8_t text_empty[16];
 
 	memset(data, 0x00, ARRAY_SIZE(data));
 	memset(text_empty, 0x00, ARRAY_SIZE(text_empty));
 
-	strcpy((char*)text_empty, "    ");
+	strcpy((char*)text_empty, "                ");
 	string2ByteArray(text_empty, data);
 
 	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, data, ARRAY_SIZE(data));
@@ -2462,7 +2513,7 @@ void setTimeTitle(uint8_t isOn)
 		}
 		else
 		{
-			strcpy((char*)text, "                ");
+			strcpy((char*)text, "                               ");
 			string2ByteArray(text, data);
 		}
 		
@@ -2498,7 +2549,7 @@ void setEnergyTitle(uint8_t isOn)
 		}
 		else
 		{
-			strcpy((char*)text, "                ");
+			strcpy((char*)text, "                               ");
 			string2ByteArray(text, data);
 		}
 		
@@ -2534,7 +2585,7 @@ void setSessionFeeTitle(uint8_t isOn)
 		}
 		else
 		{
-			strcpy((char*)text, "                ");
+			strcpy((char*)text, "                               ");
 			string2ByteArray(text, data);
 		}
 		
@@ -2570,7 +2621,7 @@ void setParkingFeeTitle(uint8_t isOn)
 		}
 		else
 		{
-			strcpy((char*)text, "                ");
+			strcpy((char*)text, "                               ");
 			string2ByteArray(text, data);
 		}
 		
@@ -2606,7 +2657,7 @@ void setFinalCostTitle(uint8_t isOn)
 		}
 		else
 		{
-			strcpy((char*)text, "                ");
+			strcpy((char*)text, "                               ");
 			string2ByteArray(text, data);
 		}
 		
@@ -2638,6 +2689,124 @@ void setCsuRootFsFwRev()
 	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CSU_ROOT_FS_FW_REV, data, ARRAY_SIZE(data));
 }
 
+//=======================================
+// Setting Precharging initial to empty
+//=======================================
+void setClearPrechargingValueToEmpty()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	strcpy((char*)text, "                ");
+	string2ByteArray(text, data);
+
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_TIMER, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_ENERGY, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_COST, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_POWER, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging initial to empty
+//=======================================
+void setPrechargingTimerToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s", "00:00:00");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_TIMER, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging energy to default
+//=======================================
+void setPrechargingEnergyToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s kWh", "0000.0000");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_ENERGY, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging session fee to default
+//=======================================
+void setPrechargingSessionFeeToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s", "000.00");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging parking fee to default
+//=======================================
+void setPrechargingParkingFeeToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s", "000.00");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging cost to default
+//=======================================
+void setPrechargingCostToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s", "000.00");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_COST, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting Precharging power to default
+//=======================================
+void setPrechargingPowerToDefault()
+{
+	uint8_t data[16];
+	uint8_t text[16];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(text, 0x00, ARRAY_SIZE(text));
+
+	sprintf((char *)text, "%s kW", "0.00");
+	string2ByteArray(text, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRECHARGING_POWER, data, ARRAY_SIZE(data));
+}
+
 //=======================================
 // Initial all share memory
 //=======================================
@@ -3112,7 +3281,8 @@ int main(void)
 						page_idle(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
 						break;
 					case SYS_MODE_AUTHORIZING:
-						//page_authorizing(ShmCharger->gun_selectd);
+						if(ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].StartMethod == START_METHOD_EVCCID)
+							page_authorizing(ShmCharger->gun_selectd);
 						break;
 					case SYS_MODE_PREPARING:
 						page_preparing(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);

+ 216 - 6
EVSE/Projects/AW-CCS/Apps/main.c

@@ -5521,6 +5521,64 @@ int main(void)
 			//==========================================
 			checkUnlocker(gun_index);
 
+			//==========================================
+			// Clean EVCCID timeout flag
+			//==========================================
+			if((ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID && (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE)) &&
+			   (ShmCharger->isCcsEnable) &&
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A))
+			{
+				for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
+				{
+					ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = OFF;
+					ShmCharger->gun_info[gun_index].isEvCCIDAuthorizeFail = NO;
+				}
+			}
+
+			//==========================================
+			// Check EVCCID communcation error
+			//==========================================
+			if(ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout == ON)
+			{
+				if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == OFF)
+					ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = ON;
+			}
+			else
+			{
+				if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == ON)
+					ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = OFF;
+			}
+
+			//==========================================
+			// Clean isRemoteStartWait flag
+			//==========================================
+			if(ocpp_get_isRemoteStartWait())
+			{
+				if(ShmCharger->gun_info[gun_index].isRemoteStartWait == OFF)
+				{
+					ShmCharger->gun_info[gun_index].isRemoteStartWait = ON;
+					DEBUG_INFO("Remote start without connector id... \n");
+				}
+				
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_CLEAN_REMOTE_START_WAIT]);
+			}
+			else
+			{
+				if((getDiffSecNow(startTime[gun_index][TMR_IDX_CLEAN_REMOTE_START_WAIT]) > 5))
+				{
+					if(ShmCharger->gun_info[gun_index].isRemoteStartWait == ON)
+					{
+						ShmCharger->gun_info[gun_index].isRemoteStartWait = OFF;
+						DEBUG_INFO("Clean isRemoteStartWait flag... \n");
+					}
+				}
+
+				if((getDiffSecNow(startTime[gun_index][TMR_IDX_CLEAN_REMOTE_START_WAIT]) > 10))
+				{
+					refreshStartTimer(&startTime[gun_index][TMR_IDX_CLEAN_REMOTE_START_WAIT]);
+				}
+			}
+
 			//==========================================
 			// Connector process
 			//==========================================
@@ -5624,7 +5682,8 @@ int main(void)
 							setChargerMode(gun_index, SYS_MODE_DEBUG);
 						else
 							setChargerMode(gun_index, SYS_MODE_IDLE);
-						
+
+						// The system identifies 1 phase or 3 phases depending on the model name 
 						ShmSysConfigAndInfo->SysConfig.AcPhaseCount = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') ||
 																	   (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') ||
 																	   (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')
@@ -5643,6 +5702,7 @@ int main(void)
 						ShmCharger->gun_info[gun_index].rfidReq = OFF;
 						ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
 						ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
+						ShmCharger->gun_info[gun_index].isGetEvCCID = OFF;
 						ocpp_set_remotestart(gun_index, OFF);
 						ocpp_set_remotestop(gun_index, OFF);
 
@@ -5711,13 +5771,110 @@ int main(void)
 						}
 					}
 
+					/*
+					 *	TODO:
+					 *	1. Try to get EVCCID if plug first
+					 */
+					if((ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID && (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE)) &&
+					   (ShmCharger->isCcsEnable) &&
+					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
+					   (ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout == OFF) &&
+					   (ShmCharger->gun_info[gun_index].isRemoteStartWait != ON) &&
+					   (ShmCharger->gun_info[gun_index].isEvCCIDAuthorizeFail != YES))
+					{
+						switch(ShmCharger->gun_info[gun_index].ccsHandshakeState)
+						{
+							case HANDSHAKE_DUTY_5:
+								if(!getRequest(gun_index))
+								{
+									setRequest(gun_index, ON);
+									refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
+									DEBUG_INFO("Try to get EVCCID, Set Request On.\n");
+
+									//Let CCS task start to negotiate
+									ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = ON;
+									ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_NONE;
+								}
+
+								// Set CCS 5% PWM duty
+								if(ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty == CCS_PWM_DUTY_5) //set 5% by SeccComm.c
+								{
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_5;
+									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5_CHECK;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+									DEBUG_INFO("ccsHandshakeState = HANDSHAKE_DUTY_5_CHECK\n");
+								}
+								break;
+							case HANDSHAKE_DUTY_5_CHECK:
+								if((ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF))
+								{
+									//2 secs timeout
+									refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
+									ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CCS;
+									DEBUG_INFO("ccsHandshakeState = HANDSHAKE_CCS\n");
+								}
+								break;
+							case HANDSHAKE_CCS:
+								if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
+								{
+									ShmCharger->gun_info[gun_index].isGetEvCCIDTimeout = ON;
+									ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
+									ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
+									setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
+									setSpeaker(ON,SPEAKER_INTERVAL_3COUNT);
+									DEBUG_INFO("Get EVCCID timeout.\n");
+									sleep(3);
+								}
+
+								if((19 <= ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 253))
+								{
+									if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+									{
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%s%02X%02X%02X%02X%02X%02X", ShmOCPP16Data->ConfigurationTable.CoreProfile[EVCCID_PREFIX].ItemData,
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[0],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[1],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[2],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[3],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[4],
+																															ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[5]);
+									}
+									else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+									{
+										sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%02X%02X%02X%02X%02X%02X", ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[0],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[1],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[2],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[3],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[4],
+																														  ShmCharger->gun_info[gun_index].acCcsInfo.EVCCID[5]);
+									}
+
+									//sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "F5902677");
+									ShmCharger->gun_info[gun_index].isGetEvCCID = ON;
+
+									DEBUG_INFO("Got EVCCID: %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
+								}
+								break;
+							default:
+								break;
+						}
+					}
+					else
+					{
+						if(getRequest(gun_index))
+						{
+							setRequest(gun_index, OFF);
+						}
+						ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
+					}
+
 					if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
 					   ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) ||
 					   ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)) ||
 					   (ShmCharger->gun_info[gun_index].rfidReq == ON) ||
 					   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart == ON) ||
 					   (ocpp_get_remotestart(gun_index) == ON) ||
-					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart == ON))
+					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart == ON) ||
+					   (ShmCharger->gun_info[gun_index].isGetEvCCID == ON))
 					{
 						if((ShmCharger->gun_info[gun_index].rfidReq == ON))
 						{
@@ -5741,6 +5898,13 @@ int main(void)
 							setSpeaker(ON, SPEAKER_SHORT);
 							DEBUG_INFO("Start Method : BLE...\n");
 						}
+						else if(ShmCharger->gun_info[gun_index].isGetEvCCID == ON)
+						{
+							ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_EVCCID;
+							ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartIdType = IdTokenType_MacAddress;
+							setSpeaker(ON, SPEAKER_SHORT);
+							DEBUG_INFO("Start Method : EVCCID...\n");
+						}
 						else
 						{
 							ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_FREE;
@@ -5757,6 +5921,7 @@ int main(void)
 						ShmCharger->gun_info[gun_index].isGunPlugged = NO;
 						ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = OFF;
+						ShmCharger->gun_info[gun_index].isGetEvCCID = OFF;
 
 						// Get target current
 						ocpp_set_profile_req(gun_index, ON);
@@ -5777,6 +5942,11 @@ int main(void)
 							DEBUG_INFO("Remote start request authorize.\n");
 							ocpp_set_auth_req(ON, "ISO14443");
 						}
+						else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_EVCCID))
+						{
+							DEBUG_INFO("EVCCID request authorize.\n");
+							ocpp_set_auth_req(ON, "MacAddress");
+						}
 					}
 
 					if(getDiffSecNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
@@ -5847,6 +6017,43 @@ int main(void)
 									setChargerMode(gun_index, SYS_MODE_PREPARING);
 								}
 								break;
+							case START_METHOD_EVCCID:
+								ShmCharger->gun_info[gun_index].resultAuthorization = UNKNOW_RFID;
+
+								if(ocpp_get_auth_conf() ||
+								   (!ocpp_get_connection_status() && ((ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE) || (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_NOCHARGE))) ||
+								   (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (getDiffSecNow(startTime[0][TMR_IDX_AUTH]) > 2)))
+								{
+									if(ocpp_get_auth_result(gun_index) ||
+									  (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
+									  (!ocpp_get_connection_status() && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
+									{
+										memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+										
+										ShmCharger->gun_info[gun_index].resultAuthorization = VALIDATED_RFID;
+										DEBUG_INFO("Authorize pass [EVCCID].\n");
+										setSpeaker(ON, SPEAKER_SHORT);
+										setLedMotion(gun_index, LED_ACTION_RFID_PASS);
+										sleep(1);
+										setChargerMode(gun_index, SYS_MODE_PREPARING);
+										ShmCharger->gun_info[gun_index].isEvCCIDAuthorizeFail = NO;
+									}
+									else
+									{
+										ShmCharger->gun_info[gun_index].resultAuthorization = UNVALIDATED_RFID;
+										DEBUG_INFO("Authorize fail [EVCCID].\n");
+										setSpeaker(ON, SPEAKER_INTERVAL_3COUNT);
+										setLedMotion(gun_index, LED_ACTION_RFID_FAIL);
+										sleep(3);
+										setChargerMode(gun_index, SYS_MODE_IDLE);
+										ShmCharger->gun_info[gun_index].isEvCCIDAuthorizeFail = YES;
+										ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
+										ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
+									}
+
+									ocpp_set_auth_conf(OFF);
+								}
+								break;
 							case START_METHOD_RFID:
 							case START_METHOD_BLE:
 							case START_METHOD_FREE:
@@ -5871,12 +6078,15 @@ int main(void)
 					{
 						refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 						setLedMotion(gun_index,LED_ACTION_AUTHED);
-						ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;												 
+						ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
 
 						if(ShmCharger->isCcsEnable)
 						{
-							ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
-							DEBUG_INFO("ccsHandshakeState = HANDSHAKE_DUTY_5\n");
+							if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod != START_METHOD_EVCCID)
+							{
+								ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
+								DEBUG_INFO("ccsHandshakeState = HANDSHAKE_DUTY_5\n");
+							}
 						}
 						else
 						{
@@ -6232,7 +6442,7 @@ int main(void)
 					// Unplug charging gun to Idle mode
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (ShmCharger->gun_info[gun_index].isGunPlugged == YES))
 					{
-						DEBUG_INFO("Charging gun is plugged before.\n");
+						DEBUG_INFO("The connector was connected to the EV before.\n");
 						//Cancel CCS task negotiating
 						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
 						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;

+ 7 - 2
EVSE/Projects/AW-CCS/Apps/main.h

@@ -174,7 +174,8 @@ enum START_METHOD
 	START_METHOD_FREE=0,
 	START_METHOD_RFID,
 	START_METHOD_BACKEND,
-	START_METHOD_BLE
+	START_METHOD_BLE,
+	START_METHOD_EVCCID
 };
 
 enum HANDSHAKE_STATE
@@ -236,7 +237,7 @@ enum TIMER_IDX
 	TMR_IDX_CHECK_POWER_CONSUMPTION,
 	TMR_IDX_LCM_POWER_CONSUMPTION,
 	TMR_IDX_RESET_WIFI,
-	TMR_IDX_16,
+	TMR_IDX_CLEAN_REMOTE_START_WAIT,
 	TMR_IDX_17,
 	TMR_IDX_18,
 	TMR_IDX_19,
@@ -762,6 +763,10 @@ typedef struct GUN_INFO
 	uint32_t										isCheckPowerConsumption:1;
 	uint32_t										isHandshakeTimerRefresh:1;
 	uint32_t										isEmergencyStopReport:1;
+	uint32_t										isGetEvCCID:1;
+	uint32_t										isGetEvCCIDTimeout:1;
+	uint32_t										isRemoteStartWait:1;
+	uint32_t										isEvCCIDAuthorizeFail:1;
 }Gun_Info;
 
 struct Charger