X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16IncomingRequestService.ts;h=6df6f75f09c08f9be541a6bd7de025aab8c46574;hb=dc6617020896c78ee5b3d4ef2513c98b4d61f06f;hp=8d5d0a20e27d86169f0efc86ec954efcfe8e9a2b;hpb=f7f98c68f78566039b7d6f53391e874d79a8b022;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 8d5d0a20..6df6f75f 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -950,6 +950,15 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ) { return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED; } + // TODO: factor out the check on connector id + if (commandPayload?.connectorId < 0) { + logger.warn( + `${this.chargingStation.logPrefix()} ${ + OCPP16IncomingRequestCommand.TRIGGER_MESSAGE + } incoming request received with invalid connectorId ${commandPayload.connectorId}` + ); + return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED; + } try { switch (commandPayload.requestedMessage) { case MessageTrigger.BootNotification: @@ -999,6 +1008,49 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer }); }, Constants.OCPP_TRIGGER_MESSAGE_DELAY); return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED; + case MessageTrigger.StatusNotification: + setTimeout(() => { + if (commandPayload?.connectorId) { + this.chargingStation.ocppRequestService + .requestHandler( + OCPP16RequestCommand.STATUS_NOTIFICATION, + { + connectorId: commandPayload.connectorId, + errorCode: OCPP16ChargePointErrorCode.NO_ERROR, + status: this.chargingStation.getConnectorStatus(commandPayload.connectorId) + .status, + }, + { + triggerMessage: true, + } + ) + .catch(() => { + /* This is intentional */ + }); + } else { + for (const connectorId of this.chargingStation.connectors.keys()) { + this.chargingStation.ocppRequestService + .requestHandler< + OCPP16StatusNotificationRequest, + OCPP16StatusNotificationResponse + >( + OCPP16RequestCommand.STATUS_NOTIFICATION, + { + connectorId, + errorCode: OCPP16ChargePointErrorCode.NO_ERROR, + status: this.chargingStation.getConnectorStatus(connectorId).status, + }, + { + triggerMessage: true, + } + ) + .catch(() => { + /* This is intentional */ + }); + } + } + }, Constants.OCPP_TRIGGER_MESSAGE_DELAY); + return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED; default: return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED; }