From: Jérôme Benoit Date: Thu, 25 May 2023 19:42:52 +0000 (+0200) Subject: refactor(simulator): factor out data transfer response X-Git-Tag: v1.2.14~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b63b4a73f7869a2ff31e5bd259d056faaa53a5de;p=e-mobility-charging-stations-simulator.git refactor(simulator): factor out data transfer response Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 9e4ff3e0..f39e8cfa 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -1488,13 +1488,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ): OCPP16DataTransferResponse { try { if (Object.values(OCPP16DataTransferVendorId).includes(commandPayload.vendorId)) { - return { - status: OCPP16DataTransferStatus.ACCEPTED, - }; + return OCPP16Constants.OCPP_DATA_TRANSFER_RESPONSE_ACCEPTED; } - return { - status: OCPP16DataTransferStatus.UNKNOWN_VENDOR_ID, - }; + return OCPP16Constants.OCPP_DATA_TRANSFER_RESPONSE_UNKNOWN_VENDOR_ID; } catch (error) { return this.handleIncomingRequestError( chargingStation, diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index 5a271f59..e82b7d70 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -97,10 +97,18 @@ export class OCPPConstants { status: TriggerMessageStatus.NOT_IMPLEMENTED, }); + static readonly OCPP_DATA_TRANSFER_RESPONSE_ACCEPTED = Object.freeze({ + status: DataTransferStatus.ACCEPTED, + }); + static readonly OCPP_DATA_TRANSFER_RESPONSE_REJECTED = Object.freeze({ status: DataTransferStatus.REJECTED, }); + static readonly OCPP_DATA_TRANSFER_RESPONSE_UNKNOWN_VENDOR_ID = Object.freeze({ + status: DataTransferStatus.UNKNOWN_VENDOR_ID, + }); + protected constructor() { // This is intentional }