Browse Source

2021-05-20 / Eason Yang
Action :
1. Added : Cancel charging process.
2. Added : ocpp_get_reset() into SYS_MODE_COMPLETE for end of session.

File :
1. main.c
Action 1
Action 2

Version : D0.53.XX.XXXX.XX

8009 3 years ago
parent
commit
8187e95ca8
1 changed files with 59 additions and 1 deletions
  1. 59 1
      EVSE/Projects/AW-CCS/Apps/main.c

+ 59 - 1
EVSE/Projects/AW-CCS/Apps/main.c

@@ -2608,6 +2608,54 @@ int isMatchStartUser(unsigned char gun_index)
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
 }
 
+int isMatchPresentUser()
+{
+	uint8_t tmpUser[32];
+
+	if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
+	{
+		// Big endian
+		switch(rfid.snType)
+		{
+			case RFID_SN_TYPE_6BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]);
+				break;
+			case RFID_SN_TYPE_7BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]);
+				break;
+			case RFID_SN_TYPE_10BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7], rfid.currentCard[8], rfid.currentCard[9]);
+				break;
+			case RFID_SN_TYPE_4BYTE:
+			default:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3]);
+				break;
+		}
+	}
+	else
+	{
+		// Little endian
+		switch(rfid.snType)
+		{
+			case RFID_SN_TYPE_6BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+				break;
+			case RFID_SN_TYPE_7BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+				break;
+			case RFID_SN_TYPE_10BYTE:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[9], rfid.currentCard[8], rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+				break;
+			case RFID_SN_TYPE_4BYTE:
+			default:
+				sprintf((char*)tmpUser, "%02X%02X%02X%02X", rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]);
+				break;
+		}
+	}
+
+	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysConfig.UserId)==0)?YES:NO);
+}
+
 //===============================================
 //	Read RFID Serial Number
 //===============================================
@@ -3901,6 +3949,15 @@ void checkRfidAuthrize()
 
 					if(DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT]) < (ocpp_get_connection_timeout()*1000))
 					{
+						if(GetCardSerialNumber() != FAIL)
+						{
+							if(isMatchPresentUser())
+							{
+								DEBUG_INFO("Cancel present user.\n");
+								ShmCharger->isAuthrizing = FALSE;
+							}
+						}
+
 						for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
 						{
 							if(DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT]) < 3000)
@@ -5166,7 +5223,8 @@ int main(void)
 					}
 					
 					if(((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)) ||
-					   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && (!ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn)))
+					   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && (!ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn)) ||
+					   ocpp_get_reset_req())
 					{
 						ShmCharger->gun_info[gun_index].rfidReq = OFF;
 						ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;