|
@@ -1316,6 +1316,8 @@ int isOvertNow(uint8_t *start)
|
|
|
struct tm tmStart;
|
|
|
struct timeb tbStart;
|
|
|
|
|
|
+ memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
|
|
|
+
|
|
|
if(strstr((char*)start, ".") != NULL)
|
|
|
{
|
|
|
// Original data with mini second
|
|
@@ -8598,73 +8600,61 @@ int sendGetConfigurationConfirmation(char *uuid)
|
|
|
|
|
|
MaxKeySupported = atoi((const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData);
|
|
|
|
|
|
- //DEBUG_INFO("MaxKeySupported=%d\n",MaxKeySupported);
|
|
|
-
|
|
|
- sprintf(message,"[%d,\"%s\",{\"configurationKey\":["
|
|
|
- ,MESSAGE_TYPE_CALLRESULT
|
|
|
- ,uuid );
|
|
|
-
|
|
|
- //configuration key
|
|
|
+ //configuration key
|
|
|
+ json_object *GetConfiguration = json_object_new_object();
|
|
|
+ json_object *configurationKey = json_object_new_array();
|
|
|
for(int idx_sample=0;idx_sample< MaxKeySupported/*43*/;idx_sample++)
|
|
|
{
|
|
|
if(strcmp((const char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Key, "")!= 0)
|
|
|
{
|
|
|
- if (sentConfigurationNumber == 0)
|
|
|
- {
|
|
|
- sprintf(message + strlen(message), "{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}"
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Key
|
|
|
- , atoi((const char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].ReadOnly) == 1 ? "true":"false"
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Value );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sprintf(message + strlen(message), ", {\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}"
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Key
|
|
|
- , atoi((const char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].ReadOnly) == 1 ? "true":"false"
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Value );
|
|
|
- }
|
|
|
+ json_object *keyValue = json_object_new_object();
|
|
|
+ json_object_object_add(keyValue, "key", json_object_new_string((char*)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Key));
|
|
|
+ json_object_object_add(keyValue, "readonly", atoi((const char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].ReadOnly) == 1?json_object_new_boolean(1):json_object_new_boolean(0));
|
|
|
+ json_object_object_add(keyValue, "value", json_object_new_string((char*)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[idx_sample].Value));
|
|
|
+
|
|
|
+ json_object_array_add(configurationKey, keyValue);
|
|
|
|
|
|
sentConfigurationNumber = sentConfigurationNumber + 1;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- sprintf(message + strlen(message), "]");
|
|
|
-
|
|
|
-
|
|
|
+ json_object *unknownKey = json_object_new_array();
|
|
|
if(UnknownKeynum != 0)
|
|
|
{
|
|
|
- sprintf(message + strlen(message), ",\"unknownKey\":[");
|
|
|
- //unkown key
|
|
|
for(int idx_sample=0;idx_sample< UnknownKeynum ;idx_sample++)
|
|
|
{
|
|
|
- // json_object *jstring1 = json_object_new_string((const char *)((ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey + idx_sample)->Item));
|
|
|
-
|
|
|
- DEBUG_INFO("unkown key:%s\n", ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey[idx_sample].Item);
|
|
|
+ DEBUG_INFO("unknown key:%s\n", ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey[idx_sample].Item);
|
|
|
+ json_object_array_add(unknownKey, json_object_new_string((char*)ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey[idx_sample].Item));
|
|
|
|
|
|
- if(sentunConfigurationNumber == 0)
|
|
|
- {
|
|
|
- sprintf(message + strlen(message), "\"%s\""
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey[idx_sample].Item );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sprintf(message + strlen(message), ",\"%s\""
|
|
|
- , ShmOCPP16DataPH->GetConfiguration.ResponseUnknownKey[idx_sample].Item );
|
|
|
- }
|
|
|
sentunConfigurationNumber = sentunConfigurationNumber + 1;
|
|
|
-
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- sprintf(message + strlen(message), "]");
|
|
|
+ if((sentConfigurationNumber>0) && (sentunConfigurationNumber>0))
|
|
|
+ {
|
|
|
+ json_object_object_add(GetConfiguration, "configurationKey", configurationKey);
|
|
|
+ json_object_object_add(GetConfiguration, "unknownKey", unknownKey);
|
|
|
|
|
|
}
|
|
|
+ else if(sentConfigurationNumber>0)
|
|
|
+ {
|
|
|
+ json_object_object_add(GetConfiguration, "configurationKey", configurationKey);
|
|
|
+ json_object_put(unknownKey);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(GetConfiguration, "unknownKey", unknownKey);
|
|
|
+ json_object_put(configurationKey);
|
|
|
+ }
|
|
|
|
|
|
- sprintf(message + strlen(message), "}]");
|
|
|
+ sprintf(message,"[%d,\"%s\",%s]"
|
|
|
+ ,MESSAGE_TYPE_CALLRESULT
|
|
|
+ ,uuid
|
|
|
+ ,json_object_to_json_string_ext(GetConfiguration, JSON_C_TO_STRING_PLAIN));
|
|
|
|
|
|
- LWS_Send(message);
|
|
|
+ json_object_put(GetConfiguration);
|
|
|
|
|
|
+ LWS_Send(message);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -11560,6 +11550,7 @@ void* GetDiagnosticsProcess(void* data)
|
|
|
sprintf(cmdBuf, "%s /Storage/OCPP/TransactionRelatedQueue", cmdBuf);
|
|
|
sprintf(cmdBuf, "%s /Storage/OCPP/QueueTransactionId", cmdBuf);
|
|
|
sprintf(cmdBuf, "%s /Storage/OCPP/OCPPConfiguration", cmdBuf);
|
|
|
+ sprintf(cmdBuf, "%s /Storage/SystemLog/*Dispenser*Log.zip", cmdBuf);
|
|
|
system(cmdBuf);
|
|
|
|
|
|
// Pack charging & event log
|
|
@@ -11742,6 +11733,7 @@ void* GetDiagnosticsProcess(void* data)
|
|
|
|
|
|
end:
|
|
|
system("rm -f /mnt/*");
|
|
|
+ system("rm -f /Storage/SystemLog/*Dispenser*Log.zip");
|
|
|
sleep(5);
|
|
|
sprintf((char*)ShmOCPP16DataPH->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_Idle]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
|
|
@@ -14375,21 +14367,19 @@ end:
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-static char UpdateFirmwarepayloadData[300]={0};
|
|
|
int handleUpdateFirmwareRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
|
pthread_t t;
|
|
|
|
|
|
+ DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
|
|
|
sendUpdateFirmwareConfirmation(uuid);
|
|
|
- memset(UpdateFirmwarepayloadData, 0, 300);
|
|
|
- strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
|
|
|
|
|
|
if(!interLock.isUpdateFirmwareGoing)
|
|
|
{
|
|
|
interLock.isUpdateFirmwareGoing = 1;
|
|
|
- pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
|
|
|
+ pthread_create(&t, NULL, UpdateFirmwareProcess, payload);
|
|
|
sleep(1);
|
|
|
}
|
|
|
else
|
|
@@ -14404,18 +14394,17 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
pthread_detach(pthread_self());
|
|
|
mtrace();
|
|
|
int retriesInt =0, retryIntervalInt=0;
|
|
|
- char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
|
|
|
+ char protocol[10], user[64],password[64],host[256], path[1024], ftppath[1024],host1[256],path1[1024];
|
|
|
int port=0;
|
|
|
- char locationstr[512]={0}, retrieveDatestr[36]={0};
|
|
|
+ char locationstr[2048]={0}, retrieveDatestr[36]={0};
|
|
|
int isSuccess = 0;
|
|
|
- char ftpbuf[512];
|
|
|
- char temp[100];
|
|
|
+ char ftpbuf[2048];
|
|
|
+ char temp[2048];
|
|
|
+ char filenametemp[256];
|
|
|
char * pch;
|
|
|
|
|
|
- DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
|
|
|
-
|
|
|
json_object *UpdateFirmware;
|
|
|
- UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
|
|
|
+ UpdateFirmware = json_tokener_parse(data);
|
|
|
if(!is_error(UpdateFirmware))
|
|
|
{
|
|
|
// Required data
|
|
@@ -14465,7 +14454,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
int ftppathlen=strlen(ftppath);
|
|
|
int i=1;
|
|
|
- char filenametemp[50];
|
|
|
+
|
|
|
while(i < ftppathlen)
|
|
|
{
|
|
|
int len=ftppathlen-i;
|
|
@@ -14483,6 +14472,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
+ sleep(1);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
sleep(1);
|
|
@@ -14490,15 +14480,17 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
|
|
|
if(!isSuccess)
|
|
|
{
|
|
|
+ sleep(1);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
- if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(3);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Idle]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
+ sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
retriesInt--;
|
|
@@ -14512,7 +14504,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
strcpy(ftpbuf, locationstr);
|
|
|
int ftppathlen=strlen(ftpbuf);
|
|
|
int i=1;
|
|
|
- char filenametemp[50];
|
|
|
+
|
|
|
while(i < ftppathlen)
|
|
|
{
|
|
|
int len=ftppathlen-i;
|
|
@@ -14554,6 +14546,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
+ sleep(1);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
sleep(1);
|
|
@@ -14565,19 +14558,20 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
DEBUG_INFO("Update firmware request and download file fail.\n");
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
- if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(3);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Idle]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
+ sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
retriesInt--;
|
|
|
}while((!isSuccess)&&(retriesInt >= 0));
|
|
|
}
|
|
|
- else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
|
|
|
+ else if((strncmp(locationstr,"ftp", 3) == 0) || (strncmp(locationstr,"ftps", 4) == 0)) // ftp/ftps
|
|
|
{
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
memset(temp, 0, ARRAY_SIZE(temp));
|
|
@@ -14585,7 +14579,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
|
|
|
int ftppathlen=strlen(ftpbuf);
|
|
|
int i=1;
|
|
|
- char filenametemp[50];
|
|
|
+
|
|
|
while(i < ftppathlen)
|
|
|
{
|
|
|
int len=ftppathlen-i;
|
|
@@ -14637,6 +14631,7 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
+ sleep(1);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloading]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
sleep(1);
|
|
@@ -14648,13 +14643,14 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
DEBUG_INFO("Update firmware request and download file fail.\n");
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
- if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(3);
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Idle]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
+ sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s",FirmwareStatusStr[FirmwareStatus_Downloaded]);
|
|
|
ShmOCPP16DataPH->SpMsg.bits.FirmwareStatusNotificationReq = 1;
|
|
|
}
|
|
|
retriesInt--;
|
|
@@ -14670,7 +14666,11 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
}
|
|
|
|
|
|
// OCPPPH only, must announce CSU upgrade firmware
|
|
|
- if(strstr((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, FirmwareStatusStr[FirmwareStatus_Downloaded]) != NULL)ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
|
|
|
+ if(strstr((char*)ShmOCPP16DataPH->FirmwareStatusNotification.Status, FirmwareStatusStr[FirmwareStatus_Downloaded]) != NULL)
|
|
|
+ {
|
|
|
+ sleep(3);
|
|
|
+ ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
|
|
|
+ }
|
|
|
|
|
|
interLock.isUpdateFirmwareGoing = 0;
|
|
|
pthread_exit(NULL);
|
|
@@ -15395,10 +15395,7 @@ int initialConfigurationTable(void)
|
|
|
FILE *fp;
|
|
|
FILE *outfile;
|
|
|
char str[512]={0};
|
|
|
- char sstr[256]={0};
|
|
|
- int c = 0;
|
|
|
- char *loc;
|
|
|
- int confVersion = 18;
|
|
|
+ int confVersion = 19;
|
|
|
|
|
|
DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
|
|
|
//start_t = clock();
|
|
@@ -15842,6 +15839,13 @@ int initialConfigurationTable(void)
|
|
|
|
|
|
fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
|
|
|
|
|
|
+ // Check certificate of download link
|
|
|
+ ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemAccessibility = 1;
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemName, "AuthDownloadlinkCertificate");
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "%s", "FALSE");
|
|
|
+
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AuthDownloadlinkCertificate", "false", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData);
|
|
|
+
|
|
|
//* Local Auth List Management Profile*/
|
|
|
#if 0
|
|
|
//For OCTT Test Case
|
|
@@ -15934,54 +15938,19 @@ int initialConfigurationTable(void)
|
|
|
while( fgets (str, ARRAY_SIZE(str), fp)!=NULL )
|
|
|
{
|
|
|
//DEBUG_INFO("Get Configuration \n");
|
|
|
-
|
|
|
if(strlen(str) > 0)
|
|
|
{
|
|
|
- str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
|
|
|
- //*************************key*********************************/
|
|
|
- if(strstr(str, "key") != NULL)
|
|
|
- {
|
|
|
- loc = strstr(str, "key");
|
|
|
- c = 0;
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- while ((loc[strlen("key")+3+c] != '\"') && (c < (ARRAY_SIZE(sstr)-1)))
|
|
|
- {
|
|
|
- sstr[c] = loc[strlen("key")+3+c];
|
|
|
- c++;
|
|
|
- }
|
|
|
- sstr[c] = '\0';
|
|
|
- strcpy(keystr,sstr);
|
|
|
- }
|
|
|
+ json_object *OCPPConfiguration;
|
|
|
+ OCPPConfiguration = json_tokener_parse(str);
|
|
|
|
|
|
- //*************************readonly*********************************/
|
|
|
- if(strstr(str, "readonly") != NULL)
|
|
|
- {
|
|
|
- loc = strstr(str, "readonly");
|
|
|
- c = 0;
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- while ((loc[strlen("readonly")+2+c] != ',') && (c < (ARRAY_SIZE(sstr)-1)))
|
|
|
- {
|
|
|
- sstr[c] = loc[strlen("readonly")+2+c];
|
|
|
- c++;
|
|
|
- }
|
|
|
- sstr[c] = '\0';
|
|
|
- strcpy(readonlystr,sstr);
|
|
|
- }
|
|
|
+ if(json_object_object_get(OCPPConfiguration, "key") != NULL)
|
|
|
+ strcpy(keystr, json_object_get_string(json_object_object_get(OCPPConfiguration,"key")));
|
|
|
+ if(json_object_object_get(OCPPConfiguration, "readonly") != NULL)
|
|
|
+ strcpy(readonlystr, json_object_get_string(json_object_object_get(OCPPConfiguration,"readonly")));
|
|
|
+ if(json_object_object_get(OCPPConfiguration, "value") != NULL)
|
|
|
+ strcpy(valuestr, json_object_get_string(json_object_object_get(OCPPConfiguration,"value")));
|
|
|
|
|
|
- //*************************value*********************************/
|
|
|
- if(strstr(str, "value") != NULL)
|
|
|
- {
|
|
|
- loc = strstr(str, "value");
|
|
|
- c = 0;
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- while ((loc[strlen("value")+3+c] != '\"') && (c < (ARRAY_SIZE(sstr)-1)))
|
|
|
- {
|
|
|
- sstr[c] = loc[strlen("value")+3+c];
|
|
|
- c++;
|
|
|
- }
|
|
|
- sstr[c] = '\0';
|
|
|
- strcpy(valuestr,sstr);
|
|
|
- }
|
|
|
+ json_object_put(OCPPConfiguration);
|
|
|
|
|
|
// DEBUG_INFO("keystr=%s\n",keystr);
|
|
|
// DEBUG_INFO("readonlystr=%s\n",readonlystr);
|
|
@@ -16324,6 +16293,12 @@ int initialConfigurationTable(void)
|
|
|
sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", valuestr);
|
|
|
}
|
|
|
|
|
|
+ if(strcmp(keystr, "AuthDownloadlinkCertificate") == 0)
|
|
|
+ {
|
|
|
+ ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "%s", valuestr);
|
|
|
+ }
|
|
|
+
|
|
|
if(strcmp(keystr, "LocalAuthListEnabled") == 0)
|
|
|
{
|
|
|
ShmOCPP16DataPH->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
|
|
@@ -16757,7 +16732,25 @@ void StoreConfigurationTable(void)
|
|
|
strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemData, "" );
|
|
|
*/
|
|
|
|
|
|
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","DefaultPrice", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
|
|
|
+ json_object *tmp;
|
|
|
+ tmp = json_tokener_parse((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
|
|
|
+ if(!is_error(tmp))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("JSON string type\n");
|
|
|
+ json_object *target = json_object_new_object();
|
|
|
+ json_object_object_add(target, "key", json_object_new_string("DefaultPrice"));
|
|
|
+ json_object_object_add(target, "readonly", (ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemAccessibility?json_object_new_boolean(0):json_object_new_boolean(1)));
|
|
|
+ json_object_object_add(target, "value", json_object_new_string((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemData));
|
|
|
+
|
|
|
+ fprintf(outfile, "%s\n", json_object_to_json_string_ext(target, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(target);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Normal string type\n");
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","DefaultPrice", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
|
|
|
+ }
|
|
|
+ json_object_put(tmp);
|
|
|
|
|
|
// CustomDisplayCostAndPrice
|
|
|
/*
|
|
@@ -16903,6 +16896,15 @@ void StoreConfigurationTable(void)
|
|
|
|
|
|
fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
|
|
|
|
|
|
+ // AuthDownloadlinkCertificate
|
|
|
+ /*
|
|
|
+ ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemAccessibility = 1;
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemName, "AuthDownloadlinkCertificate");
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "" );
|
|
|
+ */
|
|
|
+
|
|
|
+ fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AuthDownloadlinkCertificate", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData);
|
|
|
+
|
|
|
//* Local Auth List Management Profile*/
|
|
|
//LocalAuthListEnabled
|
|
|
/*
|
|
@@ -17990,6 +17992,24 @@ void getKeyValue(char *keyReq)
|
|
|
strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData );
|
|
|
isKnowKey = TRUE;
|
|
|
}
|
|
|
+
|
|
|
+ if(isEmpty || strcmp(keyReq, "AuthDownloadlinkCertificate") == 0 )
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->GetConfiguration.Key[GetConfiguration_AuthDownloadlinkCertificate].Item, "AuthDownloadlinkCertificate");
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthDownloadlinkCertificate].Key, "AuthDownloadlinkCertificate");
|
|
|
+
|
|
|
+ if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemAccessibility == 1)
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthDownloadlinkCertificate].ReadOnly, "0"/*"FALSE"*/);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthDownloadlinkCertificate].ReadOnly, "1"/*"TRUE"*/);
|
|
|
+ }
|
|
|
+
|
|
|
+ strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthDownloadlinkCertificate].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData );
|
|
|
+ isKnowKey = TRUE;
|
|
|
+ }
|
|
|
#if 1
|
|
|
if(isEmpty || strcmp(keyReq, "LocalAuthListEnabled") == 0 )
|
|
|
{
|
|
@@ -19322,6 +19342,34 @@ int setKeyValue(char *key, char *value)
|
|
|
isSuccess = ConfigurationStatus_Rejected;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(strcmp(key, "OcppSoftwareVersion") == 0)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility == 1)
|
|
|
+ {
|
|
|
+ strcpy(str, (const char*)value);
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", str );
|
|
|
+ isSuccess = ConfigurationStatus_Accepted;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ isSuccess = ConfigurationStatus_Rejected;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(strcmp(key, "AuthDownloadlinkCertificate") == 0)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemAccessibility == 1)
|
|
|
+ {
|
|
|
+ strcpy(str, (const char*)value);
|
|
|
+ sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "%s", str );
|
|
|
+ isSuccess = ConfigurationStatus_Accepted;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ isSuccess = ConfigurationStatus_Rejected;
|
|
|
+ }
|
|
|
+ }
|
|
|
#if 0
|
|
|
//For OCPP Test Case
|
|
|
if(strcmp(key, "LocalAuthorizationListEnabled") == 0)
|
|
@@ -19615,9 +19663,9 @@ int ParseHeader(int sock)
|
|
|
int httpDownLoadFile(char *location, char *path, char *filename,char *url)
|
|
|
{
|
|
|
int result = TRUE;
|
|
|
- char rmFileCmd[100]={0};
|
|
|
- char FilePath[100]={0};
|
|
|
- char ftpbuf[200];
|
|
|
+ char rmFileCmd[300]={0};
|
|
|
+ char FilePath[256]={0};
|
|
|
+ char ftpbuf[2048];
|
|
|
int systemresult;
|
|
|
|
|
|
sprintf(FilePath,"/mnt/%s",filename);
|
|
@@ -19630,7 +19678,10 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
|
|
|
system(rmFileCmd);
|
|
|
}
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
|
|
|
+ if(strstr((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "TRUE") != NULL)
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --ca-certificate=/root/cacert.pem",filename, url);
|
|
|
+ else
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
|
|
|
DEBUG_INFO("Download command: %s\n",ftpbuf);
|
|
|
|
|
|
systemresult = system(ftpbuf);
|
|
@@ -19647,9 +19698,9 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
|
|
|
int sftpDownLoadFile(char *location, char *user, int port, char *path, char *filename,char *url)
|
|
|
{
|
|
|
int result = TRUE;
|
|
|
- char rmFileCmd[100]={0};
|
|
|
- char FilePath[100]={0};
|
|
|
- char ftpbuf[200];
|
|
|
+ char rmFileCmd[300]={0};
|
|
|
+ char FilePath[256]={0};
|
|
|
+ char ftpbuf[2048];
|
|
|
int systemresult;
|
|
|
|
|
|
sprintf(FilePath,"/mnt/%s",filename);
|
|
@@ -19680,9 +19731,9 @@ int sftpDownLoadFile(char *location, char *user, int port, char *path, char *fil
|
|
|
int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
|
|
|
{
|
|
|
int result = TRUE;
|
|
|
- char rmFileCmd[100]={0};
|
|
|
- char FilePath[100]={0};
|
|
|
- char ftpbuf[200];
|
|
|
+ char rmFileCmd[300]={0};
|
|
|
+ char FilePath[256]={0};
|
|
|
+ char ftpbuf[2048];
|
|
|
int systemresult;
|
|
|
|
|
|
sprintf(FilePath,"/mnt/%s",filename);
|
|
@@ -19696,14 +19747,20 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
|
|
|
}
|
|
|
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
-
|
|
|
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
|
|
|
+ if(strstr((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "TRUE") != NULL)
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --ca-certificate=/root/cacert.pem",filename, url);
|
|
|
+ else
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
|
|
|
DEBUG_INFO("Download command: %s\n",ftpbuf);
|
|
|
|
|
|
systemresult = system(ftpbuf);
|
|
|
if(systemresult != 0)
|
|
|
{
|
|
|
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
|
|
|
+ if(strstr((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[AuthDownloadlinkCertificate].ItemData, "TRUE") != NULL)
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp --ca-certificate=/root/cacert.pem",filename, url);
|
|
|
+ else
|
|
|
+ sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp --no-check-certificate",filename, url);
|
|
|
+
|
|
|
DEBUG_INFO("Download command: %s\n",ftpbuf);
|
|
|
|
|
|
systemresult = system(ftpbuf);
|
|
@@ -21274,10 +21331,13 @@ void InitialSystemValue(void)
|
|
|
TransactionMessageAttemptsValue = atoi((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData);
|
|
|
TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
|
|
|
|
|
|
- //Hear Beat
|
|
|
+ //Heart Beat
|
|
|
HeartBeatWithNOResponse = 0;
|
|
|
- HeartBeatWaitTime = atoi((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData);;
|
|
|
- FirstHeartBeat = 0;
|
|
|
+ HeartBeatWaitTime = atoi((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData);
|
|
|
+ if(HeartBeatWaitTime == 0)
|
|
|
+ FirstHeartBeat = TRUE;
|
|
|
+ else
|
|
|
+ FirstHeartBeat = FALSE;
|
|
|
|
|
|
FirmwareStatusNotificationStatus = FIRMWARE_STATUS_IDLE; // Idle
|
|
|
DiagnosticsStatusNotificationStatus = DIAGNOSTIC_STATUS_IDLE; // Idle
|