} from '../../utils/index.js'
import { OCPPConstants } from './OCPPConstants.js'
import type { OCPPResponseService } from './OCPPResponseService.js'
-import { OCPPServiceUtils } from './OCPPServiceUtils.js'
+import { getMessageTypeString, OCPPServiceUtils } from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const Ajv = _Ajv.default
commandName
)
} catch (error) {
- handleSendMessageError(chargingStation, commandName, error as Error, {
- throwError: true
- })
+ handleSendMessageError(
+ chargingStation,
+ commandName,
+ MessageType.CALL_RESULT_MESSAGE,
+ error as Error,
+ {
+ throwError: true
+ }
+ )
return null
}
}
commandName
)
} catch (error) {
- handleSendMessageError(chargingStation, commandName, error as Error)
+ handleSendMessageError(
+ chargingStation,
+ commandName,
+ MessageType.CALL_ERROR_MESSAGE,
+ error as Error
+ )
return null
}
}
params
)
} catch (error) {
- handleSendMessageError(chargingStation, commandName, error as Error, {
- throwError: params.throwError
- })
+ handleSendMessageError(
+ chargingStation,
+ commandName,
+ MessageType.CALL_MESSAGE,
+ error as Error,
+ {
+ throwError: params.throwError
+ }
+ )
return null
}
}
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this
// Send a message through wsConnection
- return await new Promise<ResponseType>((resolve, reject) => {
+ return await new Promise<ResponseType>((resolve, reject: (reason?: unknown) => void) => {
/**
* Function that will receive the request's response
*
)
}
logger.error(
- `${chargingStation.logPrefix()} Error occurred at ${OCPPServiceUtils.getMessageTypeString(
+ `${chargingStation.logPrefix()} Error occurred at ${getMessageTypeString(
messageType
)} command ${commandName} with PDU %j:`,
messagePayload,
clearTimeout(sendTimeout)
if (error == null) {
logger.debug(
- `${chargingStation.logPrefix()} >> Command '${commandName}' sent ${OCPPServiceUtils.getMessageTypeString(
+ `${chargingStation.logPrefix()} >> Command '${commandName}' sent ${getMessageTypeString(
messageType
)} payload: ${messageToSend}`
)
params.skipBufferingOnError === false ? '' : 'non '
}buffered message id '${messageId}' with content '${messageToSend}'`,
commandName,
- { name: error.name, message: error.message, stack: error.stack }
+ {
+ name: error.name,
+ message: error.message,
+ stack: error.stack
+ }
)
)
}
])
}
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
public abstract requestHandler<ReqType extends JsonType, ResType extends JsonType>(
chargingStation: ChargingStation,
commandName: RequestCommand,
- // FIXME: should be ReqType
- commandParams?: JsonType,
+ commandParams?: ReqType,
params?: RequestParams
): Promise<ResType>
}