From b03c86f2f90f1390805570e296d16af071d4b2c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 7 Jul 2023 23:19:53 +0200 Subject: [PATCH] feat: make ocppStrictCompliance define payloadSchemaValidation default MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 2 +- src/charging-station/ChargingStation.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3bbc77e9..592b3eab 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ But the modifications to test have to be done to the files in the build target d | amperageLimitationUnit | A/cA/dA/mA | A | string | charging stations amperage limit unit | | enableStatistics | true/false | false | boolean | enable charging stations statistics | | mustAuthorizeAtRemoteStart | true/false | true | boolean | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled | -| payloadSchemaValidation | true/false | true | boolean | validate OCPP commands PDU against [OCA](https://www.openchargealliance.org/) JSON schemas | +| payloadSchemaValidation | true/false | true if ocppStrictCompliance is true/false if ocppStrictCompliance is false | boolean | validate OCPP commands PDU against [OCA](https://www.openchargealliance.org/) JSON schemas | | beginEndMeterValues | true/false | false | boolean | enable Transaction.{Begin,End} MeterValues | | outOfOrderEndMeterValues | true/false | false | boolean | send Transaction.End MeterValues out of order. Need to relax OCPP specifications strict compliance ('ocppStrictCompliance' parameter) | | meteringPerTransaction | true/false | true | boolean | enable metering history on a per transaction basis | diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 77e93ed6..022f11bb 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -251,6 +251,19 @@ export class ChargingStation { } public getPayloadSchemaValidation(): boolean { + if ( + this.getOcppStrictCompliance() === true && + (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) || + this.stationInfo.payloadSchemaValidation === false) + ) { + return true; + } else if ( + this.getOcppStrictCompliance() === false && + (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) || + this.stationInfo.payloadSchemaValidation === true) + ) { + return false; + } return this.stationInfo.payloadSchemaValidation ?? true; } -- 2.34.1