From: Jérôme Benoit Date: Mon, 7 Mar 2022 21:22:30 +0000 (+0100) Subject: Convert sendBootNotification to OCPP message sending handler X-Git-Tag: v1.1.52~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6a8b180d4cd55803e41abdc90f016d1323d37ae9;p=e-mobility-charging-stations-simulator.git Convert sendBootNotification to OCPP message sending handler Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index a71d56d9..9297b3e8 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -937,12 +937,16 @@ export default class ChargingStation { // Send BootNotification let registrationRetryCount = 0; do { - this.bootNotificationResponse = await this.ocppRequestService.sendBootNotification( - this.bootNotificationRequest.chargePointModel, - this.bootNotificationRequest.chargePointVendor, - this.bootNotificationRequest.chargeBoxSerialNumber, - this.bootNotificationRequest.firmwareVersion - ); + this.bootNotificationResponse = (await this.ocppRequestService.sendMessageHandler( + RequestCommand.BOOT_NOTIFICATION, + { + chargePointModel: this.bootNotificationRequest.chargePointModel, + chargePointVendor: this.bootNotificationRequest.chargePointVendor, + chargeBoxSerialNumber: this.bootNotificationRequest.chargeBoxSerialNumber, + firmwareVersion: this.bootNotificationRequest.firmwareVersion, + }, + { skipBufferingOnError: true } + )) as BootNotificationResponse; if (!this.isInAcceptedState()) { this.getRegistrationMaxRetries() !== -1 && registrationRetryCount++; await Utils.sleep( @@ -1237,11 +1241,15 @@ export default class ChargingStation { private async startMessageSequence(): Promise { if (this.stationInfo.autoRegister) { - await this.ocppRequestService.sendBootNotification( - this.bootNotificationRequest.chargePointModel, - this.bootNotificationRequest.chargePointVendor, - this.bootNotificationRequest.chargeBoxSerialNumber, - this.bootNotificationRequest.firmwareVersion + await this.ocppRequestService.sendMessageHandler( + RequestCommand.BOOT_NOTIFICATION, + { + chargePointModel: this.bootNotificationRequest.chargePointModel, + chargePointVendor: this.bootNotificationRequest.chargePointVendor, + chargeBoxSerialNumber: this.bootNotificationRequest.chargeBoxSerialNumber, + firmwareVersion: this.bootNotificationRequest.firmwareVersion, + }, + { skipBufferingOnError: true } ); } // Start WebSocket ping diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index f8ca8de6..a7dae0c5 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -811,17 +811,26 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer case MessageTrigger.BootNotification: setTimeout(() => { this.chargingStation.ocppRequestService - .sendBootNotification( - this.chargingStation.getBootNotificationRequest().chargePointModel, - this.chargingStation.getBootNotificationRequest().chargePointVendor, - this.chargingStation.getBootNotificationRequest().chargeBoxSerialNumber, - this.chargingStation.getBootNotificationRequest().firmwareVersion, - this.chargingStation.getBootNotificationRequest().chargePointSerialNumber, - this.chargingStation.getBootNotificationRequest().iccid, - this.chargingStation.getBootNotificationRequest().imsi, - this.chargingStation.getBootNotificationRequest().meterSerialNumber, - this.chargingStation.getBootNotificationRequest().meterType, - { triggerMessage: true } + .sendMessageHandler( + OCPP16RequestCommand.BOOT_NOTIFICATION, + { + chargePointModel: + this.chargingStation.getBootNotificationRequest().chargePointModel, + chargePointVendor: + this.chargingStation.getBootNotificationRequest().chargePointVendor, + chargeBoxSerialNumber: + this.chargingStation.getBootNotificationRequest().chargeBoxSerialNumber, + firmwareVersion: + this.chargingStation.getBootNotificationRequest().firmwareVersion, + chargePointSerialNumber: + this.chargingStation.getBootNotificationRequest().chargePointSerialNumber, + iccid: this.chargingStation.getBootNotificationRequest().iccid, + imsi: this.chargingStation.getBootNotificationRequest().imsi, + meterSerialNumber: + this.chargingStation.getBootNotificationRequest().meterSerialNumber, + meterType: this.chargingStation.getBootNotificationRequest().meterType, + }, + { skipBufferingOnError: true, triggerMessage: true } ) .catch(() => { /* This is intentional */ diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 27ba76ec..e7fa7751 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -23,7 +23,6 @@ import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; import { ErrorType } from '../../../types/ocpp/ErrorType'; import { JsonType } from '../../../types/JsonType'; -import { OCPP16BootNotificationResponse } from '../../../types/ocpp/1.6/Responses'; import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode'; import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus'; import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus'; @@ -64,37 +63,6 @@ export default class OCPP16RequestService extends OCPPRequestService { ); } - public async sendBootNotification( - chargePointModel: string, - chargePointVendor: string, - chargeBoxSerialNumber?: string, - firmwareVersion?: string, - chargePointSerialNumber?: string, - iccid?: string, - imsi?: string, - meterSerialNumber?: string, - meterType?: string, - params?: SendParams - ): Promise { - const payload: OCPP16BootNotificationRequest = { - chargePointModel, - chargePointVendor, - ...(!Utils.isUndefined(chargeBoxSerialNumber) && { chargeBoxSerialNumber }), - ...(!Utils.isUndefined(chargePointSerialNumber) && { chargePointSerialNumber }), - ...(!Utils.isUndefined(firmwareVersion) && { firmwareVersion }), - ...(!Utils.isUndefined(iccid) && { iccid }), - ...(!Utils.isUndefined(imsi) && { imsi }), - ...(!Utils.isUndefined(meterSerialNumber) && { meterSerialNumber }), - ...(!Utils.isUndefined(meterType) && { meterType }), - }; - return (await this.sendMessage( - Utils.generateUUID(), - payload, - OCPP16RequestCommand.BOOT_NOTIFICATION, - { ...params, skipBufferingOnError: true } - )) as OCPP16BootNotificationResponse; - } - public async sendStatusNotification( connectorId: number, status: OCPP16ChargePointStatus, diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 90af961e..73fc4bf1 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -333,19 +333,6 @@ export default abstract class OCPPRequestService { params?: SendParams ): Promise; - public abstract sendBootNotification( - chargePointModel: string, - chargePointVendor: string, - chargeBoxSerialNumber?: string, - firmwareVersion?: string, - chargePointSerialNumber?: string, - iccid?: string, - imsi?: string, - meterSerialNumber?: string, - meterType?: string, - params?: SendParams - ): Promise; - public abstract sendStatusNotification( connectorId: number, status: ChargePointStatus,