From 1b0147cae119f5b519cffd8cdf2a733a3df20b11 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 24 Dec 2020 19:54:07 +0100 Subject: [PATCH] Do case insensitive OCPP parameter key matching in ChangeConfiguration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ab3986be..4c042eaa 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1277,8 +1277,13 @@ export default class ChargingStation { return Constants.OCPP_RESPONSE_UNLOCKED; } - _getConfigurationKey(key: string): ConfigurationKey { - return this._configuration.configurationKey.find((configElement) => configElement.key === key); + _getConfigurationKey(key: string, caseInsensitive = false): ConfigurationKey { + return this._configuration.configurationKey.find((configElement) => { + if (caseInsensitive) { + return configElement.key.toLowerCase() === key.toLowerCase(); + } + return configElement.key === key; + }); } _addConfigurationKey(key: string, value: string, readonly = false, visible = true, reboot = false): void { @@ -1353,7 +1358,7 @@ export default class ChargingStation { if (!Utils.isString(commandPayload.value)) { logger.error(`${this._logPrefix()} ChangeConfiguration request value field is not a string:`, commandPayload); } - const keyToChange = this._getConfigurationKey(commandPayload.key); + const keyToChange = this._getConfigurationKey(commandPayload.key, true); if (!keyToChange) { return Constants.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED; } else if (keyToChange && keyToChange.readonly) { -- 2.34.1