if (params?.terminateOpened) {
this.terminateWSConnection();
}
- const ocppVersion = this.getOcppVersion();
+ const ocppVersion = this.stationInfo.ocppVersion ?? OCPPVersion.VERSION_16;
let protocol: string;
switch (ocppVersion) {
case OCPPVersion.VERSION_16:
this.index,
stationTemplate
);
+ stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16;
ChargingStationUtils.createSerialNumber(stationTemplate, stationInfo);
if (!Utils.isEmptyArray(stationTemplate.power)) {
stationTemplate.power = stationTemplate.power as number[];
}
}
- private getOcppVersion(): OCPPVersion {
- return this.stationInfo.ocppVersion ?? OCPPVersion.VERSION_16;
- }
-
private getOcppPersistentConfiguration(): boolean {
return this.stationInfo?.ocppPersistentConfiguration ?? true;
}
// OCPP configuration
this.ocppConfiguration = this.getOcppConfiguration();
this.initializeOcppConfiguration();
- switch (this.getOcppVersion()) {
+ const ocppVersion = this.stationInfo.ocppVersion ?? OCPPVersion.VERSION_16;
+ switch (ocppVersion) {
case OCPPVersion.VERSION_16:
this.ocppIncomingRequestService =
OCPP16IncomingRequestService.getInstance<OCPP16IncomingRequestService>();
);
break;
default:
- this.handleUnsupportedVersion(this.getOcppVersion());
+ this.handleUnsupportedVersion(ocppVersion);
break;
}
if (this.stationInfo?.autoRegister === true) {
} as unknown as Request;
case OCPP16RequestCommand.STOP_TRANSACTION:
chargingStation.getTransactionDataMeterValues() &&
- Utils.isUndefined(commandParams?.transactionData) &&
+ Utils.isNullOrUndefined(commandParams?.transactionData) &&
(connectorId = chargingStation.getConnectorIdByTransactionId(
commandParams?.transactionId as number
));
- !commandParams?.meterStop &&
+ Utils.isNullOrUndefined(commandParams?.meterStop) &&
(energyActiveImportRegister =
chargingStation.getEnergyActiveImportRegisterByTransactionId(
commandParams?.transactionId as number,
// Request
case MessageType.CALL_MESSAGE:
// Build request
+ this.validateRequestPayload(chargingStation, commandName, messagePayload as JsonObject);
chargingStation.requests.set(messageId, [
responseCallback,
errorCallback,
commandName,
messagePayload as JsonType,
]);
- this.validateRequestPayload(chargingStation, commandName, messagePayload as JsonObject);
messageToSend = JSON.stringify([
messageType,
messageId,
connectorId: number,
status: ConnectorStatusEnum
): StatusNotificationRequest {
- switch (chargingStation.stationInfo.ocppVersion) {
+ switch (chargingStation.stationInfo.ocppVersion ?? OCPPVersion.VERSION_16) {
case OCPPVersion.VERSION_16:
return {
connectorId,
connectorId,
evseId: connectorId,
} as OCPP20StatusNotificationRequest;
+ default:
+ throw new BaseError('Cannot build status notification payload: OCPP version not supported');
}
}