]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 23:59:05 +0000 (00:59 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 23:59:24 +0000 (00:59 +0100)
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

src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index b9c0bdaaebe59f908dddd29ae65fd333b9ae2273..6a188dfff9d7f46ed0a56906eb701b233cbae0dd 100644 (file)
@@ -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`