From b63b4a73f7869a2ff31e5bd259d056faaa53a5de Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 25 May 2023 21:42:52 +0200 Subject: [PATCH] refactor(simulator): factor out data transfer response MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 8 ++------ src/charging-station/ocpp/OCPPConstants.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) 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 } -- 2.34.1