From: Jérôme Benoit Date: Wed, 24 Jul 2024 22:14:10 +0000 (+0200) Subject: fix: ensure OCPP payload validation report error details X-Git-Tag: ocpp-server@v1.5.0~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=45087a81ca7dda0b6e72897acd1391d859026961;p=e-mobility-charging-stations-simulator.git fix: ensure OCPP payload validation report error details The validate() is already bound to Ajv and cannot be rebinded to a different instance. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index f026d0a8..d114fe6c 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -215,8 +215,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, @@ -227,8 +226,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, @@ -239,8 +237,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, @@ -251,8 +248,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, @@ -263,8 +259,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, @@ -275,8 +270,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, @@ -287,8 +281,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, @@ -299,8 +292,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, @@ -311,8 +303,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, @@ -323,8 +314,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, @@ -335,8 +325,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, @@ -347,8 +336,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, @@ -359,8 +347,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, @@ -371,8 +358,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, @@ -383,8 +369,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.RESERVE_NOW, @@ -395,8 +380,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CANCEL_RESERVATION, @@ -407,8 +391,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) // Handle incoming request events diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 7c8e9006..8f810861 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -49,8 +49,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.BOOT_NOTIFICATION, @@ -61,8 +60,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, @@ -73,8 +71,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.HEARTBEAT, @@ -85,8 +82,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.METER_VALUES, @@ -97,8 +93,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, @@ -109,8 +104,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.START_TRANSACTION, @@ -121,8 +115,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, @@ -133,8 +126,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.DATA_TRANSFER, @@ -145,8 +137,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, @@ -157,8 +148,7 @@ export class OCPP16RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.buildRequestPayload = this.buildRequestPayload.bind(this) diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 654cc4ef..4fa2dae0 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -108,8 +108,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.HEARTBEAT, @@ -120,8 +119,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.AUTHORIZE, @@ -132,8 +130,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.START_TRANSACTION, @@ -144,8 +141,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, @@ -156,8 +152,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, @@ -168,8 +163,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.METER_VALUES, @@ -180,8 +174,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, @@ -192,8 +185,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.DATA_TRANSFER, @@ -204,8 +196,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, @@ -216,8 +207,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.incomingRequestResponsePayloadValidateFunctions = new Map< @@ -233,8 +223,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, @@ -245,8 +234,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, @@ -257,8 +245,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, @@ -269,8 +256,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, @@ -281,8 +267,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, @@ -293,8 +278,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, @@ -305,8 +289,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, @@ -317,8 +300,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, @@ -329,8 +311,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, @@ -341,8 +322,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, @@ -353,8 +333,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, @@ -365,8 +344,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, @@ -377,8 +355,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, @@ -389,8 +366,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, @@ -401,8 +377,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.RESERVE_NOW, @@ -413,8 +388,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP16IncomingRequestCommand.CANCEL_RESERVATION, @@ -425,8 +399,7 @@ export class OCPP16ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.validatePayload = this.validatePayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 5817ede4..5d074f6a 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -47,8 +47,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.validatePayload = this.validatePayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 0fb6c7f0..c64de06f 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -41,8 +41,7 @@ export class OCPP20RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP20RequestCommand.HEARTBEAT, @@ -53,8 +52,7 @@ export class OCPP20RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, @@ -65,8 +63,7 @@ export class OCPP20RequestService extends OCPPRequestService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.buildRequestPayload = this.buildRequestPayload.bind(this) diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index d24800b2..b846a76a 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -57,8 +57,7 @@ export class OCPP20ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP20RequestCommand.HEARTBEAT, @@ -69,8 +68,7 @@ export class OCPP20ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, @@ -81,8 +79,7 @@ export class OCPP20ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.incomingRequestResponsePayloadValidateFunctions = new Map< @@ -98,8 +95,7 @@ export class OCPP20ResponseService extends OCPPResponseService { moduleName, 'constructor' ) - ) - .bind(this), + ), ], ]) this.validatePayload = this.validatePayload.bind(this)