this.ocppResponseService = ocppResponseService;
}
- public async sendMessage(messageId: string, commandParams: Record<string, unknown>, messageType: MessageType,
- commandName: RequestCommand | IncomingRequestCommand): Promise<unknown> {
+ public async sendMessage(messageId: string, commandParams: any, messageType: MessageType, commandName: RequestCommand | IncomingRequestCommand): Promise<unknown> {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// Send a message through wsConnection
// Request
case MessageType.CALL_MESSAGE:
// Build request
- this.chargingStation.requests[messageId] = [responseCallback, rejectCallback, commandParams];
+ this.chargingStation.requests[messageId] = [responseCallback, rejectCallback, commandParams as Record<string, unknown>];
messageToSend = JSON.stringify([messageType, messageId, commandName, commandParams]);
break;
// Response
// Buffer it
this.chargingStation.addToMessageQueue(messageToSend);
// Reject it
- return rejectCallback(new OCPPError(commandParams.code ? commandParams.code as ErrorType : ErrorType.GENERIC_ERROR, commandParams.message ? commandParams.message as string : `WebSocket closed for message id '${messageId}' with content '${messageToSend}', message buffered`, commandParams.details ? commandParams.details : {}));
+ return rejectCallback(new OCPPError(commandParams.code ? commandParams.code : ErrorType.GENERIC_ERROR, commandParams.message ? commandParams.message : `WebSocket closed for message id '${messageId}' with content '${messageToSend}', message buffered`, commandParams.details ? commandParams.details : {}));
}
// Response?
if (messageType === MessageType.CALL_RESULT_MESSAGE) {
resolve();
} else if (messageType === MessageType.CALL_ERROR_MESSAGE) {
// Send timeout
- setTimeout(() => rejectCallback(new OCPPError(commandParams.code ? commandParams.code as ErrorType : ErrorType.GENERIC_ERROR, commandParams.message ? commandParams.message as string : `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams.details ? commandParams.details : {})), Constants.OCPP_ERROR_TIMEOUT);
+ setTimeout(() => rejectCallback(new OCPPError(commandParams.code ? commandParams.code : ErrorType.GENERIC_ERROR, commandParams.message ? commandParams.message : `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams.details ? commandParams.details : {})), Constants.OCPP_ERROR_TIMEOUT);
}
/**