From: Jérôme Benoit Date: Wed, 23 Feb 2022 16:28:39 +0000 (+0100) Subject: Track OCPP commande use at sending error message X-Git-Tag: v1.1.48~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1d4ad05181ef93c9ea15c25fbd13c6ea22ff35dc;p=e-mobility-charging-stations-simulator.git Track OCPP commande use at sending error message Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 081d8fad..15ad6e8a 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -62,7 +62,7 @@ export default abstract class OCPPRequestService { } } - private async internalSendMessage(messageId: string, messagePayload: JsonType | OCPPError, messageType: MessageType, commandName: RequestCommand | IncomingRequestCommand, + private async internalSendMessage(messageId: string, messagePayload: JsonType | OCPPError, messageType: MessageType, commandName?: RequestCommand | IncomingRequestCommand, params: SendParams = { skipBufferingOnError: false, triggerMessage: false @@ -147,9 +147,9 @@ export default abstract class OCPPRequestService { throw new OCPPError(ErrorType.SECURITY_ERROR, `Cannot send command ${commandName} payload when the charging station is in ${this.chargingStation.getRegistrationStatus()} state on the central server`, commandName); } - private buildMessageToSend(messageId: string, messagePayload: JsonType | OCPPError, messageType: MessageType, commandName: RequestCommand | IncomingRequestCommand, - responseCallback: (payload: JsonType | string, requestPayload: JsonType) => Promise, - rejectCallback: (error: OCPPError, requestStatistic?: boolean) => void): string { + private buildMessageToSend(messageId: string, messagePayload: JsonType | OCPPError, messageType: MessageType, commandName?: RequestCommand | IncomingRequestCommand, + responseCallback?: (payload: JsonType | string, requestPayload: JsonType) => Promise, + rejectCallback?: (error: OCPPError, requestStatistic?: boolean) => void): string { let messageToSend: string; // Type of message switch (messageType) { @@ -167,7 +167,7 @@ export default abstract class OCPPRequestService { // Error Message case MessageType.CALL_ERROR_MESSAGE: // Build Error Message - messageToSend = JSON.stringify([messageType, messageId, messagePayload?.code ?? ErrorType.GENERIC_ERROR, messagePayload?.message ?? '', messagePayload?.details ?? {}]); + messageToSend = JSON.stringify([messageType, messageId, messagePayload?.code ?? ErrorType.GENERIC_ERROR, messagePayload?.message ?? '', messagePayload?.details ?? { commandName }]); break; } return messageToSend;