return false
}
- public isRegistered (): boolean {
- return !this.inUnknownState() && (this.inAcceptedState() || this.inPendingState())
- }
-
public isWebSocketConnectionOpened (): boolean {
return this.wsConnection?.readyState === WebSocket.OPEN
}
} succeeded`
)
let registrationRetryCount = 0
- if (!this.isRegistered()) {
+ if (!this.inAcceptedState()) {
// Send BootNotification
do {
await this.ocppRequestService.requestHandler<
this.bootNotificationResponse!.currentTime = convertToDate(
this.bootNotificationResponse?.currentTime
)!
- if (!this.isRegistered()) {
- this.stationInfo?.registrationMaxRetries !== -1 && ++registrationRetryCount
+ if (!this.inAcceptedState()) {
+ ++registrationRetryCount
await sleep(
- this.bootNotificationResponse?.interval != null
- ? secondsToMilliseconds(this.bootNotificationResponse.interval)
- : Constants.DEFAULT_BOOT_NOTIFICATION_INTERVAL
+ exponentialDelay(
+ registrationRetryCount,
+ this.bootNotificationResponse?.interval != null
+ ? secondsToMilliseconds(this.bootNotificationResponse.interval)
+ : Constants.DEFAULT_BOOT_NOTIFICATION_INTERVAL
+ )
)
}
} while (
- !this.isRegistered() &&
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (registrationRetryCount <= this.stationInfo!.registrationMaxRetries! ||
- this.stationInfo?.registrationMaxRetries === -1)
+ !this.inAcceptedState() &&
+ (this.stationInfo?.registrationMaxRetries === -1 ||
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ registrationRetryCount <= this.stationInfo!.registrationMaxRetries!)
)
}
- if (!this.isRegistered()) {
+ if (!this.inAcceptedState()) {
logger.error(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${this.stationInfo?.registrationMaxRetries?.toString()})`
private async reconnect (): Promise<void> {
if (
+ this.stationInfo?.autoReconnectMaxRetries === -1 ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.wsConnectionRetryCount < this.stationInfo!.autoReconnectMaxRetries! ||
- this.stationInfo?.autoReconnectMaxRetries === -1
+ this.wsConnectionRetryCount < this.stationInfo!.autoReconnectMaxRetries!
) {
++this.wsConnectionRetryCount
const reconnectDelay =
)
}
if (
- chargingStation.isRegistered() ||
+ chargingStation.inAcceptedState() ||
+ chargingStation.inPendingState() ||
(chargingStation.stationInfo?.ocppStrictCompliance === false &&
chargingStation.inUnknownState())
) {
payload: ResType,
requestPayload: ReqType
): Promise<void> {
- if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
+ if (
+ chargingStation.inAcceptedState() ||
+ ((chargingStation.inUnknownState() || chargingStation.inPendingState()) &&
+ commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) ||
+ (chargingStation.stationInfo?.ocppStrictCompliance === false &&
+ (chargingStation.inUnknownState() || chargingStation.inPendingState()))
+ ) {
if (
this.responseHandlers.has(commandName) &&
OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)
): void {
if (Object.values(RegistrationStatusEnumType).includes(payload.status)) {
chargingStation.bootNotificationResponse = payload
- if (chargingStation.isRegistered()) {
- chargingStation.emit(ChargingStationEvents.registered)
- if (chargingStation.inAcceptedState()) {
- addConfigurationKey(
- chargingStation,
- OCPP16StandardParametersKey.HeartbeatInterval,
- payload.interval.toString(),
- {},
- { overwrite: true, save: true }
- )
- addConfigurationKey(
- chargingStation,
- OCPP16StandardParametersKey.HeartBeatInterval,
- payload.interval.toString(),
- { visible: false },
- { overwrite: true, save: true }
- )
- chargingStation.emit(ChargingStationEvents.accepted)
- }
+ if (chargingStation.inAcceptedState()) {
+ addConfigurationKey(
+ chargingStation,
+ OCPP16StandardParametersKey.HeartbeatInterval,
+ payload.interval.toString(),
+ {},
+ { overwrite: true, save: true }
+ )
+ addConfigurationKey(
+ chargingStation,
+ OCPP16StandardParametersKey.HeartBeatInterval,
+ payload.interval.toString(),
+ { visible: false },
+ { overwrite: true, save: true }
+ )
+ chargingStation.emit(ChargingStationEvents.accepted)
+ } else if (chargingStation.inPendingState()) {
+ chargingStation.emit(ChargingStationEvents.pending)
} else if (chargingStation.inRejectedState()) {
chargingStation.emit(ChargingStationEvents.rejected)
}
)
}
if (
- chargingStation.isRegistered() ||
+ chargingStation.inAcceptedState() ||
+ chargingStation.inPendingState() ||
(chargingStation.stationInfo?.ocppStrictCompliance === false &&
chargingStation.inUnknownState())
) {
payload: ResType,
requestPayload: ReqType
): Promise<void> {
- if (chargingStation.isRegistered() || commandName === OCPP20RequestCommand.BOOT_NOTIFICATION) {
+ if (
+ chargingStation.inAcceptedState() ||
+ ((chargingStation.inUnknownState() || chargingStation.inPendingState()) &&
+ commandName === OCPP20RequestCommand.BOOT_NOTIFICATION) ||
+ (chargingStation.stationInfo?.ocppStrictCompliance === false &&
+ (chargingStation.inUnknownState() || chargingStation.inPendingState()))
+ ) {
if (
this.responseHandlers.has(commandName) &&
OCPP20ServiceUtils.isRequestCommandSupported(chargingStation, commandName)
): void {
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)
- }
+ if (chargingStation.inAcceptedState()) {
+ addConfigurationKey(
+ chargingStation,
+ OCPP20OptionalVariableName.HeartbeatInterval,
+ payload.interval.toString(),
+ {},
+ { overwrite: true, save: true }
+ )
+ chargingStation.emit(ChargingStationEvents.accepted)
+ } else if (chargingStation.inPendingState()) {
+ chargingStation.emit(ChargingStationEvents.pending)
} else if (chargingStation.inRejectedState()) {
chargingStation.emit(ChargingStationEvents.rejected)
}
...params,
}
if (
- (chargingStation.inUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) ||
+ ((chargingStation.inUnknownState() || chargingStation.inPendingState()) &&
+ commandName === RequestCommand.BOOT_NOTIFICATION) ||
(chargingStation.stationInfo?.ocppStrictCompliance === false &&
- chargingStation.inUnknownState()) ||
+ (chargingStation.inUnknownState() || chargingStation.inPendingState())) ||
chargingStation.inAcceptedState() ||
(chargingStation.inPendingState() &&
(params.triggerMessage === true || messageType === MessageType.CALL_RESULT_MESSAGE))
connectorStatusChanged = 'connectorStatusChanged',
deleted = 'deleted',
disconnected = 'disconnected',
- registered = 'registered',
+ pending = 'pending',
rejected = 'rejected',
started = 'started',
stopped = 'stopped',