IoT Protocol

A sketch for a simple IoT protocol for typical star network topology.

A lot of inspiration is taken from https://www.mysensors.org

But the way actuators are handled are quite strange.

However there are a smartSleep() function that handles receive of messages on heartbeats.

Each sleep function has a "smart" variant, which sends heartbeat and process incoming messages before going to sleep. This is useful for sending out firmwares or commands for sleeping nodes. The controller must support buffering of messages and send them when node wakes up.

I think this is the way to go to always allow the sensor initiate communication.

Introduction

The architecture should be suitable for a star network configuration with one or several (redundant) gateways to many sensors and/or actuators.

The gateway should only work as a dumb intermediate between sensor nodes and a controller program.

The controller can either be hosted on a local host or via intermediate in the cloud.

The controller program and sensor nodes need to understand the exact protocol used.

Gateway may be a simple USB stick connected to a computer with the controller program.

Data Model

Data is divided in sensor data and sensor configuration.

Sensor data is owned by sensor and updated regularly to controller for storage.

Sensor configuration is owned by controller and retrieved regularly from controller to sensor.

Data Format

Data is represented as simple key/value pairs.

The key is a string.

The value is one of the supported data types.

Data can represented as:

Each data format (sensor data or configuration) has a unique identifiers which mandates its format.

The following types should be supported:

All formats have an empty value which means that is not entered e.g. 255 for uint8. This permit that only some values are updated in a message. For datatypes with variable length these can be very short.

A data format is specified as follows:

A generic parser can be used to translate between string and binary representation from the spec.

binary = to_binary(format, keys, values)
keys, values = from_binary(format, binary)
string = to_string(format, keys, values)

Radio message format (sensor/gateway)

Messaging over radio has the following format

Following parts may be encrypted with pre-shared node key.

Values are MSB (most significant byte/bit first)

The same format is used both for upstream and downstream messages.

Encryption may be supported using a device unique key installed at factory.

Message types

Attach a new sensor to network

Get sensor configuration

Upload sensor data to controller

Data format may be empty/heartbeat and contain no information.

Typical Sensor Data (owned by sensor)

Typical Sensor Configuration (owned by controller)

TODO

Simulator

Build a simulator to evaluate the system before implemented in hardware.

References