Bläddra i källkod

[Improve][AW-Regular][main.c]
2022-08-11 / EASON YANG
Action:
1. Improve: When remote start charging and the system needs copy UserId into StartUserId for compare RIFD card.

File:
1. main.c
Action 1

FIRMWARE VERSION: V0.71.XX.XXXX.PX

8009 2 år sedan
förälder
incheckning
c8a8c5ea1b
1 ändrade filer med 28 tillägg och 13 borttagningar
  1. 28 13
      EVSE/Projects/AW-Regular/Apps/main.c

+ 28 - 13
EVSE/Projects/AW-Regular/Apps/main.c

@@ -652,10 +652,20 @@ void ocpp_copy_userid_from_remotestart(uint8_t gun_index)
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
 		memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag));
+
+		DEBUG_INFO("==========================================\n");
+		DEBUG_INFO("Copy IdTag into UserId. \n");
+		DEBUG_INFO("IdTag : [%s] ---> UserId : [%s] . \n", ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ShmSysConfigAndInfo->SysConfig.UserId);
+		DEBUG_INFO("==========================================\n");
 	}
 	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
 		memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+
+		DEBUG_INFO("==========================================\n");
+		DEBUG_INFO("Copy idToken into UserId. \n");
+		DEBUG_INFO("idToken : [%s] ---> UserId : [%s]. \n", ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, ShmSysConfigAndInfo->SysConfig.UserId);
+		DEBUG_INFO("==========================================\n");
 	}
 }
 
@@ -2306,14 +2316,14 @@ void InitEthernet()
 
 			// Check is need to reset WIFI/4G module power
 			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)) || 
+
+			   ((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) || 
+
+			    ((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)
@@ -2882,12 +2892,10 @@ int isMatchStartUser(unsigned char gun_index)
 		}
 	}
 
-	/*
 	DEBUG_INFO("==== isMatchStartUser ==== \n");
 	DEBUG_INFO("tmpUser : %s \n", tmpUser);
 	DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
 	DEBUG_INFO("========================== \n");
-	*/
 
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
 }
@@ -4536,6 +4544,8 @@ int main(void)
 
 						// Response StopTransactionConf
 						ocpp_set_stoptransaction_conf(gun_index, OFF);
+						memset(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId));
+						memset(ShmSysConfigAndInfo->SysConfig.UserId, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
 
 						previousData[gun_index].primaryMcuCp_Pwn_Duty = 0;
 						previousData[gun_index].targetCurrent = 0;
@@ -4603,7 +4613,7 @@ int main(void)
 								}
 							}
 
-							DEBUG_INFO("Start request User Id : %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
+							DEBUG_INFO("Start request UserId : %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
 						}
 						else if(ocpp_get_remotestart(gun_index))
 						{
@@ -4686,7 +4696,7 @@ int main(void)
 							ocpp_set_auth_req(ON, "ISO14443");
 						}
 					}
-					
+
 					if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
 					{
 						// Authorization timeout process.
@@ -4711,6 +4721,7 @@ int main(void)
 									   (!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));
+										DEBUG_INFO("[START_METHOD_RFID] StartUserId : %s \n",ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
 
 										DEBUG_INFO("Authorize pass.\n");
 										setSpeaker(ON,SPEAKER_SHORT);
@@ -4739,6 +4750,7 @@ int main(void)
 										if(ocpp_get_auth_result(gun_index))
 										{
 											memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+											DEBUG_INFO("[START_METHOD_BACKEND] StartUserId : %s \n",ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
 
 											DEBUG_INFO("Authorize pass.\n");
 											setSpeaker(ON,SPEAKER_SHORT);
@@ -4759,6 +4771,9 @@ int main(void)
 								}
 								else
 								{
+									memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+									DEBUG_INFO("[START_METHOD_BACKEND] StartUserId : %s \n",ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
+
 									setSpeaker(ON,SPEAKER_SHORT);
 									setChargerMode(gun_index, SYS_MODE_PREPARING);
 								}
@@ -4822,7 +4837,7 @@ int main(void)
 						// Set relay on when the system is state C
 						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) && ((ShmCharger->gun_info[gun_index].targetCurrent != 0)))
 							setRelay(gun_index, ON);
-						
+
 						if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON) || (ShmCharger->gun_info[gun_index].targetCurrent == 0))
 						{
 							ocpp_set_unlocker_req(gun_index, OFF);
@@ -5379,7 +5394,7 @@ int main(void)
 						setRelay(gun_index, OFF);
 						sleep(2);
 					}
-					
+
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || ocpp_get_reset_req())
 					{
 						sleep(2);