7 Replies Latest reply: May 6, 2014 2:54 AM by Trinity RSS

    Message formatting doc - revised (please join in!)


      This week while doing lesson 5 I realized that I don't like the message formatting document that accompanied lessons 3 & 4.  If I have to read something too many times to figure it out, my general nature is to clean it up.  I don't think it's good to complain unless you have a solution to offer since the world already has enough negativity. 

      To that end, I'm submitting this draft of a new version for future classes.  I did not make drastic changes, but reshuffled some things, added clarity and made all the carats (^) bold.  I also took the line-breaks out of the examples.  My preference is to see the string as it truly is so that when someone copies the examples it doesn't introduce invalid characters, namely spaces and carriage returns.

      Feel free to provide comments, corrections, etc. because in the end the goal is to provide the best possible document for future classes!  It'll be up to the instructors to take our collective feedback for future classes.


      Brent S

      Java Embedded MOOC Message Formatting


      When client socket connects to a well-known port on the Raspberry Pi, a process on the server will respond with a message that contains all of the data gathered on the device. A message can consist of switch activation events, temperature events, position/motion events, and some delimiters.

      The general format of the data string follows this convention:

      Switch Events^Temp Events^GPS Position Events^GPS Motion Events


      • A carat (^) is used a delimiter to separate event types. It follows the last switch activation event, the last temperature event, the last position event. Each message contains exactly three carats, regardless of whether any of the four event types exist in a given message.
      • A comma (,) separates events of the same type.
      • The beginning of the stream signifies the beginning of the message.
      • The end of the stream signifies the end of the message.
      • Note that there are no embedded spaces in the message.

      Events Composition

      • General: Timestamp
        • The timestamp for this and all other events is the number of seconds past the epoch
        • epoch = Jan 1, 1970
      • Switch Activation Events
        • Each switch activation event consists of a timestamp and either a 1 or 0, comma-separated.
        • Switch ON == 1, OFF == 0
      • Temperature Events
        • Each temperature event consists of a timestamp and the temperature value, comma-separated.
        • Temperature units are in degrees Celsius.
      • Position Events
        • Each position event consists of a timestamp, the latitude, longitude, altitude, comma-separated.
        • Example:  41.1234567,E,86.1234567,N,135.89
      • Motion Events
        • Each motion event consists of a timestamp, the velocity and bearing, comma-separated.
        • Bearing and speed units are kilometers per hour (km/h).
        • Example:  45,56.02

      Example Messages


      A single door event (open)


      Three door events: open, closed, open, followed by a temperature event, 24 C


      A temperature event (24 C) followed by a GPS position event (E,86.1234567,N,135.89)


      Two GPS position events

      Two GPS motion events


      Four door events, open, closed, open closed

      Three temperature events: -12, 5, 24 C

      Two GPS position events

      Two GPS motion events