import type OCPPError from '../exception/OCPPError';
import { StandardParametersKey } from '../types/ocpp/Configuration';
import {
- HeartbeatRequest,
- MeterValuesRequest,
+ type BootNotificationRequest,
+ type HeartbeatRequest,
+ type MeterValuesRequest,
RequestCommand,
type StatusNotificationRequest,
} from '../types/ocpp/Requests';
-import type {
- HeartbeatResponse,
- MeterValuesResponse,
- StatusNotificationResponse,
+import {
+ type BootNotificationResponse,
+ type HeartbeatResponse,
+ type MeterValuesResponse,
+ RegistrationStatus,
+ type StatusNotificationResponse,
} from '../types/ocpp/Responses';
import {
AuthorizationStatus,
- AuthorizeRequest,
- AuthorizeResponse,
- StartTransactionRequest,
- StartTransactionResponse,
- StopTransactionRequest,
- StopTransactionResponse,
+ type AuthorizeRequest,
+ type AuthorizeResponse,
+ type StartTransactionRequest,
+ type StartTransactionResponse,
+ type StopTransactionRequest,
+ type StopTransactionResponse,
} from '../types/ocpp/Transaction';
import {
BroadcastChannelProcedureName,
- BroadcastChannelRequest,
- BroadcastChannelRequestPayload,
- BroadcastChannelResponsePayload,
- MessageEvent,
+ type BroadcastChannelRequest,
+ type BroadcastChannelRequestPayload,
+ type BroadcastChannelResponsePayload,
+ type MessageEvent,
} from '../types/WorkerBroadcastChannel';
import { ResponseStatus } from '../ui/web/src/types/UIProtocol';
import Constants from '../utils/Constants';
| StartTransactionResponse
| StopTransactionResponse
| AuthorizeResponse
+ | BootNotificationResponse
| StatusNotificationResponse
| HeartbeatResponse
| MeterValuesResponse;
StopTransactionRequest,
StartTransactionResponse
>(this.chargingStation, RequestCommand.STOP_TRANSACTION, {
+ meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(
+ requestPayload.transactionId,
+ true
+ ),
...requestPayload,
- meterStop:
- requestPayload.meterStop ??
- this.chargingStation.getEnergyActiveImportRegisterByTransactionId(
- requestPayload.transactionId,
- true
- ),
}),
],
[
AuthorizeResponse
>(this.chargingStation, RequestCommand.AUTHORIZE, requestPayload),
],
+ [
+ BroadcastChannelProcedureName.BOOT_NOTIFICATION,
+ async (requestPayload?: BroadcastChannelRequestPayload) => {
+ this.chargingStation.bootNotificationResponse =
+ await this.chargingStation.ocppRequestService.requestHandler<
+ BootNotificationRequest,
+ BootNotificationResponse
+ >(
+ this.chargingStation,
+ RequestCommand.BOOT_NOTIFICATION,
+ {
+ ...this.chargingStation.bootNotificationRequest,
+ ...requestPayload,
+ },
+ {
+ skipBufferingOnError: true,
+ }
+ );
+ return this.chargingStation.bootNotificationResponse;
+ },
+ ],
[
BroadcastChannelProcedureName.STATUS_NOTIFICATION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
MeterValuesRequest,
MeterValuesResponse
>(this.chargingStation, RequestCommand.METER_VALUES, {
- ...requestPayload,
- meterValue: requestPayload.meterValue ?? [
+ meterValue: [
OCPP16ServiceUtils.buildMeterValue(
this.chargingStation,
requestPayload.connectorId,
: Constants.DEFAULT_METER_VALUES_INTERVAL
),
],
+ ...requestPayload,
});
},
],
return ResponseStatus.SUCCESS;
}
return ResponseStatus.FAILURE;
+ case BroadcastChannelProcedureName.BOOT_NOTIFICATION:
+ if (commandResponse?.status === RegistrationStatus.ACCEPTED) {
+ return ResponseStatus.SUCCESS;
+ }
+ return ResponseStatus.FAILURE;
case BroadcastChannelProcedureName.STATUS_NOTIFICATION:
case BroadcastChannelProcedureName.METER_VALUES:
if (Utils.isEmptyObject(commandResponse) === true) {