From: Jérôme Benoit Date: Thu, 24 Dec 2020 18:54:07 +0000 (+0100) Subject: Do case insensitive OCPP parameter key matching in ChangeConfiguration X-Git-Tag: v1.0.1-0~152^2~19 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1b0147cae119f5b519cffd8cdf2a733a3df20b11;p=e-mobility-charging-stations-simulator.git Do case insensitive OCPP parameter key matching in ChangeConfiguration Signed-off-by: Jérôme Benoit --- 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) {