BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Introduction

BeeeOn Gateway is a software platform for integrating IoT technologies from different vendors. It abstracts from the sensoric network specifics and provides a unified interface to control sensors and actuator devices.

The BeeeOn Gateway is written in C++ and is divided into several components, especially:

Quick start

The BeeeOn Gateway is built by the CMake build system:

``` $ mkdir build $ (cd build && cmake ..) $ make -C build ```

During development, the BeeeOn Gateway can be started as:

``` $ build/src/beeeon-gateway -c conf/gateway-startup.ini ```

The executable beeeon-gateway reads the given configuration file and configuration files from conf/config.d. Then, the definition of the main instance (of class LoopRunner) is searched, created and executed. Then, all main application threads start.

Hacking the BeeeOn Gateway

In the following sections, you can find some tips how to work with the BeeeOn Gateway or how to customize it.

Server-less debugging (TestingCenter)

The BeeeOn Gateway is primarily intended to be controlled from a remote server. The server allows its users to communicate with gateways and their sensors. However, for development, it is uncomfortable to always work with a server. For this purpose, there is an internal debugging component named TestingCenter.

The TestingCenter is disabled as default. It must be enabled explicitly:

``` $ beeeon-gateway -c conf/gateway-startup -Dtesting.center.enable=yes ... BeeeOn::TestingCenter 20:46:34.627 7052 [Critical] TESTING CENTER IS NOT INTENDED FOR PRODUCTION BeeeOn::TCPConsole 20:46:34.627 7052 [Information] waiting for connection... ... ```

During startup, it will inform you that the TestingCenter is listening for TCP connections. The default port is 6000. Use some TCP line oriented tool (e.g. telnet, netcat) to connect and get the prompt:

``` $ nc localhost 6000

help

Gateway Testing Center Commands: help - print this help exit - exit the console session command - dispatch a command into the system credentials - manage credentials storage device - simulate device in server database echo - echo arguments to output separated by space wait-queue - wait for new command answers ```

The TestingCenter allows to see some internals of the BeeeOn Gateway runtime. It provides a very basic help. The most important feature of the TestingCenter is the possibility to mimic the server. It allows to dispatch commands to the particular connected devices and receive results.

Pairing a device via TestingCenter

The BeeeOn Gateway implements the pairing process used in the BeeeOn system. The pairing process is used for all technologies regardless of their own pairing mechanisms. Some technologies may require a manual intervention with the particular devices (Jablotron, Z-Wave).

Pairing has always the two steps:

  1. Discover new devices (listen).
  2. Confirm devices to be paired (accept).

To pair a device using the TestingCenter, type the following commands into the TestingCenter prompt:

```

command listen 30

0x7F3CB0002030 PENDING 0/3

wait-queue

0x7F3CB0002030 DONE 3/3 SSS

device list-new

0xa300000000000003

command device-accept 0xa300000000000003

0x7F3CB0002CD0 PENDING 0/1

wait-queue

0x7F3CB0002CD0 DONE 1/1 S ```

First, the listen command has discovered there is a single available device with ID 0xa300000000000003. Note, that there were 3 Device Managers handling the listen command. Then, we accepted the device by sending accept command and waiting for the result. This time, only one Device Manager has responded.

A paired device would ship its measured sensor data to the Distributor component that would export it to the configured Exporters.

Device Manager

Each supported technology (Jablotron, Z-Wave, ...) is represented by a Device Manager. A Device Manager is usually a singleton class created once on startup. Its purpose is to translate the BeeeOn common interfaces to the specifics of the target technology. Each Device Manager is basically a thread (but no necessarily). It reacts to certain commands dispatched by the component CommandDispatcher. All such commands are asynchronous and can report the status of execution multiple times until finished. A Device Manager also ensures that the data delivered from the paired sensors are shipped into the Distributor component (and then exported out). Device Managers can also report technology-specific events via custom interfaces.

Configuration

The BeeeOn Gateway is configured at 2 levels of abstraction:

  1. user level - mostly INI files
  2. developer level - INI and XML files

The user level configuration can be found in the conf/gateway-startup.ini. To configure virtual sensors, see also conf/virtual-devices.ini.

The developer level configuration is made by files located in the conf/config.d directory. Those files are loaded automatically during startup and define how to startup the whole system. The main component that is created and build is called main and it is defined in the conf/config.d/factory.xml file. It denotes an instance of the LoopRunner class. Its purpose is to start all main application threads (internally called loops).

User level configuration

The user level configuration is divided into several sections according to the number of subsystems in the BeeeOn Gateway.

Core configuration entries
Credentials storage facility

The BeeeOn Gateway provides a credentials storage facility. Its purpose is to serve credentials to Device Managers to authenticate with its sensors properly. The credentials storage can persist the credentials with a certain level of security. The current implementation stores all credentials in an encrypted form.

TestingCenter configuration
Gateway Server connection

The GWServerConnector is a component of the BeeeOn Gateway. It provides connection to the remote server that allows users to control the BeeeOn Gateway and the connected devices.

Hotplug configuration

Some Device Managers depend on external hardware - USB dongles. To detect that a dongle is present or disconnected, a hotplug mechanism is used. The preferred hotplug implementation is the udev (via UDevMonitor). However, there is also the PipeHotplugMonitor, the second hotplug interface that is controlled via a named pipe from some external sources.

Exporters configuration
Belkin Wemo

The BeeeOn Gateway application is currently not capable of the initial setup of Belkin Wemo devices. This must be done via the official procedure usign the WeMo mobile application. After the initial setup, we have full control over all currently supported devices.

Bluetooth DBus HCI configuration
Bluetooth HCI statistics reporting

The BeeeOn Gateway can periodically report statistics of HCI interfaces via the internal C++ interface HciListener.

Bluetooth availability

The BeeeOn Gateway can scan the Bluetooth for availability of devices. When a device is available or unavailable, such event is distributed.

Vektiva Smarwi

Smarwi's initial set up by the BeeeOn Gateway application is not supported in the current version of the application. Configuration must be made by connecting to the access point created by Smarwi and fill in the correct credentials to the Wi-Fi network and specify the MQTT broker that Smarwi should connect to. Once Smarwi is on the same network as the BeeeOn Gateway application and is connected to the same broker as BeeeOn Gateway is connected to, the device can be controlled.

Jablotron
Virtual devices

For debugging and testing purposes, the BeeeOn Gateway contains a subsystem for creating virtual devices. Virtual devices are configured once before startup. Then they mimic real sensors or actuators.

Z-Wave

Thermona VPT

Air Pressure Sensor

Settings for the internal Air Pressure Sensor that is available on the original BeeeOn Gateway board. It can however be used for any pressure sensor available via sysfs.

Philips Hue
BLE Smart

IQRF

Sonoff

Sonoff's initial set up by the BeeeOn Gateway application is not supported in the current version of the application. Configuration must be made by connecting to the access point created by Sonoff device and fill in the correct credentials to the Wi-Fi network and specify the MQTT broker that Sonoff device should connect to. Once Sonoff device is on the same network as the BeeeOn Gateway application and is connected to the same broker as BeeeOn Gateway is connected to, the device can be controlled. In order for the BeeeOn Gateway to be able to retrieve data from Sonoff SC, it is necessary to upload the custom firmware available at https://github.com/xbedna62/SonoffSC_firmware.git to the Sonoff SC.

Conrad

Configuration of Conrad device support. It requires running FHEM server with correctly set up radio 868 MHz dongle which is named CUL_0 in FHEM.