"voltageOut": 230,
"beginEndMeterValues": true,
"outOfOrderEndMeterValues": true,
+ "firmwareUpgrade": {
+ "versionUpgrade": {
+ "patternGroup": 3
+ }
+ },
"commandsSupport": {
"incomingCommands": {
"Reset": true,
import { URL } from 'url';
import { parentPort } from 'worker_threads';
+import merge from 'just-merge';
import WebSocket, { type RawData } from 'ws';
import BaseError from '../exception/BaseError';
import {
type ChargingStationTemplate,
CurrentType,
+ type FirmwareUpgrade,
PowerUnits,
type WsOptions,
} from '../types/ChargingStationTemplate';
}
}
+ public getFirmwareUpgrade(): FirmwareUpgrade {
+ return merge(
+ {
+ reset: true,
+ },
+ this.stationInfo.firmwareUpgrade
+ );
+ }
+
public async reset(reason?: StopTransactionReason): Promise<void> {
await this.stop(reason);
await Utils.sleep(this.stationInfo.resetTime);
this.stationInfo.firmwareVersion &&
this.stationInfo.firmwareVersionPattern
) {
+ const versionStep = this.getFirmwareUpgrade()?.versionUpgrade?.step ?? 1;
+ const patternGroup: number =
+ this.getFirmwareUpgrade()?.versionUpgrade?.patternGroup ??
+ this.stationInfo.firmwareVersion.split('.').length;
const match = this.stationInfo.firmwareVersion
.match(new RegExp(this.stationInfo.firmwareVersionPattern))
- .slice(1, this.stationInfo.firmwareVersion.split('.').length + 1);
+ .slice(1, patternGroup + 1);
const patchLevelIndex = match.length - 1;
- match[patchLevelIndex] = (Utils.convertToInt(match[patchLevelIndex]) + 1).toString();
+ match[patchLevelIndex] = (
+ Utils.convertToInt(match[patchLevelIndex]) + versionStep
+ ).toString();
this.stationInfo.firmwareVersion = match.join('.');
}
}
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE
) === false
) {
+ logger.warn(
+ `${chargingStation.logPrefix()} Cannot simulate firmware update: feature profile not supported`
+ );
+ return OCPPConstants.OCPP_RESPONSE_EMPTY;
+ }
+ if (
+ !Utils.isNullOrUndefined(chargingStation.stationInfo.firmwareStatus) &&
+ chargingStation.stationInfo.firmwareStatus !== OCPP16FirmwareStatus.Installed
+ ) {
+ logger.warn(
+ `${chargingStation.logPrefix()} Cannot simulate firmware update: firmware update is already in progress`
+ );
return OCPPConstants.OCPP_RESPONSE_EMPTY;
}
const retrieveDate = Utils.convertToDate(commandPayload.retrieveDate);
OCPP16ChargePointStatus.UNAVAILABLE;
}
}
+ if (
+ chargingStation.getFirmwareUpgrade()?.failureStatus &&
+ !Utils.isEmptyString(chargingStation.getFirmwareUpgrade().failureStatus)
+ ) {
+ await chargingStation.ocppRequestService.requestHandler<
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
+ >(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
+ status: chargingStation.getFirmwareUpgrade().failureStatus,
+ });
+ return;
+ }
await chargingStation.ocppRequestService.requestHandler<
OCPP16FirmwareStatusNotificationRequest,
OCPP16FirmwareStatusNotificationResponse
status: OCPP16FirmwareStatus.Installing,
});
chargingStation.stationInfo.firmwareStatus = OCPP16FirmwareStatus.Installing;
- await Utils.sleep(Utils.getRandomInteger(minDelay, maxDelay) * 1000);
- await chargingStation.reset(OCPP16StopTransactionReason.REBOOT);
+ if (chargingStation.getFirmwareUpgrade().reset === true) {
+ await Utils.sleep(Utils.getRandomInteger(minDelay, maxDelay) * 1000);
+ await chargingStation.reset(OCPP16StopTransactionReason.REBOOT);
+ }
}
private async handleRequestGetDiagnostics(
export type WsOptions = ClientOptions & ClientRequestArgs;
-type FirmwareUpgrade = {
+export type FirmwareUpgrade = {
versionUpgrade: {
- patternGroup?: number | number[];
+ patternGroup?: number;
step?: number;
};
reset?: boolean;
- resetDelay?: number;
- failureMessage?: FirmwareStatus;
+ failureStatus?: FirmwareStatus;
};
type CommandsSupport = {