From: Jérôme Benoit Date: Sun, 13 Mar 2022 21:46:53 +0000 (+0100) Subject: Use right station info attributes for serial number X-Git-Tag: v1.1.55~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=efb85e20f26ef140f7a293de7404d23ddf11bb38;p=e-mobility-charging-stations-simulator.git Use right station info attributes for serial number Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index d9840987..dc679b84 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -759,6 +759,19 @@ export default class ChargingStation { idSuffix; } + private getRandomSerialNumberSuffix(params?: { + randomBytesLength?: number; + upperCase?: boolean; + }): string { + const randomSerialNumberSuffix = crypto + .randomBytes(params?.randomBytesLength ?? 16) + .toString('hex'); + if (params?.upperCase) { + return randomSerialNumberSuffix.toUpperCase(); + } + return randomSerialNumberSuffix; + } + private buildStationInfo(): ChargingStationInfo { let stationTemplateFromFile: ChargingStationTemplate; try { @@ -784,6 +797,10 @@ export default class ChargingStation { ); this.convertDeprecatedTemplateKey(stationTemplateFromFile, 'supervisionUrl', 'supervisionUrls'); const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? ({} as ChargingStationInfo); + stationInfo.chargePointSerialNumber = stationTemplateFromFile?.chargePointSerialNumberPrefix; + delete stationInfo.chargePointSerialNumberPrefix; + stationInfo.chargeBoxSerialNumber = stationTemplateFromFile?.chargeBoxSerialNumberPrefix; + delete stationInfo.chargeBoxSerialNumberPrefix; stationInfo.wsOptions = stationTemplateFromFile?.wsOptions ?? {}; if (!Utils.isEmptyArray(stationTemplateFromFile.power)) { stationTemplateFromFile.power = stationTemplateFromFile.power as number[]; @@ -831,11 +848,11 @@ export default class ChargingStation { this.bootNotificationRequest = { chargePointModel: this.stationInfo.chargePointModel, chargePointVendor: this.stationInfo.chargePointVendor, - ...(!Utils.isUndefined(this.stationInfo.chargeBoxSerialNumberPrefix) && { - chargeBoxSerialNumber: this.stationInfo.chargeBoxSerialNumberPrefix, + ...(!Utils.isUndefined(this.stationInfo.chargeBoxSerialNumber) && { + chargeBoxSerialNumber: this.stationInfo.chargeBoxSerialNumber, }), - ...(!Utils.isUndefined(this.stationInfo.chargePointSerialNumberPrefix) && { - chargePointSerialNumber: this.stationInfo.chargePointSerialNumberPrefix, + ...(!Utils.isUndefined(this.stationInfo.chargePointSerialNumber) && { + chargePointSerialNumber: this.stationInfo.chargePointSerialNumber, }), ...(!Utils.isUndefined(this.stationInfo.firmwareVersion) && { firmwareVersion: this.stationInfo.firmwareVersion,