From b9b505dd25c7d195abfbc125d5420c6babdf61b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 16 Mar 2026 00:59:05 +0100 Subject: [PATCH] fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Per spec §4.4/§7.24 and §4.5/§7.25, Idle SHALL only be sent via TriggerMessage when not busy. The code was returning stale terminal statuses (Uploaded, UploadFailed, Installed, etc.) instead of Idle. - DiagnosticsStatusNotification: return Uploading only when actively uploading, Idle otherwise (fixes stale Uploaded/UploadFailed) - FirmwareStatusNotification: return Downloading/Downloaded/Installing only when in progress, Idle otherwise (fixes stale Installed/Failed) - UpdateFirmware guard: allow retry after DownloadFailed or InstallationFailed instead of blocking all non-Installed statuses --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index b9c0bdaa..6a188dff 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -369,8 +369,12 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, { + // §4.4 + §7.24: Idle when not busy uploading diagnostics status: - chargingStation.stationInfo?.diagnosticsStatus ?? OCPP16DiagnosticsStatus.Idle, + chargingStation.stationInfo?.diagnosticsStatus === + OCPP16DiagnosticsStatus.Uploading + ? OCPP16DiagnosticsStatus.Uploading + : OCPP16DiagnosticsStatus.Idle, }, { triggerMessage: true, @@ -387,7 +391,15 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, { - status: chargingStation.stationInfo?.firmwareStatus ?? OCPP16FirmwareStatus.Idle, + // §4.5 + §7.25: Idle when not busy downloading/installing firmware + status: + chargingStation.stationInfo?.firmwareStatus === + OCPP16FirmwareStatus.Downloading || + chargingStation.stationInfo?.firmwareStatus === + OCPP16FirmwareStatus.Downloaded || + chargingStation.stationInfo?.firmwareStatus === OCPP16FirmwareStatus.Installing + ? chargingStation.stationInfo.firmwareStatus + : OCPP16FirmwareStatus.Idle, }, { triggerMessage: true, @@ -1554,8 +1566,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { commandPayload.retrieveDate = convertToDate(commandPayload.retrieveDate)! const { retrieveDate } = commandPayload if ( - chargingStation.stationInfo?.firmwareStatus != null && - chargingStation.stationInfo.firmwareStatus !== OCPP16FirmwareStatus.Installed + chargingStation.stationInfo?.firmwareStatus === OCPP16FirmwareStatus.Downloading || + chargingStation.stationInfo?.firmwareStatus === OCPP16FirmwareStatus.Downloaded || + chargingStation.stationInfo?.firmwareStatus === OCPP16FirmwareStatus.Installing ) { logger.warn( `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: firmware update is already in progress` -- 2.53.0