Edit
Is there a way of intercepting the original request?
|
this.socket.on( |
|
"message", |
|
(message) => { |
|
this.onMessage(message.toString()); |
|
} |
|
); |
|
} |
|
onMessage(message: string) { |
Similarly, intercept the resulting response/error?
|
const result = JSON.stringify([ |
|
CALLRESULT_MESSAGE, |
|
messageId, |
|
responsePayload]); |
|
this.socket.send(result); |
|
const result = JSON.stringify([CALLERROR_MESSAGE, |
|
messageId, |
|
error.code, |
|
error.message, |
|
error.details || {}]); |
|
this.socket.send(result); |
This would be useful for features that depend on a Charger message logs database.
Original Message
According to OCPP 2.0.1 specs:
4.2.1. CALL
A CALL always consists of 4 elements: The standard elements MessageTypeId and MessageId, a specific Action that is required on the other side and a payload, the arguments to the Action. The syntax of a CALL looks like this:
[<MessageTypeId>, "<MessageId>", "<Action>", {<Payload>}]
MessageId string[36] This is a unique identifier that will be used to match request and result.
Given the README example, is there a way of retrieving the MessageId from the OCPP message?
client.on('BootNotification', (request: BootNotificationRequest, cb: (response: BootNotificationResponse) => void) => {
const response: BootNotificationResponse = {
status: 'Accepted',
currentTime: new Date().toISOString(),
interval: 60,
};
cb(response);
});
Edit
Is there a way of intercepting the original request?
ocpp-node-ts/src/impl/Protocol.ts
Lines 30 to 37 in fac0c19
Similarly, intercept the resulting response/error?
ocpp-node-ts/src/impl/Protocol.ts
Lines 237 to 241 in fac0c19
ocpp-node-ts/src/impl/Protocol.ts
Lines 115 to 120 in fac0c19
This would be useful for features that depend on a Charger message logs database.
Original Message
According to OCPP 2.0.1 specs:
Given the README example, is there a way of retrieving the MessageId from the OCPP message?