AuthorizationStatus,
StartTransactionRequest,
StartTransactionResponse,
- StopTransactionReason,
StopTransactionRequest,
StopTransactionResponse,
} from '../types/ocpp/Transaction';
if (this.isResponse(messageEvent.data)) {
return;
}
- this.validateMessageEvent(messageEvent);
+ const [uuid, command, requestPayload] = this.validateMessageEvent(messageEvent)
+ .data as BroadcastChannelRequest;
- const [uuid, command, requestPayload] = messageEvent.data as BroadcastChannelRequest;
-
- if (
- requestPayload?.hashId === undefined &&
- (requestPayload?.hashIds as string[])?.includes(this.chargingStation.stationInfo.hashId) ===
- false
- ) {
- return;
- }
- if (
- requestPayload?.hashIds === undefined &&
- requestPayload?.hashId !== this.chargingStation.stationInfo.hashId
- ) {
- return;
- }
- if (requestPayload?.hashId !== undefined) {
- logger.warn(
- `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead`
- );
+ if (requestPayload?.hashIds !== undefined || requestPayload?.hashId !== undefined) {
+ if (
+ requestPayload?.hashId === undefined &&
+ requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
+ ) {
+ return;
+ }
+ if (
+ requestPayload?.hashIds === undefined &&
+ requestPayload?.hashId !== this.chargingStation.stationInfo.hashId
+ ) {
+ return;
+ }
+ if (requestPayload?.hashId !== undefined) {
+ logger.warn(
+ `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead`
+ );
+ }
}
let responsePayload: BroadcastChannelResponsePayload;
private messageErrorHandler(messageEvent: MessageEvent): void {
logger.error(
`${this.chargingStation.logPrefix()} ${moduleName}.messageErrorHandler: Error at handling message:`,
- { messageEvent, messageEventData: messageEvent.data }
+ { messageEvent }
);
}
true
),
idTag: this.chargingStation.getTransactionIdTag(requestPayload.transactionId),
- reason: StopTransactionReason.NONE,
+ ...(requestPayload.reason && { reason: requestPayload.reason }),
});
case BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR:
this.chargingStation.startAutomaticTransactionGenerator(requestPayload.connectorIds);