|
@@ -10022,12 +10022,187 @@ void createFirmwareVersionByDataTransfer(void)
|
|
|
json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
|
|
|
}
|
|
|
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId, "ID_FirmwareVersion");
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].ResponseData, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
|
|
|
json_object_put(FirmwareDataTransfer);
|
|
|
}
|
|
|
|
|
|
+int createPresetChargingedEnergyByDataTransfer(uint8_t gun_index, int transactionId)
|
|
|
+{
|
|
|
+ int result = FAIL;
|
|
|
+ int tempIndex;
|
|
|
+ json_object *EnergyDataTransfer = json_object_new_object();
|
|
|
+ json_object *periodEnergys = json_object_new_object();
|
|
|
+
|
|
|
+ if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionId)
|
|
|
+ {
|
|
|
+ json_object_object_add(EnergyDataTransfer, "txId", json_object_new_int(transactionId));
|
|
|
+
|
|
|
+ for(uint8_t idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].presentChargedEnergyPeriod);idxPeriod++)
|
|
|
+ {
|
|
|
+ uint8_t period[3];
|
|
|
+ sprintf((char*)period, "%d", idxPeriod);
|
|
|
+
|
|
|
+ json_object_object_add(periodEnergys, (const char *)period, json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].presentChargedEnergyPeriod[idxPeriod]));
|
|
|
+ }
|
|
|
+
|
|
|
+ json_object_object_add(EnergyDataTransfer, "periodEnergy", json_object_new_string(json_object_to_json_string_ext(periodEnergys, JSON_C_TO_STRING_PLAIN)));
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ } //end of the same index
|
|
|
+ }//end of for CHAdeMO_QUANTITY
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_CCS)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < CCS_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionId)
|
|
|
+ {
|
|
|
+ json_object_object_add(EnergyDataTransfer, "txId", json_object_new_int(transactionId));
|
|
|
+
|
|
|
+ for(uint8_t idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].presentChargedEnergyPeriod);idxPeriod++)
|
|
|
+ {
|
|
|
+ uint8_t period[3];
|
|
|
+ sprintf((char*)period, "%d", idxPeriod);
|
|
|
+
|
|
|
+ json_object_object_add(periodEnergys, (const char *)period, json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].presentChargedEnergyPeriod[idxPeriod]));
|
|
|
+ }
|
|
|
+
|
|
|
+ json_object_object_add(EnergyDataTransfer, "periodEnergy", json_object_new_string(json_object_to_json_string_ext(periodEnergys, JSON_C_TO_STRING_PLAIN)));
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ } //end of the same index
|
|
|
+ } // end of for CCS_QUANTITY
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_GBT)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < GB_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionId)
|
|
|
+ {
|
|
|
+ json_object_object_add(EnergyDataTransfer, "txId", json_object_new_int(transactionId));
|
|
|
+
|
|
|
+ for(uint8_t idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].presentChargedEnergyPeriod);idxPeriod++)
|
|
|
+ {
|
|
|
+ uint8_t period[3];
|
|
|
+ sprintf((char*)period, "%d", idxPeriod);
|
|
|
+
|
|
|
+ json_object_object_add(periodEnergys, (const char *)period, json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].presentChargedEnergyPeriod[idxPeriod]));
|
|
|
+ }
|
|
|
+
|
|
|
+ json_object_object_add(EnergyDataTransfer, "periodEnergy", json_object_new_string(json_object_to_json_string_ext(periodEnergys, JSON_C_TO_STRING_PLAIN)));
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ } //end of the same index
|
|
|
+ } // end of for GB_QUANTITY
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_DO)
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+
|
|
|
+ for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionId)
|
|
|
+ {
|
|
|
+ json_object_object_add(EnergyDataTransfer, "txId", json_object_new_int(transactionId));
|
|
|
+
|
|
|
+ for(uint8_t idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.presentChargedEnergyPeriod);idxPeriod++)
|
|
|
+ {
|
|
|
+ uint8_t period[3];
|
|
|
+ sprintf((char*)period, "%d", idxPeriod);
|
|
|
+
|
|
|
+ json_object_object_add(periodEnergys, (const char *)period, json_object_new_double(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.presentChargedEnergyPeriod[idxPeriod]));
|
|
|
+ }
|
|
|
+
|
|
|
+ json_object_object_add(EnergyDataTransfer, "periodEnergy", json_object_new_string(json_object_to_json_string_ext(periodEnergys, JSON_C_TO_STRING_PLAIN)));
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ } //end of the same index
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
|
|
|
+ {
|
|
|
+ tempIndex = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < AC_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionId)
|
|
|
+ {
|
|
|
+ json_object_object_add(EnergyDataTransfer, "txId", json_object_new_int(transactionId));
|
|
|
+
|
|
|
+ for(uint8_t idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].presentChargedEnergyPeriod);idxPeriod++)
|
|
|
+ {
|
|
|
+ uint8_t period[3];
|
|
|
+ sprintf((char*)period, "%d", idxPeriod);
|
|
|
+
|
|
|
+ json_object_object_add(periodEnergys, (const char *)period, json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].presentChargedEnergyPeriod[idxPeriod]));
|
|
|
+ }
|
|
|
+
|
|
|
+ json_object_object_add(EnergyDataTransfer, "periodEnergy", json_object_new_string(json_object_to_json_string_ext(periodEnergys, JSON_C_TO_STRING_PLAIN)));
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ }//end of the same index
|
|
|
+ }//end of for AC_QUANTITY
|
|
|
+ }
|
|
|
+
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].ResponseData, json_object_to_json_string_ext(EnergyDataTransfer, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(EnergyDataTransfer);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
@@ -10066,7 +10241,7 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
// Send all moudle firmware version on EVSE
|
|
|
createFirmwareVersionByDataTransfer();
|
|
|
json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
- json_object_object_add(response, "data", json_object_new_string((char*)ShmOCPP16Data->DataTransfer[0].Data));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string((char*)ShmOCPP16Data->DataTransfer[0].ResponseData));
|
|
|
sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
json_object_put(response);
|
|
|
}
|
|
@@ -10564,6 +10739,40 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
json_object_put(response);
|
|
|
}
|
|
|
+ else if(strstr(tempmessageId, "ID_TxEnergy") != NULL)
|
|
|
+ {
|
|
|
+ json_object *data;
|
|
|
+ data = json_tokener_parse(tempdata);
|
|
|
+ if(!is_error(data))
|
|
|
+ {
|
|
|
+ if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_object_get(data, "txId") != NULL))
|
|
|
+ {
|
|
|
+ if(createPresetChargingedEnergyByDataTransfer((json_object_get_int(json_object_object_get(data, "ConnectorId"))-1), json_object_get_int(json_object_object_get(data, "txId"))) == PASS)
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Accepted"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string((char*)ShmOCPP16Data->DataTransfer[0].ResponseData));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Present charged energy data can not get."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ json_object_object_add(response, "status", json_object_new_string("Rejected"));
|
|
|
+ json_object_object_add(response, "data", json_object_new_string("Configuration content something wrong."));
|
|
|
+ }
|
|
|
+
|
|
|
+ sprintf(message,"[%d,\"%s\",%s]",MESSAGE_TYPE_CALLRESULT, uuid, json_object_to_json_string_ext(response, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(response);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
// Can not find valid message id
|