realms-team / sol

Sensor Object Library
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link
Master branch Develop branch
Build Status Build Status
Code Health Code Health

This repo contains a set of libraries to manipulate sensor Objects.

An sensor Object contains the following conceptual fields:

We refer to this format as the MTtlv format. It is a generalization of the well-known "Type-Length-Value" (TLV) format.

Installation

Download source: git clone https://github.com/realms-team/sol.git

Code documentation

http://realms-sol.readthedocs.io

Registry

Objects' "types" registry

See registry.

Representations

The SOL Objects are manipulated in groups. Each group of Objects can be represented in binary, JSON or HTTP format.

Binary representation

This representation is used for:

Each group of Objects consists of the following fields:

| SOL header | Objects list |

Some rules:

SOL Header

 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
| V |T|M|S|Y| L |
+-+-+-+-+-+-+-+-+

Object List

According to the header flags, the Object list structure can vary.

Example transmission use cases

Example 1. transmitting a single 2-byte temperature sensor reading, taken in the past:

Total 8 bytes.

Example 2. transmitting a single 2-byte temperature sensor reading, taken just now:

Total: 4 bytes.

Example 3. Transmitting 3 sensor readings from 3 different sensors with well-known length, taken at the same time in the past:

Total: 15 bytes.

Rules for saving to a binary file

The assumption is that a binary file is stored on some hard/flash drive with orders of magnitude more space than a packet. The driving design choice are hence made to allow:

The following rules hence apply when saving to a binary file:

JSON representation

A JSON representation is used:

We use clean indentation for easier readability in these examples. An efficient implementation SHOULD represent the entire JSON string on a single line.

The following is the general format of a JSON representation of sensor Objects:

{
   "mac":       "00-17-0d-00-00-12-34-56",
   "timestamp": 12345678890,
   "type":      39,
   "value":     {
       'temperature': 0x0a33,
   },
}

HTTP representation

This representation is used for minimal communication overhead (when data transists).

{
   "v": 0,
   "o": [
       ew0KICAgIm1hYyI6ICAg,
       ICAgICIwMC0xNy0wZC0w,
       ...
       1NiIsDQogICAidGltZXw,
   ]
}