perf: add fastpath for trigger message handling
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 Jan 2024 19:56:05 +0000 (20:56 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 Jan 2024 19:56:05 +0000 (20:56 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/types/index.ts

index efc3acbace22690d8a374e27657aba7230070dfc..ef87992592780402b57f52584cab7cf3584ce175 100644 (file)
@@ -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(
index 2ca7e8cce450e93a144739943518e7948009cd10..0de12683d952000179e7dedc58b1a944a8411fe5 100644 (file)
@@ -126,6 +126,7 @@ export {
   type OCPP16ReserveNowResponse,
   type OCPP16StatusNotificationResponse,
   type OCPP16TriggerMessageResponse,
+  OCPP16TriggerMessageStatus,
   type OCPP16UpdateFirmwareResponse,
   type SetChargingProfileResponse,
   type UnlockConnectorResponse