Message protocol for embedded device

I'm building an embedded device with a couple of sensors. The device will 'stream' digital data from these sensors over Bluetooth or USB.

Most of the communication will be from the embedded device to the host. The host will infrequently be sending control messages, to control the gain etc.

Since the physical and data link layers are taken care of, I'm looking for a simple message protocol that will make it easy to develop user applications to process/display data on the host computer. Does anyone have any suggestions?


A simple text protocol may be the best for this application. Use the communication channel as a bi-directional serial pipe.

The device can stream sensor values in ASCII (text) format, separated by commas, with each set separated by the newline character. The rate is preferably set by the host.

For example,

21204,32014 (new line character '\n' - 0x0A) at the end of each line    

This makes it easier to test, to stream the values to a file, import in to a spreadsheet etc. Similarly commands to the device too, is best done in text.

SET GAIN_1  2  ( sent by host )
OK  ( reply by device )
SET GAIN_2  4 (sent by host )
OK ( reply by device )
SET GAIN_9  2 (sent by host )
ERROR  ( reply by device if it does not understand)

SET RATE 500   ( set the sensor dump rate to every 500 ms )

Need Your Help

How does a reference to an object work?

c++ class reference

Like for instance in a function like so:

applicationDocumentsDirectory changes on build

ios xcode swift

I've created a new swift project and ticked the box for 'use core data'. I've noticed every time i build to my device my data has been cleared from the database. Tracing through the code i noticed ...