import type OCPPResponseService from './OCPPResponseService';
import PerformanceStatistics from '../../performance/PerformanceStatistics';
import Utils from '../../utils/Utils';
-import chalk from 'chalk';
import logger from '../../utils/Logger';
export default abstract class OCPPRequestService {
if (this.chargingStation.isWebSocketConnectionOpened()) {
// Yes: Send Message
const beginId = PerformanceStatistics.beginMeasure(commandName);
- console.log(chalk`{blue >> Sending message = ${messageToSend}}`);
// FIXME: Handle sending error
this.chargingStation.wsConnection.send(messageToSend);
PerformanceStatistics.endMeasure(commandName, beginId);
+ let msgTypeStr: string;
+ switch (messageType) {
+ case MessageType.CALL_MESSAGE:
+ msgTypeStr = 'request';
+ break;
+ case MessageType.CALL_RESULT_MESSAGE:
+ msgTypeStr = 'response';
+ break;
+ case MessageType.CALL_ERROR_MESSAGE:
+ msgTypeStr = 'error';
+ break;
+ }
+ logger.debug(
+ `${this.chargingStation.logPrefix()} >> Command '${commandName}' sent ${msgTypeStr} payload: ${messageToSend}`
+ );
} else if (!params.skipBufferingOnError) {
// Buffer it
this.chargingStation.bufferMessage(messageToSend);