}
}
+export const resetAuthorizeConnectorStatus = (connectorStatus: ConnectorStatus): void => {
+ connectorStatus.idTagLocalAuthorized = false
+ connectorStatus.idTagAuthorized = false
+ delete connectorStatus.localAuthorizeIdTag
+ delete connectorStatus.authorizeIdTag
+}
+
export const resetConnectorStatus = (connectorStatus: ConnectorStatus | undefined): void => {
if (connectorStatus == null) {
return
chargingProfile => chargingProfile.transactionId !== connectorStatus.transactionId
)
: []
- connectorStatus.idTagLocalAuthorized = false
- connectorStatus.idTagAuthorized = false
+ resetAuthorizeConnectorStatus(connectorStatus)
connectorStatus.transactionRemoteStarted = false
connectorStatus.transactionStarted = false
delete connectorStatus.transactionStart
delete connectorStatus.transactionId
- delete connectorStatus.localAuthorizeIdTag
- delete connectorStatus.authorizeIdTag
delete connectorStatus.transactionIdTag
connectorStatus.transactionEnergyActiveImportRegisterValue = 0
delete connectorStatus.transactionBeginMeterValue
getConnectorChargingProfiles,
prepareChargingProfileKind,
removeExpiredReservations,
+ resetAuthorizeConnectorStatus,
setConfigurationKeyValue
} from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
// 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
+ }
let response: OCPP16ReserveNowResponse
try {
if (connectorId > 0 && !chargingStation.isConnectorAvailable(connectorId)) {
return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
}
await removeExpiredReservations(chargingStation)
- switch (chargingStation.getConnectorStatus(connectorId)?.status) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const connectorStatus = chargingStation.getConnectorStatus(connectorId)!
+ resetAuthorizeConnectorStatus(connectorStatus)
+ switch (connectorStatus.status) {
case OCPP16ChargePointStatus.Faulted:
response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_FAULTED
break