public static isCommandSupported(
command: RequestCommand | IncomingRequestCommand,
- stationInfo: ChargingStationInfo
+ chargingStation: ChargingStation
): boolean {
+ const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(
+ command as IncomingRequestCommand
+ );
+ const isRequestCommand = Object.values(RequestCommand).includes(command as RequestCommand);
if (
- Object.values(IncomingRequestCommand).includes(command as IncomingRequestCommand) &&
- !stationInfo?.commandsSupport?.incomingCommands
+ isIncomingRequestCommand &&
+ !chargingStation.stationInfo?.commandsSupport?.incomingCommands
) {
return true;
- }
- if (
- Object.values(RequestCommand).includes(command as RequestCommand) &&
- !stationInfo?.commandsSupport?.outgoingCommands
+ } else if (
+ isIncomingRequestCommand &&
+ chargingStation.stationInfo?.commandsSupport?.incomingCommands
+ ) {
+ return (
+ (chargingStation.stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ??
+ false
+ );
+ } else if (
+ isRequestCommand &&
+ !chargingStation.stationInfo?.commandsSupport?.outgoingCommands
) {
return true;
+ } else if (isRequestCommand && chargingStation.stationInfo?.commandsSupport?.outgoingCommands) {
+ return (
+ (chargingStation.stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ??
+ false
+ );
}
- return (
- ((stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ?? false) ||
- ((stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ?? false)
- );
+ logger.error(`${chargingStation.logPrefix()} Unknown OCPP command '${command}'`);
+ return false;
}
private static getRandomSerialNumberSuffix(params?: {
): Promise<Response> {
if (
Object.values(OCPP16RequestCommand).includes(commandName) &&
- ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
+ ChargingStationUtils.isCommandSupported(commandName, chargingStation)
) {
return (await this.sendMessage(
chargingStation,
if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
if (
this.responseHandlers.has(commandName) &&
- ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
+ ChargingStationUtils.isCommandSupported(commandName, chargingStation)
) {
try {
await this.responseHandlers.get(commandName)(chargingStation, payload, requestPayload);