From 2c7bdc61118232aae9c754edfe6f8528640781ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 15 Jan 2023 00:21:20 +0100 Subject: [PATCH] Fix timestamping at OCPP firmware update command handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 03eb83f8..f62e0ef0 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -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; } -- 2.34.1