jkiv / rrduino

Data collection Arduino client. Intended to send time-based information to a server (over TCP/IP) which will add the data to an rrdtool database (http://oss.oetiker.ch/rrdtool/).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rrduino

Project status: on ice

The goal of this project is to make the Arduino (http://www.arduino.cc/) a versitile little time-based data collection device. The data that the Arduino collects is to be sent of to a server over Ethernet (TCP/IP) where the data can be added to an rrdtool database (http://oss.oetiker.ch/rrdtool/).

Client Configuration

To configure your device, edit config.h according to the instructions outlined in it before compiling the client code and uploading it to the Arduino.

CLIENT_MAC - the client device's MAC address

SERVER_IP - the IP address of the server

SERVER_PORT - the port the server is listening on

CLIENT_ID - the client ID as specified when creating the profile server-side

CLIENT_KEY - the pre-shared key as specified when creating the profile server-side

CAPTURE_DELAY_MS - the time between collected and uploaded data points (in milliseconds)

Customizing RRDuinoClient

TODO

The Protocol

The rrduino protocol is simple. Each command is one line long (ending in a newline \n) with each argument separated by a single space. There are two commands so far: the hello and the update.

Authentication

The rrduino protocol supports optional per-message HMACs (hashed-based message authentication codes). The server and the client have a pre-shared key. The server knows which key to use based on the client_id specified in the hello message. A separate session key is generated from this pre-shared key and some random key material that is shared during the hello exchange. If the server and client have the same pre-shared key, the session key should be able to be generated by both the client and the server but not a third party.

The authentication scheme only authenticates the client to the server. Therefore, the server should not be used to return important information that the client would need to authenticate.

Messages are signed using HMAC-SHA256. Arduino HMAC-SHA256 support requires a third-party library: https://github.com/jkiv/Cryptosuite

See the server documentation for more information on the signing of messages.

Message types

hello

Format: h client_id

The hello command initiates the client-server handshake. The response from the server is a 32-byte blob of key material. The session key is generated from this blob by hashing it using HMAC-SHA256 with the master pre-shared key.

See server documentation for more details on the session key generation.

update

Format: u key1 value1 [key2 value2 key3 value 3 ...] hmac

The update command sends arbitrary key-value pairs to the server. This message type has no response. There should be at least one key-value pair; keys and values must be separated by a space; and each pair must be separated by a space as well. The final argument, hmac, is the lower-case ASCII representation of the result of hashing the preceeding data using HMAC-SHA256 with the session key; i.e. HMAC-SHA256(session_key, "u key1 value1 [key2 value2 key3 value 3 ...]").

For example, temperature could be a key and 30.1 could be its value. The resulting message might look like u temperature 30.1 a103c31cbffe0102a103c31cbffe0102a103c31cbffe0102a103c31cbffe0102 where the last string a103c...e0102 is the HMAC. The server can then decide how to format the rrdupdate command based on these key-value pairs.

Third-party Libraries

About

Data collection Arduino client. Intended to send time-based information to a server (over TCP/IP) which will add the data to an rrdtool database (http://oss.oetiker.ch/rrdtool/).


Languages

Language:Python 62.2%Language:C++ 35.8%Language:C 2.0%