Skip to content

Commit

Permalink
fix: ensure OCPP payload validation report error details
Browse files Browse the repository at this point in the history
The validate() is already bound to Ajv and cannot be rebinded to
a different instance.

Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit committed Jul 24, 2024
1 parent d22a757 commit 45087a8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 124 deletions.
51 changes: 17 additions & 34 deletions src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.CLEAR_CACHE,
Expand All @@ -227,8 +226,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
Expand All @@ -239,8 +237,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.GET_CONFIGURATION,
Expand All @@ -251,8 +248,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
Expand All @@ -263,8 +259,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
Expand All @@ -275,8 +270,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
Expand All @@ -287,8 +281,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
Expand All @@ -299,8 +292,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
Expand All @@ -311,8 +303,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
Expand All @@ -323,8 +314,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
Expand All @@ -335,8 +325,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
Expand All @@ -347,8 +336,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
Expand All @@ -359,8 +347,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.DATA_TRANSFER,
Expand All @@ -371,8 +358,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
Expand All @@ -383,8 +369,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.RESERVE_NOW,
Expand All @@ -395,8 +380,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
Expand All @@ -407,8 +391,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
])
// Handle incoming request events
Expand Down
30 changes: 10 additions & 20 deletions src/charging-station/ocpp/1.6/OCPP16RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.BOOT_NOTIFICATION,
Expand All @@ -61,8 +60,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
Expand All @@ -73,8 +71,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.HEARTBEAT,
Expand All @@ -85,8 +82,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.METER_VALUES,
Expand All @@ -97,8 +93,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.STATUS_NOTIFICATION,
Expand All @@ -109,8 +104,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.START_TRANSACTION,
Expand All @@ -121,8 +115,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.STOP_TRANSACTION,
Expand All @@ -133,8 +126,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.DATA_TRANSFER,
Expand All @@ -145,8 +137,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
[
OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
Expand All @@ -157,8 +148,7 @@ export class OCPP16RequestService extends OCPPRequestService {
moduleName,
'constructor'
)
)
.bind(this),
),
],
])
this.buildRequestPayload = this.buildRequestPayload.bind(this)
Expand Down
Loading

0 comments on commit 45087a8

Please sign in to comment.