|
@@ -405,6 +405,95 @@ static char * UnitOfMeasureStr[] = {
|
|
|
MACROSTR(Percent)
|
|
|
};
|
|
|
|
|
|
+//=========================================
|
|
|
+// Save configuration
|
|
|
+//=========================================
|
|
|
+int runShellCmd(const char*cmd)
|
|
|
+{
|
|
|
+ int result = FAIL;
|
|
|
+ char buf[256];
|
|
|
+ FILE *fp;
|
|
|
+
|
|
|
+ fp = popen(cmd, "r");
|
|
|
+ if(fp != NULL)
|
|
|
+ {
|
|
|
+ while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("%s\n", buf);
|
|
|
+ }
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ pclose(fp);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int StoreUsrConfigData(struct SysConfigData *UsrData)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ int fd,wrd;
|
|
|
+ unsigned int i,Chk;
|
|
|
+ unsigned char *ptr, *BufTmp;
|
|
|
+ int MtdBlockSize = 0x300000;
|
|
|
+
|
|
|
+ Chk=0;
|
|
|
+ ptr=(unsigned char *)UsrData;
|
|
|
+ if((BufTmp=malloc(MtdBlockSize))!=NULL)
|
|
|
+ {
|
|
|
+ memset(BufTmp,0,MtdBlockSize);
|
|
|
+ memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
|
|
|
+ for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
|
|
|
+ Chk+=*(BufTmp+i);
|
|
|
+ memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
|
|
|
+
|
|
|
+ // Output configuration to file.
|
|
|
+ fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
|
|
|
+ if (fd < 0)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
|
|
|
+
|
|
|
+ free(BufTmp);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ wrd=write(fd, BufTmp, MtdBlockSize);
|
|
|
+ close(fd);
|
|
|
+ if(wrd<MtdBlockSize)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
|
|
|
+
|
|
|
+ free(BufTmp);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
|
|
|
+
|
|
|
+
|
|
|
+ DEBUG_INFO("Erase /dev/mtd10.\n");
|
|
|
+ runShellCmd("flash_erase /dev/mtd10 0 0");
|
|
|
+ DEBUG_INFO("Write /dev/mtd10.\n");
|
|
|
+ runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
|
|
|
+
|
|
|
+ DEBUG_INFO("Erase /dev/mtd11.\n");
|
|
|
+ runShellCmd("flash_erase /dev/mtd11 0 0");
|
|
|
+ DEBUG_INFO("Write /dev/mtd11.\n");
|
|
|
+ runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
|
|
|
+
|
|
|
+
|
|
|
+ system("rm -f /mnt/EvseConfig.bin");
|
|
|
+ DEBUG_INFO("EvseConfig write to flash OK\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("alloc BlockSize NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(BufTmp!=NULL)
|
|
|
+ free(BufTmp);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//=========================================
|
|
|
// Sqlite3 related function
|
|
|
//=========================================
|
|
@@ -11017,8 +11106,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
+ if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
{
|
|
|
if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
|
|
|
{
|
|
@@ -11044,8 +11133,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
+ if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
{
|
|
|
if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
|
|
|
{
|
|
@@ -11072,8 +11161,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
+ if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
{
|
|
|
if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
|
|
|
{
|
|
@@ -11092,8 +11181,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
+ if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
|
|
|
{
|
|
|
if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
|
|
|
{
|
|
@@ -12997,14 +13086,14 @@ int initialConfigurationTable(void)
|
|
|
// AuthorizationKey
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemAccessibility = 1;
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemName, "AuthorizationKey");
|
|
|
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "" );
|
|
|
+ strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, (char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
|
|
|
|
|
|
fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AuthorizationKey", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
|
|
|
|
|
|
// SecurityProfile
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemAccessibility = 1;
|
|
|
strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemName, "SecurityProfile");
|
|
|
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "0" );
|
|
|
+ sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
|
|
|
|
|
|
fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SecurityProfile", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData);
|
|
|
|
|
@@ -13405,13 +13494,14 @@ int initialConfigurationTable(void)
|
|
|
if(strcmp(keystr, "AuthorizationKey") == 0)
|
|
|
{
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
|
|
|
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", valuestr);
|
|
|
+ //sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", valuestr);
|
|
|
+ sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
|
|
|
}
|
|
|
|
|
|
if(strcmp(keystr, "SecurityProfile") == 0)
|
|
|
{
|
|
|
ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
|
|
|
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", atoi(valuestr) );
|
|
|
+ sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
|
|
|
}
|
|
|
|
|
|
if(strcmp(keystr, "DefaultPrice") == 0)
|
|
@@ -15734,6 +15824,9 @@ int setKeyValue(char *key, char *value)
|
|
|
{
|
|
|
strcpy(str, (const char*)value);
|
|
|
sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", str);
|
|
|
+ strcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword, (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
|
|
|
+ StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
|
|
|
+
|
|
|
isSuccess = ConfigurationStatus_Accepted;
|
|
|
}
|
|
|
else
|
|
@@ -15760,6 +15853,9 @@ int setKeyValue(char *key, char *value)
|
|
|
if(atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData) <= (check_ascii - 0x30))
|
|
|
{
|
|
|
sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", atoi(value) );
|
|
|
+ ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile = atoi(value);
|
|
|
+ StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
|
|
|
+
|
|
|
isSuccess = ConfigurationStatus_Accepted;
|
|
|
}
|
|
|
else
|
|
@@ -17622,7 +17718,7 @@ uint8_t GetOcppSecurityProfile()
|
|
|
|
|
|
void GetOcppChargerBoxId(uint8_t *data)
|
|
|
{
|
|
|
- sprintf((char*)data, "%s", ShmOCPP16Data->ChargeBoxId);
|
|
|
+ sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
|
|
|
}
|
|
|
|
|
|
void GetOcppSecurityPassword(uint8_t *data)
|