Przeglądaj źródła

[Improve][AW-Regular][main.c]
2022-10-26 / EASON YANG
Action:
1. Improve: ocpp_get_auth_result() function. If reservation IdTag is same as authorize IdTage and don't compare with parentIdTag again.

File:
1. main.c
Action 1

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

8009 2 lat temu
rodzic
commit
816d708183
1 zmienionych plików z 57 dodań i 44 usunięć
  1. 57 44
      EVSE/Projects/AW-Regular/Apps/main.c

+ 57 - 44
EVSE/Projects/AW-Regular/Apps/main.c

@@ -767,6 +767,48 @@ uint8_t ocpp_get_auth_conf()
 	return result;
 }
 
+uint8_t ocpp_compare_reserve_id_with_user(uint8_t gun_index)
+{
+	uint8_t result = OFF;
+
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
+			result = ON;
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+	{
+		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
+			result = ON;
+	}
+
+	return result;
+}
+
+uint8_t ocpp_compare_reserve_id_with_remote_user(uint8_t gun_index)
+{
+	uint8_t result = OFF;
+
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if(strcmp((char*)ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
+		{
+			result = ON;
+			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag));
+		}
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+	{
+		if(strcmp((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
+		{
+			result = ON;
+			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+		}
+	}
+
+	return result;
+}
+
 uint8_t ocpp_get_auth_result(uint8_t gun_index)
 {
 	uint8_t result = OFF;
@@ -776,9 +818,22 @@ uint8_t ocpp_get_auth_result(uint8_t gun_index)
 		case SYS_MODE_AUTHORIZING:
 			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId == -1) && (strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0)) ||
-					((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId != -1) && ((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) && (strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].ParentIdTag)==0))))
+				if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId == -1) && (strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0)))
+				{
 					result = PASS;
+				}
+				else if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId != -1) && (strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0)))
+				{
+					if(ocpp_compare_reserve_id_with_user(gun_index) || ocpp_compare_reserve_id_with_remote_user(gun_index))
+					{
+						result = PASS;
+					}
+					else
+					{
+						if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].ParentIdTag)==0))
+							result = PASS;
+					}
+				}
 
 				DEBUG_INFO("============ [SYS_MODE_AUTHORIZING] ==============\n");
 				DEBUG_INFO("Authorize response status: [ %s ].\n", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
@@ -1169,48 +1224,6 @@ void ocpp_set_cancelreservation_req(uint8_t gun_index, uint8_t status)
 	}
 }
 
-uint8_t ocpp_compare_reserve_id_with_user(uint8_t gun_index)
-{
-	uint8_t result = OFF;
-
-	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
-	{
-		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
-			result = ON;
-	}
-	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
-	{
-		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
-			result = ON;
-	}
-
-	return result;
-}
-
-uint8_t ocpp_compare_reserve_id_with_remote_user(uint8_t gun_index)
-{
-	uint8_t result = OFF;
-
-	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
-	{
-		if(strcmp((char*)ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
-		{
-			result = ON;
-			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag));
-		}
-	}
-	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
-	{
-		if(strcmp((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
-		{
-			result = ON;
-			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
-		}
-	}
-
-	return result;
-}
-
 uint8_t ocpp_isAuthorizeRemoteStart()
 {
 	uint8_t result = NO;