Understanding Message code



  • I need to understand message coding better. The overview is fine, but I was hoping for a link that would explain it more (i.e. what it message_s? etc).
    Thanks
    John


  • Admin

    message_s contains the actual message that is transferred over the air. It contains of a header and a payload.

    The payload is the actual message you want to transfer from sensor. Like 23.7 degres.
    The header contains meta information like destination, which sensor is reporting etc. The header is needed for routing the message to its destination and for interpreting the message on the other end.



  • Thanks
    So were to you find the syntax to parse the header such as message.header.??? And what is "atoi (message.data)". I hate to keep asking questions, if there is some place I could read up on it.


  • Contest Winner

    @jmmorgan said:

    Thanks
    So were to you find the syntax to parse the header such as message.header.??? And what is "atoi (message.data)". I hate to keep asking questions, if there is some place I could read up on it.

    message.data is the return of gw.getMessage and atoi() is an (arduino) C function to convert a string to an integer, so:

    atoi (message.data) returns the message.data as an integer

    Use that if you are moving integers from server side.

    if you are moving Strings:

    messageString = String(message.data)


  • Admin

    @jmmorgan

    Why would you like to parse the header? And by what?

    You probably need to pick up some of the c++ basics first. There free online 📖 and we linked a couple of physical ones on the API page.


  • Contest Winner

    @hek said:

    You probably need to pick up some of the c++ basics first. There free online 📖 and we linked a couple of physical ones on the API page.

    I would also recommend Beginning C in Arduino, which is a great start. It has practical examples you can test with your Arduino. Downside is that it has a terrible index and is pricey. Borrow it, don't buy it! 😉


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 1
  • 1
  • 6
  • 2

17
Online

11.4k
Users

11.1k
Topics

112.7k
Posts