this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
// Authorize idTag
const authorizeResponse: AuthorizeResponse =
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
AuthorizeRequest,
AuthorizeResponse
>(RequestCommand.AUTHORIZE, {
this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests++;
logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
// Start transaction
- startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+ startResponse = await this.chargingStation.ocppRequestService.requestHandler<
StartTransactionRequest,
StartTransactionResponse
>(RequestCommand.START_TRANSACTION, {
}
logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
// Start transaction
- startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+ startResponse = await this.chargingStation.ocppRequestService.requestHandler<
StartTransactionRequest,
StartTransactionResponse
>(RequestCommand.START_TRANSACTION, {
return startResponse;
}
logger.info(this.logPrefix(connectorId) + ' start transaction without an idTag');
- startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+ startResponse = await this.chargingStation.ocppRequestService.requestHandler<
StartTransactionRequest,
StartTransactionResponse
>(RequestCommand.START_TRANSACTION, { connectorId });
connectorId,
this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
);
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
MeterValuesRequest,
MeterValuesResponse
>(RequestCommand.METER_VALUES, {
meterValue: transactionEndMeterValue,
});
}
- stopResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+ stopResponse = await this.chargingStation.ocppRequestService.requestHandler<
StopTransactionRequest,
StopTransactionResponse
>(RequestCommand.STOP_TRANSACTION, {
) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this.heartbeatSetInterval = setInterval(async (): Promise<void> => {
- await this.ocppRequestService.sendMessageHandler<HeartbeatRequest, HeartbeatResponse>(
+ await this.ocppRequestService.requestHandler<HeartbeatRequest, HeartbeatResponse>(
RequestCommand.HEARTBEAT
);
}, this.getHeartbeatInterval());
this.getConnectorStatus(connectorId).transactionId,
interval
);
- await this.ocppRequestService.sendMessageHandler<MeterValuesRequest, MeterValuesResponse>(
+ await this.ocppRequestService.requestHandler<MeterValuesRequest, MeterValuesResponse>(
RequestCommand.METER_VALUES,
{
connectorId,
await this.stopMessageSequence(reason);
for (const connectorId of this.connectors.keys()) {
if (connectorId > 0) {
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
StatusNotificationResponse
>(RequestCommand.STATUS_NOTIFICATION, {
// Send BootNotification
let registrationRetryCount = 0;
do {
- this.bootNotificationResponse = await this.ocppRequestService.sendMessageHandler<
+ this.bootNotificationResponse = await this.ocppRequestService.requestHandler<
BootNotificationRequest,
BootNotificationResponse
>(
)}`
);
// Process the call
- await this.ocppIncomingRequestService.handleRequest(
+ await this.ocppIncomingRequestService.incomingRequestHandler(
messageId,
commandName,
commandPayload
private async startMessageSequence(): Promise<void> {
if (this.stationInfo.autoRegister) {
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
BootNotificationRequest,
BootNotificationResponse
>(
this.getConnectorStatus(connectorId)?.bootStatus
) {
// Send status in template at startup
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
StatusNotificationResponse
>(RequestCommand.STATUS_NOTIFICATION, {
this.getConnectorStatus(connectorId)?.bootStatus
) {
// Send status in template after reset
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
StatusNotificationResponse
>(RequestCommand.STATUS_NOTIFICATION, {
this.getConnectorStatus(connectorId).bootStatus;
} else if (!this.stopped && this.getConnectorStatus(connectorId)?.status) {
// Send previous status at template reload
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
StatusNotificationResponse
>(RequestCommand.STATUS_NOTIFICATION, {
});
} else {
// Send default status
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
StatusNotificationResponse
>(RequestCommand.STATUS_NOTIFICATION, {
connectorId,
this.getEnergyActiveImportRegisterByTransactionId(transactionId)
);
- await this.ocppRequestService.sendMessageHandler<
- MeterValuesRequest,
- MeterValuesResponse
- >(RequestCommand.METER_VALUES, {
- connectorId,
- transactionId,
- meterValue: transactionEndMeterValue,
- });
+ await this.ocppRequestService.requestHandler<MeterValuesRequest, MeterValuesResponse>(
+ RequestCommand.METER_VALUES,
+ {
+ connectorId,
+ transactionId,
+ meterValue: transactionEndMeterValue,
+ }
+ );
}
- await this.ocppRequestService.sendMessageHandler<
+ await this.ocppRequestService.requestHandler<
StopTransactionRequest,
StopTransactionResponse
>(RequestCommand.STOP_TRANSACTION, {
}
this.uiServices
.get(version)
- .handleMessage(command, payload)
+ .messageHandler(command, payload)
.catch(() => {
logger.error(
`${this.logPrefix()} Error while handling command %s message: %j`,
]);
}
- public async handleRequest(
+ public async incomingRequestHandler(
messageId: string,
commandName: OCPP16IncomingRequestCommand,
commandPayload: JsonType
connectorId,
this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
);
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
>(OCPP16RequestCommand.METER_VALUES, {
meterValue: transactionEndMeterValue,
});
}
- const stopResponse = await this.chargingStation.ocppRequestService.sendMessageHandler<
+ const stopResponse = await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StopTransactionRequest,
OCPP16StopTransactionResponse
>(OCPP16RequestCommand.STOP_TRANSACTION, {
}
return Constants.OCPP_RESPONSE_UNLOCK_FAILED;
}
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
}
this.chargingStation.getConnectorStatus(id).availability = commandPayload.type;
if (response === Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
}
this.chargingStation.getConnectorStatus(connectorId).availability = commandPayload.type;
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
const transactionConnectorId = commandPayload.connectorId;
const connectorStatus = this.chargingStation.getConnectorStatus(transactionConnectorId);
if (transactionConnectorId) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
} else if (this.chargingStation.getMayAuthorizeAtRemoteStart()) {
connectorStatus.authorizeIdTag = commandPayload.idTag;
const authorizeResponse: OCPP16AuthorizeResponse =
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16AuthorizeRequest,
OCPP16AuthorizeResponse
>(OCPP16RequestCommand.AUTHORIZE, {
connectorStatus.transactionRemoteStarted = true;
if (
(
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StartTransactionRequest,
OCPP16StartTransactionResponse
>(OCPP16RequestCommand.START_TRANSACTION, {
connectorStatus.transactionRemoteStarted = true;
if (
(
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StartTransactionRequest,
OCPP16StartTransactionResponse
>(OCPP16RequestCommand.START_TRANSACTION, {
this.chargingStation.getConnectorStatus(connectorId).status !==
OCPP16ChargePointStatus.AVAILABLE
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId > 0 &&
this.chargingStation.getConnectorStatus(connectorId)?.transactionId === transactionId
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
);
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
>(OCPP16RequestCommand.METER_VALUES, {
meterValue: transactionEndMeterValue,
});
}
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StopTransactionRequest,
OCPP16StopTransactionResponse
>(OCPP16RequestCommand.STOP_TRANSACTION, {
info.bytes / 1024
} bytes transferred from diagnostics archive ${info.name}`
);
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
DiagnosticsStatusNotificationRequest,
DiagnosticsStatusNotificationResponse
>(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
uri.pathname + diagnosticsArchive
);
if (uploadResponse.code === 226) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
DiagnosticsStatusNotificationRequest,
DiagnosticsStatusNotificationResponse
>(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
);
} catch (error) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
DiagnosticsStatusNotificationRequest,
DiagnosticsStatusNotificationResponse
>(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
uri.protocol
} to transfer the diagnostic logs archive`
);
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
DiagnosticsStatusNotificationRequest,
DiagnosticsStatusNotificationResponse
>(OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
case MessageTrigger.BootNotification:
setTimeout(() => {
this.chargingStation.ocppRequestService
- .sendMessageHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
+ .requestHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
OCPP16RequestCommand.BOOT_NOTIFICATION,
{
chargePointModel:
case MessageTrigger.Heartbeat:
setTimeout(() => {
this.chargingStation.ocppRequestService
- .sendMessageHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
+ .requestHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
OCPP16RequestCommand.HEARTBEAT,
null,
{
super(chargingStation, ocppResponseService);
}
- public async sendMessageHandler<Request extends JsonType, Response extends JsonType>(
+ public async requestHandler<Request extends JsonType, Response extends JsonType>(
commandName: OCPP16RequestCommand,
commandParams?: JsonType,
params?: SendParams
if (Object.values(OCPP16RequestCommand).includes(commandName)) {
return (await this.sendMessage(
Utils.generateUUID(),
- this.buildCommandPayload<Request>(commandName, commandParams),
+ this.buildRequestPayload<Request>(commandName, commandParams),
commandName,
params
)) as unknown as Response;
);
}
- private buildCommandPayload<Request extends JsonType>(
+ private buildRequestPayload<Request extends JsonType>(
commandName: OCPP16RequestCommand,
commandParams?: JsonType
): Request {
} from '../../../types/ocpp/1.6/Transaction';
import {
OCPP16BootNotificationRequest,
- OCPP16HeartbeatRequest,
OCPP16RequestCommand,
OCPP16StatusNotificationRequest,
} from '../../../types/ocpp/1.6/Requests';
import {
OCPP16BootNotificationResponse,
- OCPP16HeartbeatResponse,
OCPP16RegistrationStatus,
OCPP16StatusNotificationResponse,
} from '../../../types/ocpp/1.6/Responses';
]);
}
- public async handleResponse(
+ public async responseHandler(
commandName: OCPP16RequestCommand,
payload: JsonType | string,
requestPayload: JsonType
requestPayload.meterStart
);
this.chargingStation.getBeginEndMeterValues() &&
- (await this.chargingStation.ocppRequestService.sendMessageHandler<
+ (await this.chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
>(OCPP16RequestCommand.METER_VALUES, {
meterValue:
this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
}));
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
this.chargingStation.getConnectorStatus(connectorId).status !==
OCPP16ChargePointStatus.AVAILABLE
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
this.chargingStation.getBeginEndMeterValues() &&
!this.chargingStation.getOcppStrictCompliance() &&
this.chargingStation.getOutOfOrderEndMeterValues() &&
- (await this.chargingStation.ocppRequestService.sendMessageHandler<
+ (await this.chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
OCPP16MeterValuesResponse
>(OCPP16RequestCommand.METER_VALUES, {
!this.chargingStation.isChargingStationAvailable() ||
!this.chargingStation.isConnectorAvailable(transactionConnectorId)
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
this.chargingStation.getConnectorStatus(transactionConnectorId).status =
OCPP16ChargePointStatus.UNAVAILABLE;
} else {
- await this.chargingStation.ocppRequestService.sendMessageHandler<
+ await this.chargingStation.ocppRequestService.requestHandler<
OCPP16BootNotificationRequest,
OCPP16BootNotificationResponse
>(OCPP16RequestCommand.STATUS_NOTIFICATION, {
}
}
- public abstract handleRequest(
+ public abstract incomingRequestHandler(
messageId: string,
commandName: IncomingRequestCommand,
commandPayload: JsonType
) {
this.chargingStation = chargingStation;
this.ocppResponseService = ocppResponseService;
- this.sendMessageHandler.bind(this);
+ this.requestHandler.bind(this);
this.sendResult.bind(this);
this.sendError.bind(this);
}
}
// Handle the request's response
try {
- await self.ocppResponseService.handleResponse(
+ await self.ocppResponseService.responseHandler(
commandName as RequestCommand,
payload,
requestPayload
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- public abstract sendMessageHandler<Request extends JsonType, Response extends JsonType>(
+ public abstract requestHandler<Request extends JsonType, Response extends JsonType>(
commandName: RequestCommand,
commandParams?: JsonType,
params?: SendParams
return OCPPResponseService.instances.get(chargingStation.hashId) as T;
}
- public abstract handleResponse(
+ public abstract responseHandler(
commandName: RequestCommand,
payload: JsonType | string,
requestPayload: JsonType
]);
}
- public async handleMessage(command: ProtocolCommand, payload: JsonType): Promise<void> {
+ public async messageHandler(command: ProtocolCommand, payload: JsonType): Promise<void> {
let messageResponse: JsonType;
if (this.messageHandlers.has(command)) {
try {