Search code examples
ocpp

What's MessageTypeId in OCPP request payload


In OCPP 1.6, the client (Charging Station) sends a CALL (similar to request in HTTP) to server (Charging Station Management Systems). All CALLs have a strict structure of 4 elements:

  • MessageTypeId (integer)
  • UniqueId (UUID, string)
  • Action (string)
  • Payload (JSON object containing the arguments relevant to the Action.)

I have gone through the documentation but I cannot find MessageTypeId. So I want to know whether it is just a random number?

Example request payload:

[
  2,// <----- I want to know, where I can find this. 
  "a7caa7a1-c309-43bd-af3f-b5c1c4f9657e", 
  "Authorize",
  {
    "idTag": "${req.body.idTag}"
  }
]

Solution

  • MessageTypeId Defines the type of Message, whether it is Call, CallResult or CallError:

    MessageType | MessageTypeId | Direction
    
    CALL        |       2       | Client-to-Server
    
    CALLRESULT  |       3       | Server-to-Client
    
    CALLERROR   |       4       | Server-to-Client
    

    You can read more on page 9 of This document .