Преглед на файлове

2021-12-15 / Jerry Wang
Action:
1. Modify the logic for checking if the value of ChangeConfiguration.req is over 500 bytes.
2. Fix the logic for checking the limit in ChargingProfile.
3. Cancel 'syncDateTimeRTC' function in OcppPH.

File:
1. /EVSE/Modularization/ocppfiles/MessageHandler.c
-->Action 1,2
2. /EVSE/Modularization/ocppph/MessageHandler.c
-->Action 1,2,3

Jerry Wang преди 3 години
родител
ревизия
07b93a598e
променени са 2 файла, в които са добавени 11 реда и са изтрити 7 реда
  1. 5 3
      EVSE/Modularization/ocppfiles/MessageHandler.c
  2. 6 4
      EVSE/Modularization/ocppph/MessageHandler.c

+ 5 - 3
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -9478,6 +9478,7 @@ end:
 int handleChangeConfigurationRequest(char *uuid, char *payload)
 {
 	mtrace();
+	int valueInvalid = NO;
 	int result = FAIL;
 	char keystr[40]={0};
 	char valuestr[501]={0}; //value should be limited in 500 bytes
@@ -9498,15 +9499,16 @@ int handleChangeConfigurationRequest(char *uuid, char *payload)
 		}
 		else
 		{
+			valueInvalid = YES;
 			DEBUG_ERROR("The ChangeConfiguration value is NULL or OVER SIZE.\n");
 		}
 	}
 	json_object_put(ChangeConfiguration);
 
 
-    if((uuid==NULL) || (payload ==NULL) || (strlen(valuestr)<=0))
+    if((uuid==NULL) || (payload ==NULL) || (valueInvalid==YES))
     {
-		DEBUG_ERROR("Payload is null or not accepted.\n");
+		DEBUG_ERROR("Payload is null or value is invalid.\n");
 		sprintf(comfirmstr, "%s", ConfigurationStatusStr[ConfigurationStatus_Rejected] );
     }
     else
@@ -13378,7 +13380,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 	{
 		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
 		{
-			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:modelnameInfo.ParsingInfo[0].Current)))
+			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?1:220*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases)) > modelnameInfo.ratedPower))
 			{
 				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
 				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,

+ 6 - 4
EVSE/Modularization/ocppph/MessageHandler.c

@@ -9015,6 +9015,7 @@ end:
 int handleChangeConfigurationRequest(char *uuid, char *payload)
 {
 	mtrace();
+	int valueInvalid = NO;
 	int result = FAIL;
 	char keystr[40]={0};
 	char valuestr[501]={0}; //value should be limited in 500 bytes
@@ -9035,13 +9036,14 @@ int handleChangeConfigurationRequest(char *uuid, char *payload)
 		}
 		else
 		{
+			valueInvalid = YES;
 			DEBUG_ERROR("The ChangeConfiguration value is NULL or OVER SIZE.\n");
 		}
 	}
 	json_object_put(ChangeConfiguration);
 
 
-    if((uuid==NULL) || (payload ==NULL) || (strlen(valuestr)<=0))
+    if((uuid==NULL) || (payload ==NULL) || (valueInvalid == YES))
     {
 		DEBUG_ERROR("Payload is null or not accepted.\n");
 		sprintf(comfirmstr, "%s", ConfigurationStatusStr[ConfigurationStatus_Rejected] );
@@ -12884,7 +12886,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
 		{
 
-			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:modelnameInfo.ParsingInfo[0].Current)))
+			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?1:220*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases)) > modelnameInfo.ratedPower))
 			{
 				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
 				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
@@ -14372,7 +14374,7 @@ void handleBootNotificationResponse(char *payload, int gun_index)
 	{
 		server_pending = TRUE;
 	}
-	syncDateTimeRTC(ShmOCPP16DataPH->BootNotification.ResponseCurrentTime);
+	//syncDateTimeRTC(ShmOCPP16DataPH->BootNotification.ResponseCurrentTime);
 
 	srand(time(NULL));
 	refreshStartTimer(&clientTime.Heartbeat);
@@ -14444,7 +14446,7 @@ void handleHeartbeatResponse(char *payload, int gun_index)
 	HeartBeatWithNOResponse = 0;
 	refreshStartTimer(&clientTime.Heartbeat);
 
-	syncDateTimeRTC(ShmOCPP16DataPH->Heartbeat.ResponseCurrentTime);
+	//syncDateTimeRTC(ShmOCPP16DataPH->Heartbeat.ResponseCurrentTime);
 }
 
 void handleMeterValuesResponse(char *payload, int gun_index)