Documentation
¶
Overview ¶
The iote package was designed to help build IoT edge software for on premise edge devices managing a large number of IoT Stations.
The package provides ¶
- MQTT messaging amoung IoT stations and control software - HTTP REST Server for data gathering and configuration - Websockets for realtime bidirectional communication with UI - Web server for mondern web based User Interface - Station manager to track a variety of IoT stations
Messaging Based ¶
The primary communication model for IoTe is a messaging system based on MQTT. These messages can be broke into the following categories
- Meta Data that help describe the "network" infrastructure - Sensor Data that produces data gathered by sensors - Control Data that represents actions to be performed by stations
The topic format used by MQTT is flexible but generally follows the following formats:
## ss/m/<source>/<type> -> { station-informaiton }
Where ss/m == sensor station, <source> is the station Id or source of the message and type represents the specific type of information.
### Meta Data (Station Information)
For example when a station comes alive it can provide some information about itself using the topic:
```ss/m/be:ef:ca:fe:02/station```
The station will announce itself along with some meta information and it's capabilities. The body of the message might look something like this:
```json
{ "id": "be:ef:ca:fe:02", "ip": "10.11.24.24", "sensors": [ "tempc", "humidity", "light" ], "relays": [ "heater", "light" ], }
```
### Sensor Data
Sensor data takes on the form:
```ss/d/<source>/<sensor>/<index>```
Where the source is the Station ID publishing the respective data. The sensor is the type of data being produced (temp, humidity, lidar, GPS).
The index is optional in situations where they may be more than one similar device or sensor, for example a couple of rotation counters on wheels.
The value published by the sensors is typically going to be floating point, however these values may also be integer or string values, including nema-0183.
### Control Data
```ss/c/<source>/<device>/<index>```
This is essentially the same as the sensor except that control commands are used to have a particular device change, for example turning a relay on or off.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Done chan bool StationName string Version string )
global variables and structures
Functions ¶
Types ¶
type Configuration ¶ added in v0.0.3
type Configuration struct { Addr string Broker string Appdir string Debug bool DebugMQTT bool FakeWS bool Filename string Interactive bool Mock bool MaxData int // maximum data values to save Plugin string GPIO bool Verbose bool }
Configuration holds all variables that can be changed to alter the way the program works.
func GetConfig ¶ added in v0.0.3
func GetConfig() *Configuration
func (*Configuration) ReadFile ¶ added in v0.0.3
func (c *Configuration) ReadFile(fname string) error
Load the file from the file corresponding to the fname parameter
func (*Configuration) SaveFile ¶ added in v0.0.3
func (c *Configuration) SaveFile(fname string) error
Save write the configuration to a file in JSON format
func (Configuration) ServeHTTP ¶ added in v0.0.3
func (c Configuration) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP provides a REST interface to the config structure