Fix and add log messages
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 19 Jan 2023 22:01:55 +0000 (23:01 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 19 Jan 2023 22:01:55 +0000 (23:01 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts

index a87ef6f2145bf6c89cd8a946bb27a593366290ee..547a4f3693321bf271d23cdae07c6cb51df01876 100644 (file)
@@ -65,6 +65,7 @@ import {
   type IncomingRequest,
   IncomingRequestCommand,
   type MeterValuesRequest,
+  type OutgoingRequest,
   RequestCommand,
   type ResponseCallback,
   type StatusNotificationRequest,
@@ -769,6 +770,12 @@ export default class ChargingStation {
       this.messageBuffer.forEach((message) => {
         // TODO: evaluate the need to track performance
         this.wsConnection.send(message);
+        const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse;
+        logger.debug(
+          `${this.logPrefix()} >> Buffered ${OCPPServiceUtils.getMessageTypeString(
+            messageType
+          )} payload sent: ${message}`
+        );
         this.messageBuffer.delete(message);
       });
     }
index d7772bdcc0adbb900602a47a40de582577b04377..effa3abd0ada1244ba1ec1326e92c66848415dca 100644 (file)
@@ -569,7 +569,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
           ' Starting transaction id ' +
           payload.transactionId.toString() +
           " REJECTED with status '" +
-          payload?.idTagInfo?.status +
+          payload.idTagInfo?.status +
           "', idTag '" +
           requestPayload.idTag +
           "'"
@@ -661,16 +661,11 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       chargingStation.powerDivider--;
     }
     chargingStation.resetConnectorStatus(transactionConnectorId);
-    const logMsg =
-      chargingStation.logPrefix() +
-        ' Transaction ' +
-        requestPayload.transactionId.toString() +
-        ' STOPPED on ' +
-        chargingStation.stationInfo.chargingStationId +
-        '#' +
-        transactionConnectorId.toString() +
-        " with status '" +
-        payload.idTagInfo?.status ?? 'undefined' + "'";
+    const logMsg = `${chargingStation.logPrefix()} Transaction ${requestPayload.transactionId.toString()} STOPPED on ${
+      chargingStation.stationInfo.chargingStationId
+    }#${transactionConnectorId.toString()} with status '${
+      payload.idTagInfo?.status ?? 'undefined'
+    }'`;
     if (
       Utils.isNullOrUndefined(payload.idTagInfo) ||
       payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED