getConnectorChargingProfiles,
prepareChargingProfileKind,
removeExpiredReservations,
+ resetAuthorizeConnectorStatus,
setConfigurationKeyValue
} from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
}
)
.then(response => {
- if (response.status === OCPP16AuthorizationStatus.ACCEPTED) {
+ if (response.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${
chargingStation.stationInfo?.chargingStationId
switch (requestedMessage) {
case OCPP16MessageTrigger.BootNotification:
chargingStation.ocppRequestService
- .requestHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
- chargingStation,
- OCPP16RequestCommand.BOOT_NOTIFICATION,
- chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest,
- { skipBufferingOnError: true, triggerMessage: true }
- )
- .then(response => {
- chargingStation.bootNotificationResponse = response
- })
+ .requestHandler<
+ OCPP16BootNotificationRequest,
+ OCPP16BootNotificationResponse
+ >(chargingStation, OCPP16RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.catch(errorHandler)
break
case OCPP16MessageTrigger.Heartbeat:
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
commandPayload.expiryDate = convertToDate(commandPayload.expiryDate)!
const { reservationId, idTag, connectorId } = commandPayload
+ if (!chargingStation.hasConnector(connectorId)) {
+ logger.error(
+ `${chargingStation.logPrefix()} Trying to reserve a non existing connector id ${connectorId}`
+ )
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
+ }
+ if (connectorId > 0 && !chargingStation.isConnectorAvailable(connectorId)) {
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
+ }
+ if (connectorId === 0 && !chargingStation.getReserveConnectorZeroSupported()) {
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
+ }
+ if (!(await OCPP16ServiceUtils.isIdTagAuthorized(chargingStation, connectorId, idTag))) {
+ return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
+ }
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const connectorStatus = chargingStation.getConnectorStatus(connectorId)!
+ resetAuthorizeConnectorStatus(connectorStatus)
let response: OCPP16ReserveNowResponse
try {
- if (connectorId > 0 && !chargingStation.isConnectorAvailable(connectorId)) {
- return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
- }
- if (connectorId === 0 && !chargingStation.getReserveConnectorZeroSupported()) {
- return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
- }
- if (!(await OCPP16ServiceUtils.isIdTagAuthorized(chargingStation, connectorId, idTag))) {
- return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
- }
await removeExpiredReservations(chargingStation)
- switch (chargingStation.getConnectorStatus(connectorId)?.status) {
+ switch (connectorStatus.status) {
case OCPP16ChargePointStatus.Faulted:
response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_FAULTED
break