From: Jérôme Benoit Date: Sun, 15 Mar 2026 23:59:05 +0000 (+0100) Subject: fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating X-Git-Tag: ocpp-server@v3.1.1~31 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b9b505dd25c7d195abfbc125d5420c6babdf61b5;p=e-mobility-charging-stations-simulator.git fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating 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 --- 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`