Add initial code structure for update firmware simulation
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 30 Dec 2022 15:55:43 +0000 (16:55 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 30 Dec 2022 15:55:43 +0000 (16:55 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/station-templates/chargex.station-template.json
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/types/ocpp/1.6/Requests.ts
src/types/ocpp/1.6/Responses.ts

index 39cc58046effaecf49a44226264dfeb22d4334ad..7c20df31ed97d7ecd4f9b45b7a6a55a7b4d07cc2 100644 (file)
@@ -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",
index ebec27d23544cd40f741b7429042464534fdaf9f..754d0fbfc5cbd0d22beb95ef126a2106a58c68db 100644 (file)
@@ -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<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>([
       [
@@ -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
index 4a90569d5e9a18fee51b7a46bc000dac260f4b95..20d1e4498bccc65ca403e5153a6a2f749d69e4d8 100644 (file)
@@ -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;
index 0f65b7d199ea7f9a9f0066b73510358731871085..1dbcfba8ffe670ceeccc0ce8218fdb35161879fd 100644 (file)
@@ -75,6 +75,8 @@ export interface ClearChargingProfileResponse extends JsonObject {
   status: OCPP16ClearChargingProfileStatus;
 }
 
+export type OCPP16UpdateFirmwareResponse = EmptyObject;
+
 export interface GetDiagnosticsResponse extends JsonObject {
   fileName?: string;
 }