From: Calin Crecea Date: Wed, 13 Apr 2022 16:18:29 +0000 (+0200) Subject: log raw socket messages X-Git-Tag: v1.1.57~8^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=625b0fd5a433f3f9a65a03633ca9ebbd01c5e875;p=e-mobility-charging-stations-simulator.git log raw socket messages --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 1d18e5b6..d1a94e75 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -69,6 +69,7 @@ import { SampledValueTemplate } from '../types/MeasurandPerPhaseSampledValueTemp import { SupervisionUrlDistribution } from '../types/ConfigurationData'; import { URL } from 'url'; import Utils from '../utils/Utils'; +import chalk from 'chalk'; import crypto from 'crypto'; import fs from 'fs'; import logger from '../utils/Logger'; @@ -1468,6 +1469,8 @@ export default class ChargingStation { let errMsg: string; try { const request = JSON.parse(data.toString()) as IncomingRequest; + const requestAsString = JSON.stringify(request); + console.log(chalk`{yellow << Received message = ${requestAsString}}`); if (Utils.isIterable(request)) { // Parse the message [messageType, messageId, commandName, commandPayload, errorDetails] = request; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 89766371..9dd0e7bf 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -16,6 +16,7 @@ import OCPPError from '../../exception/OCPPError'; 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 { @@ -151,6 +152,7 @@ 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);