Skip to content

Retrieving the OCPP MessageID from the OCPP Messages #4

@fabioluiz1

Description

@fabioluiz1

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);
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions