import type { ValidateFunction } from 'ajv'
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
-import { type ChargingStation, addConfigurationKey } from '../../../charging-station/index.js'
+import { addConfigurationKey, type ChargingStation } from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
+ ChargingStationEvents,
ErrorType,
type JsonType,
type OCPP20BootNotificationResponse,
} from '../../../types/index.js'
import { isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
const moduleName = 'OCPP20ResponseService'
chargingStation: ChargingStation,
payload: OCPP20BootNotificationResponse
): void {
- if (payload.status === RegistrationStatusEnumType.ACCEPTED) {
- addConfigurationKey(
- chargingStation,
- OCPP20OptionalVariableName.HeartbeatInterval,
- payload.interval.toString(),
- {},
- { overwrite: true, save: true }
- )
- OCPP20ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval)
- }
if (Object.values(RegistrationStatusEnumType).includes(payload.status)) {
+ chargingStation.bootNotificationResponse = payload
+ if (chargingStation.isRegistered()) {
+ chargingStation.emit(ChargingStationEvents.registered)
+ if (chargingStation.inAcceptedState()) {
+ addConfigurationKey(
+ chargingStation,
+ OCPP20OptionalVariableName.HeartbeatInterval,
+ payload.interval.toString(),
+ {},
+ { overwrite: true, save: true }
+ )
+ chargingStation.emit(ChargingStationEvents.accepted)
+ }
+ } else if (chargingStation.inRejectedState()) {
+ chargingStation.emit(ChargingStationEvents.rejected)
+ }
const logMsg = `${chargingStation.logPrefix()} Charging station in '${
payload.status
}' state on the central server`