Fix timestamping at OCPP firmware update command handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Jan 2023 23:21:20 +0000 (00:21 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Jan 2023 23:21:20 +0000 (00:21 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index 03eb83f83de114e11f2f6865e2fbba2efe3a5bed..f62e0ef0b6daf460c7277c9d4c0e58b495436bde 100644 (file)
@@ -956,7 +956,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       return OCPPConstants.OCPP_RESPONSE_EMPTY;
     }
     const retrieveDate = Utils.convertToDate(commandPayload.retrieveDate);
-    if (retrieveDate.getTime() <= Date.now()) {
+    const now = Date.now();
+    if (retrieveDate.getTime() <= now) {
       this.asyncResource
         .runInAsyncScope(
           this.updateFirmware.bind(this) as (
@@ -974,7 +975,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         this.updateFirmware(chargingStation).catch(() => {
           /* Intentional */
         });
-      }, retrieveDate.getTime() - Date.now());
+      }, retrieveDate.getTime() - now);
     }
     return OCPPConstants.OCPP_RESPONSE_EMPTY;
   }