From: Jérôme Benoit Date: Fri, 30 Dec 2022 15:55:43 +0000 (+0100) Subject: Add initial code structure for update firmware simulation X-Git-Tag: v1.1.89~46 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b03df580733c540eafc26269ee267b675e6b4ae8;p=e-mobility-charging-stations-simulator.git Add initial code structure for update firmware simulation Signed-off-by: Jérôme Benoit --- diff --git a/src/assets/station-templates/chargex.station-template.json b/src/assets/station-templates/chargex.station-template.json index 39cc5804..7c20df31 100644 --- a/src/assets/station-templates/chargex.station-template.json +++ b/src/assets/station-templates/chargex.station-template.json @@ -3,6 +3,7 @@ "baseName": "CS-CHARGEX", "chargePointModel": "Aqueduct 1.0", "chargePointVendor": "ChargeX GmbH", + "firmwareVersionPattern": "^MCC (0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*); SCC \\[(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*), (0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\]$", "firmwareVersion": "MCC 1.2.0; SCC [0.12.0, 0.13.0]", "power": 22080, "powerUnit": "W", diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index ebec27d2..754d0fbf 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -39,6 +39,7 @@ import { OCPP16RequestCommand, OCPP16StatusNotificationRequest, OCPP16TriggerMessageRequest, + OCPP16UpdateFirmwareRequest, RemoteStartTransactionRequest, RemoteStopTransactionRequest, ResetRequest, @@ -58,6 +59,7 @@ import { OCPP16HeartbeatResponse, OCPP16StatusNotificationResponse, OCPP16TriggerMessageResponse, + OCPP16UpdateFirmwareResponse, SetChargingProfileResponse, UnlockConnectorResponse, } from '../../../types/ocpp/1.6/Responses'; @@ -128,6 +130,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer [OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, this.handleRequestGetDiagnostics.bind(this)], [OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, this.handleRequestTriggerMessage.bind(this)], [OCPP16IncomingRequestCommand.DATA_TRANSFER, this.handleRequestDataTransfer.bind(this)], + // [OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, this.handleRequestUpdateFirmware.bind(this)], ]); this.jsonSchemas = new Map>([ [ @@ -1006,6 +1009,28 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer return Constants.OCPP_RESPONSE_REJECTED; } + private handleRequestUpdateFirmware( + chargingStation: ChargingStation, + commandPayload: OCPP16UpdateFirmwareRequest + ): OCPP16UpdateFirmwareResponse { + if ( + OCPP16ServiceUtils.checkFeatureProfile( + chargingStation, + OCPP16SupportedFeatureProfiles.FirmwareManagement, + OCPP16IncomingRequestCommand.UPDATE_FIRMWARE + ) === false + ) { + return Constants.OCPP_RESPONSE_EMPTY; + } + logger.debug( + chargingStation.logPrefix() + + ' ' + + OCPP16IncomingRequestCommand.UPDATE_FIRMWARE + + ' request received: %j', + commandPayload + ); + } + private async handleRequestGetDiagnostics( chargingStation: ChargingStation, commandPayload: GetDiagnosticsRequest diff --git a/src/types/ocpp/1.6/Requests.ts b/src/types/ocpp/1.6/Requests.ts index 4a90569d..20d1e449 100644 --- a/src/types/ocpp/1.6/Requests.ts +++ b/src/types/ocpp/1.6/Requests.ts @@ -56,6 +56,7 @@ export enum OCPP16IncomingRequestCommand { GET_DIAGNOSTICS = 'GetDiagnostics', TRIGGER_MESSAGE = 'TriggerMessage', DATA_TRANSFER = 'DataTransfer', + UPDATE_FIRMWARE = 'UpdateFirmware', } export type OCPP16ClearCacheRequest = EmptyObject; @@ -114,6 +115,13 @@ export interface ClearChargingProfileRequest extends JsonObject { stackLevel?: number; } +export interface OCPP16UpdateFirmwareRequest extends JsonObject { + location: string; + retrieveDate: Date; + retries?: number; + retryInterval?: number; +} + export interface GetDiagnosticsRequest extends JsonObject { location: string; retries?: number; diff --git a/src/types/ocpp/1.6/Responses.ts b/src/types/ocpp/1.6/Responses.ts index 0f65b7d1..1dbcfba8 100644 --- a/src/types/ocpp/1.6/Responses.ts +++ b/src/types/ocpp/1.6/Responses.ts @@ -75,6 +75,8 @@ export interface ClearChargingProfileResponse extends JsonObject { status: OCPP16ClearChargingProfileStatus; } +export type OCPP16UpdateFirmwareResponse = EmptyObject; + export interface GetDiagnosticsResponse extends JsonObject { fileName?: string; }