From ef69bc46a13ffed7f2e1751f6689a1153c8106f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 29 Jan 2024 20:56:05 +0100 Subject: [PATCH] perf: add fastpath for trigger message handling 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 | 10 +++++++++- src/types/index.ts | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index efc3acba..ef879925 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -83,6 +83,7 @@ import { OCPP16SupportedFeatureProfiles, type OCPP16TriggerMessageRequest, type OCPP16TriggerMessageResponse, + OCPP16TriggerMessageStatus, type OCPP16UpdateFirmwareRequest, type OCPP16UpdateFirmwareResponse, type OCPPConfigurationKey, @@ -446,7 +447,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) this.on( OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, - (chargingStation: ChargingStation, request: OCPP16TriggerMessageRequest) => { + ( + chargingStation: ChargingStation, + request: OCPP16TriggerMessageRequest, + response: OCPP16TriggerMessageResponse + ) => { + if (response.status !== OCPP16TriggerMessageStatus.ACCEPTED) { + return + } const { requestedMessage, connectorId } = request const errorHandler = (error: Error): void => { logger.error( diff --git a/src/types/index.ts b/src/types/index.ts index 2ca7e8cc..0de12683 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -126,6 +126,7 @@ export { type OCPP16ReserveNowResponse, type OCPP16StatusNotificationResponse, type OCPP16TriggerMessageResponse, + OCPP16TriggerMessageStatus, type OCPP16UpdateFirmwareResponse, type SetChargingProfileResponse, type UnlockConnectorResponse -- 2.34.1