From: Jérôme Benoit Date: Wed, 5 Jun 2024 18:36:34 +0000 (+0200) Subject: refactor: cleanup boot notification response assignation X-Git-Tag: v1.3.4~16 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ab29e6820d6a6d48d8ccc091ec8adae575398c3d;p=e-mobility-charging-stations-simulator.git refactor: cleanup boot notification response assignation Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index def985c0..13fbee42 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1839,8 +1839,7 @@ export class ChargingStation extends EventEmitter { if (!this.isRegistered()) { // Send BootNotification do { - // FIXME: duplicated assignment with the boot notification response handler - this.bootNotificationResponse = await this.ocppRequestService.requestHandler< + await this.ocppRequestService.requestHandler< BootNotificationRequest, BootNotificationResponse >(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, { diff --git a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts index b5fc1cef..9b662134 100644 --- a/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts @@ -155,22 +155,21 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne [ BroadcastChannelProcedureName.BOOT_NOTIFICATION, async (requestPayload?: BroadcastChannelRequestPayload) => { - this.chargingStation.bootNotificationResponse = - await this.chargingStation.ocppRequestService.requestHandler< - BootNotificationRequest, - BootNotificationResponse - >( - this.chargingStation, - RequestCommand.BOOT_NOTIFICATION, - { - ...this.chargingStation.bootNotificationRequest, - ...requestPayload - }, - { - skipBufferingOnError: true, - throwError: true - } - ) + await this.chargingStation.ocppRequestService.requestHandler< + BootNotificationRequest, + BootNotificationResponse + >( + this.chargingStation, + RequestCommand.BOOT_NOTIFICATION, + { + ...this.chargingStation.bootNotificationRequest, + ...requestPayload + }, + { + skipBufferingOnError: true, + throwError: true + } + ) return this.chargingStation.bootNotificationResponse } ], diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index d3ee61fd..96fb41ab 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -510,15 +510,10 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { switch (requestedMessage) { case OCPP16MessageTrigger.BootNotification: chargingStation.ocppRequestService - .requestHandler( - chargingStation, - OCPP16RequestCommand.BOOT_NOTIFICATION, - chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, - { skipBufferingOnError: true, triggerMessage: true } - ) - .then(response => { - chargingStation.bootNotificationResponse = response - }) + .requestHandler< + OCPP16BootNotificationRequest, + OCPP16BootNotificationResponse + >(chargingStation, OCPP16RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true }) .catch(errorHandler) break case OCPP16MessageTrigger.Heartbeat: