split UpdateFirmware
ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-update-firmware.json
+{
+ "title": "Update Charging Station firmware",
+ "type": "object",
+ "properties": {
+ "chargingStationID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "args": {
+ "type": "object",
+ "properties": {
+ "location": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "retries": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "retrieveDate": {
+ "type": "string",
+ "format": "date-time",
+ "sanitize": "mongo"
+ },
+ "retryInterval": {
+ "type": "number",
+ "sanitize": "mongo"
+ }
+ },
+ "required": [
+ "location",
+ "retrieveDate"
+ ]
+ }
+ },
+ "required": [
+ "chargingStationID"
+ ]
+}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1188,8 +1188,28 @@ export default class ChargingStationService {
result = await ChargingStationService.executeChargingStationCommand(
req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
break;
+ // Update Firmware
+ case Command.UPDATE_FIRMWARE:
+ filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionUpdateFirmwareReq(req.body);
+ result = await ChargingStationService.executeChargingStationCommand(
+ req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
+ break;
// Other commands
default:
+ // Log Specific Schema has not been verified yet:
+ await Logging.logWarning({
+ tenantID: req.tenant.id,
+ siteID: chargingStation.siteID,
+ siteAreaID: chargingStation.siteAreaID,
+ companyID: chargingStation.companyID,
+ chargingStationID: chargingStation.id,
+ source: chargingStation.id,
+ user: req.user,
+ action: action,
+ module: MODULE_NAME, method: 'handleAction',
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ message: `Command '${command}' has not yet its own validation schema.`
+ });
// Execute it
result = await ChargingStationService.executeChargingStationCommand(
req.tenant, req.user, chargingStation, action, command, filteredRequest.args);

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingProfilesRequest, HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingProfilesRequest, HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
import { ChargingProfile } from '../../../../types/ChargingProfile';
import HttpDatabaseRequest from '../../../../types/requests/HttpDatabaseRequest';
@@ -16,6 +16,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationActionStartTransaction: Schema;
private chargingStationActionStopTransaction: Schema;
private chargingStationActionGetCompositeSchedule: Schema;
+ private chargingStationActionUpdateFirmware: Schema;
private chargingStationQRCodeGenerate: Schema;
private chargingStationQRCodeDownload: Schema;
private chargingStationOcppParametersGet: Schema;
@@ -41,6 +42,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationActionStartTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-start-transaction.json`, 'utf8'));
this.chargingStationActionStopTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-stop-transaction.json`, 'utf8'));
this.chargingStationActionGetCompositeSchedule = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-get-composite-schedule.json`, 'utf8'));
+ this.chargingStationActionUpdateFirmware = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-update-firmware.json`, 'utf8'));
this.chargingStationQRCodeGenerate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-generate.json`, 'utf8'));
this.chargingStationQRCodeDownload = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-qrcode-download.json`, 'utf8'));
this.chargingStationOcppParametersGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-ocpp-parameters-get.json`, 'utf8'));
@@ -107,6 +109,12 @@ export default class ChargingStationValidator extends SchemaValidator {
return data;
}
+ public validateChargingStationActionUpdateFirmwareReq(data: any): HttpChargingStationUpdateFirmwareRequest {
+ // Validate schema for Update Firmware
+ this.validate(this.chargingStationActionUpdateFirmware, data);
+ return data;
+ }
+
public validateChargingStationQRCodeGenerateReq(data: any): HttpChargingStationConnectorRequest {
// Validate schema
this.validate(this.chargingStationQRCodeGenerate, data);

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -136,6 +136,16 @@ export interface HttpChargingStationGetCompositeScheduleRequest {
}
}
+export interface HttpChargingStationUpdateFirmwareRequest {
+ chargingStationID: string,
+ args: {
+ location: string,
+ retries?: number,
+ retryInterval?: number,
+ retrieveDate: Date
+ }
+}
+
export interface HttpIsAuthorizedRequest {
Action: string;
Arg1: any;

split UpdateFirmware