|
@@ -9512,7 +9512,7 @@ int sendTransactionEventRequest(int gun_index)
|
|
|
json_object *evse = json_object_new_object();
|
|
|
json_object *meterValues = json_object_new_array();
|
|
|
char TempStopTransaction[256];
|
|
|
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
|
|
|
+ sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
|
|
|
|
|
|
DEBUG_INFO("sendTransactionEventRequest...\n");
|
|
|
|
|
@@ -12868,9 +12868,7 @@ void createFirmwareVersionByDataTransfer(void)
|
|
|
json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
|
|
|
}
|
|
|
|
|
|
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
|
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
|
|
|
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
|
|
|
+ sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
|
|
|
|
|
|
json_object_put(FirmwareDataTransfer);
|
|
|
}
|
|
@@ -14225,28 +14223,28 @@ int handlePublishFirmwareRequest(char *uuid, char *payload)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-int handleRemoteStartTransactionRequest(char *uuid, char *payload)
|
|
|
+int handleRequestStartTransactionRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
|
int8_t gun_index = -1;
|
|
|
uint8_t isPeriodOverMax = FALSE;
|
|
|
uint8_t isProfileOverMax = FALSE;
|
|
|
- uint8_t isConnectorMismatch = FALSE;
|
|
|
uint8_t isTxProfile = TRUE;
|
|
|
uint8_t existProfileQuantity = 0;
|
|
|
uint8_t filename[128]={0};
|
|
|
uint8_t word[2048]={0};
|
|
|
+ char cmdBuf[128];
|
|
|
FILE *filePtr;
|
|
|
json_object *RemoteStartTransaction;
|
|
|
|
|
|
- DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
|
|
|
+ DEBUG_INFO("handleRequestStartTransactionRequest...\n");
|
|
|
RemoteStartTransaction = json_tokener_parse(payload);
|
|
|
if(!is_error(RemoteStartTransaction))
|
|
|
{
|
|
|
if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
|
|
|
{
|
|
|
- gun_index = (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))>0)?(json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))-1):-1;
|
|
|
+ gun_index = ((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))?(json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))-1):-1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -14302,217 +14300,62 @@ int handleRemoteStartTransactionRequest(char *uuid, char *payload)
|
|
|
if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
|
|
|
{
|
|
|
|
|
|
- if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
|
|
|
+ if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
|
|
|
{
|
|
|
isPeriodOverMax = TRUE;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
|
|
|
{
|
|
|
- if(gun_index >= 0)
|
|
|
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
|
|
|
- else
|
|
|
- isConnectorMismatch = TRUE;
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
|
|
|
|
|
|
- if(!isConnectorMismatch)
|
|
|
+ filePtr = fopen((char*)filename, "r");
|
|
|
+ if (!filePtr)
|
|
|
{
|
|
|
- filePtr = fopen((char*)filename, "r");
|
|
|
- if (!filePtr)
|
|
|
- {
|
|
|
- DEBUG_INFO("%s not exist, create it.\n", filename);
|
|
|
- filePtr = fopen((char*)filename, "w+");
|
|
|
- }
|
|
|
- else
|
|
|
+ DEBUG_INFO("%s not exist, create it.\n", filename);
|
|
|
+ filePtr = fopen((char*)filename, "w+");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ while(fscanf(filePtr, "%s", word) != EOF)
|
|
|
{
|
|
|
-
|
|
|
- while(fscanf(filePtr, "%s", word) != EOF)
|
|
|
+
|
|
|
+ if(strstr((char*)word, "chargingProfileId")!= NULL)
|
|
|
{
|
|
|
-
|
|
|
- if(strstr((char*)word, "chargingProfileId")!= NULL)
|
|
|
- {
|
|
|
- existProfileQuantity += 1;
|
|
|
- }
|
|
|
+ existProfileQuantity += 1;
|
|
|
}
|
|
|
}
|
|
|
- fclose(filePtr);
|
|
|
}
|
|
|
+ fclose(filePtr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
isTxProfile = FALSE;
|
|
|
}
|
|
|
|
|
|
- if(existProfileQuantity > 3)
|
|
|
+ if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
|
|
|
isProfileOverMax = TRUE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
- if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && isTxProfile)
|
|
|
+ if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && isTxProfile)
|
|
|
{
|
|
|
- FILE *infile;
|
|
|
- FILE *outfile;
|
|
|
- char tmpProfileName[32];
|
|
|
- char rmFileCmd[128];
|
|
|
- char tempchargingProfilePurposeStr[30]={0};
|
|
|
- int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
|
|
|
-
|
|
|
- sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
|
|
|
- infile = fopen ((char*)filename, "r");
|
|
|
- outfile = fopen ((char*)tmpProfileName, "w");
|
|
|
-
|
|
|
- int d = fgetc(infile);
|
|
|
- rewind(infile);
|
|
|
-
|
|
|
- if(d == EOF)
|
|
|
- {
|
|
|
-
|
|
|
- fprintf(outfile,"%s\n", payload);
|
|
|
-
|
|
|
- fclose(infile);
|
|
|
- fclose(outfile);
|
|
|
-
|
|
|
- sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
- system(rmFileCmd);
|
|
|
-
|
|
|
- rename((char*)tmpProfileName, (char*)filename);
|
|
|
- }
|
|
|
- else
|
|
|
+ if(strlen((char*)filename) > 0)
|
|
|
{
|
|
|
-
|
|
|
- char buf[2048]={0};
|
|
|
- int ChargingProfileAdded = FALSE;
|
|
|
-
|
|
|
- while (fgets(buf, sizeof(buf), infile) != NULL)
|
|
|
- {
|
|
|
- buf[strlen(buf) - 1] = '\0';
|
|
|
-
|
|
|
- json_object *tmpChargingProfile;
|
|
|
- tmpChargingProfile = json_tokener_parse(buf);
|
|
|
- if(!is_error(tmpChargingProfile))
|
|
|
- {
|
|
|
- if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
|
|
|
- {
|
|
|
- tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
|
|
|
- {
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
|
|
|
- {
|
|
|
- tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
|
|
|
- {
|
|
|
- tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
|
|
|
- }
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
|
|
|
- {
|
|
|
- strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- json_object_put(tmpChargingProfile);
|
|
|
-
|
|
|
- if((tempconnectorIdInt == (gun_index+1)) &&
|
|
|
- (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
|
|
|
- {
|
|
|
- if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
|
|
|
- (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ChargingProfileAdded == FALSE)
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- fprintf(outfile,"%s\n",payload);
|
|
|
- ChargingProfileAdded = TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf(outfile,"%s\n",buf);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- fclose(infile);
|
|
|
- fclose(outfile);
|
|
|
-
|
|
|
- sprintf(rmFileCmd,"rm -f %s",filename);
|
|
|
- system(rmFileCmd);
|
|
|
+
|
|
|
+ sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
|
|
|
+ system(cmdBuf);
|
|
|
|
|
|
- rename((char*)tmpProfileName, (char*)filename);
|
|
|
+ sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", (gun_index+1));
|
|
|
+ filePtr = fopen((char*)filename, "w");
|
|
|
+ fprintf(filePtr, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", (gun_index+1), json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
|
|
|
+ fclose(filePtr);
|
|
|
}
|
|
|
|
|
|
+ ShmOCPP20Data->CsMsg.bits[gun_index].RequestStartTransactionReq = ON;
|
|
|
sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
|
|
|
random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
|
|
|
result = PASS;
|
|
@@ -14522,9 +14365,6 @@ int handleRemoteStartTransactionRequest(char *uuid, char *payload)
|
|
|
if(gun_index < 0)
|
|
|
DEBUG_WARN("Connector id is wrong.\n");
|
|
|
|
|
|
- if(isConnectorMismatch)
|
|
|
- DEBUG_WARN("Connector id is mismatch.\n");
|
|
|
-
|
|
|
if(isPeriodOverMax)
|
|
|
DEBUG_WARN("Profile periods quantity is over spec.\n");
|
|
|
|
|
@@ -14544,7 +14384,7 @@ int handleRemoteStartTransactionRequest(char *uuid, char *payload)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-int handleRemoteStopTransactionRequest(char *uuid, char *payload)
|
|
|
+int handleRequestStopTransactionRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
@@ -14555,7 +14395,7 @@ int handleRemoteStopTransactionRequest(char *uuid, char *payload)
|
|
|
int transactionIdIsNULL= TRUE;
|
|
|
json_object *RemoteStopTransaction;
|
|
|
|
|
|
- DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
|
|
|
+ DEBUG_INFO("handleRequestStopTransactionRequest...\n");
|
|
|
|
|
|
if(server_pending == TRUE)
|
|
|
{
|
|
@@ -15411,7 +15251,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
|
|
|
{
|
|
|
|
|
|
- if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
|
|
|
+ if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
|
|
|
{
|
|
|
isPeriodOverMax = TRUE;
|
|
|
}
|
|
@@ -15514,7 +15354,7 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
|
|
|
}
|
|
|
|
|
|
- if(existProfileQuantity > 3)
|
|
|
+ if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
|
|
|
isProfileOverMax = TRUE;
|
|
|
}
|
|
|
|
|
@@ -16278,6 +16118,11 @@ int handleSetVariablesRequest(char *uuid, char *payload)
|
|
|
StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
|
|
|
SetOcppConnStatus(FALSE);
|
|
|
}
|
|
|
+
|
|
|
+ if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
|
|
|
+ {
|
|
|
+ HeartBeatWaitTime = (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)<10) ? 10 : atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -16371,6 +16216,7 @@ int handleTriggerMessageRequest(char *uuid, char *payload)
|
|
|
((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
|
|
|
{
|
|
|
FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
|
|
|
+ sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
}
|
|
|
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
@@ -16539,7 +16385,6 @@ int handleUnlockConnectorRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
|
|
|
ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -16612,11 +16457,9 @@ int handleUnlockConnectorRequest(char *uuid, char *payload)
|
|
|
if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
|
|
|
{
|
|
|
ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
|
|
|
strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
|
|
|
result = TRUE;
|
|
@@ -16624,8 +16467,7 @@ int handleUnlockConnectorRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
|
|
|
end:
|
|
|
-
|
|
|
- sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
|
|
|
+ ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorConf = ON;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -16664,37 +16506,52 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
{
|
|
|
pthread_detach(pthread_self());
|
|
|
mtrace();
|
|
|
- int retriesInt =0, retryIntervalInt=0;
|
|
|
char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
|
|
|
int port=0;
|
|
|
- char locationstr[1024]={0}, retrieveDatestr[36]={0};
|
|
|
int isSuccess = 0;
|
|
|
char ftpbuf[1024];
|
|
|
char temp[1024];
|
|
|
char * pch;
|
|
|
|
|
|
|
|
|
- DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
|
|
|
+ DEBUG_INFO("handleUpdateFirmwareRequest...\n");
|
|
|
json_object *UpdateFirmware;
|
|
|
UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
|
|
|
if(!is_error(UpdateFirmware))
|
|
|
{
|
|
|
|
|
|
- if(json_object_object_get(UpdateFirmware, "location") != NULL)
|
|
|
- sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
|
|
|
+ if(json_object_object_get(UpdateFirmware, "requestId"))
|
|
|
+ {
|
|
|
+ ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(UpdateFirmware, "firmware"))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
|
|
|
+
|
|
|
+ if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
|
|
|
+
|
|
|
+ if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
|
|
|
|
|
|
- if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
|
|
|
- sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
|
|
|
+ if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
|
|
|
+
|
|
|
+ if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if(json_object_object_get(UpdateFirmware, "retries"))
|
|
|
{
|
|
|
- retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
|
|
|
+ ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
|
|
|
}
|
|
|
|
|
|
if(json_object_object_get(UpdateFirmware, "retryInterval"))
|
|
|
{
|
|
|
- retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
|
|
|
+ ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
|
|
|
}
|
|
|
}
|
|
|
json_object_put(UpdateFirmware);
|
|
@@ -16703,23 +16560,24 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
memset(path, 0, ARRAY_SIZE(path));
|
|
|
|
|
|
|
|
|
- if(strlen(retrieveDatestr) > 10)
|
|
|
+ if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
do
|
|
|
{
|
|
|
sleep(1);
|
|
|
- }while(!isOvertNow((uint8_t*)retrieveDatestr));
|
|
|
+ }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
|
|
|
}
|
|
|
|
|
|
system("rm -f /mnt/*");
|
|
|
- if(strncmp(locationstr,"http", 4) == 0)
|
|
|
+ if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
|
|
|
{
|
|
|
- sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
|
|
|
+ sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
|
|
|
|
|
|
sprintf(ftppath,"/%s", path);
|
|
|
- DEBUG_INFO("locationstr: %s\n", locationstr);
|
|
|
+ DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
|
|
|
DEBUG_INFO("protocol: %s\n",protocol);
|
|
|
DEBUG_INFO("host: %s\n",host);
|
|
|
DEBUG_INFO("path: %s\n",path);
|
|
@@ -16745,33 +16603,37 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
sleep(3);
|
|
|
|
|
|
- isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
|
|
|
+ isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
|
|
|
if(!isSuccess)
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
- if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
- retriesInt--;
|
|
|
- }while((isSuccess == 0)&&(retriesInt >= 0));
|
|
|
+ ShmOCPP20Data->UpdateFirmware.retries--;
|
|
|
+ }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
|
|
|
}
|
|
|
- else if(strncmp(locationstr,"ftp", 3) == 0)
|
|
|
+ else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
|
|
|
{
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
memset(temp, 0, ARRAY_SIZE(temp));
|
|
|
|
|
|
- strcpy(ftpbuf, locationstr);
|
|
|
+ strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
|
|
|
int ftppathlen=strlen(ftpbuf);
|
|
|
int i=1;
|
|
|
char filenametemp[50];
|
|
@@ -16816,35 +16678,41 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
sleep(3);
|
|
|
|
|
|
- isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
|
|
|
+ isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
|
|
|
if(!isSuccess)
|
|
|
{
|
|
|
|
|
|
DEBUG_INFO("Update firmware request and download file fail.\n");
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
- if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
|
|
|
}
|
|
|
- retriesInt--;
|
|
|
- }while((!isSuccess)&&(retriesInt >= 0));
|
|
|
+ ShmOCPP20Data->UpdateFirmware.retries--;
|
|
|
+ }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
sleep(1);
|
|
|
+ ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
@@ -17739,7 +17607,7 @@ void storeTempStopTransaction(int gun_index)
|
|
|
json_object *idToken = json_object_new_object();
|
|
|
json_object *evse = json_object_new_object();
|
|
|
json_object *meterValues = json_object_new_array();
|
|
|
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
|
|
|
+ sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
|
|
|
|
|
|
DEBUG_INFO("storeTempStopTransaction...\n");
|
|
|
|
|
@@ -18174,12 +18042,12 @@ void checkTempStopTransaction(int gun_index)
|
|
|
char guid[37]={0};
|
|
|
char tempdata[65]={0};
|
|
|
char TempStopTransaction[256];
|
|
|
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
|
|
|
+ sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
|
|
|
|
|
|
fptr1 = fopen(TempStopTransaction, "r");
|
|
|
if (!fptr1)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
return ;
|
|
|
}
|
|
|
|