- It is a gateway between
XBee® ZigBee
andTCP
network forBUTLER
smart house framework. - Gateway extracts data from
XBee® ZigBee
frames and sends to theTCP
Server. - Gateway maintains separate
TCP
connection for eachXBee® ZigBee
device.
In default configuration/example:
- Gateway assumes that sensor uses MQTT protocol over
XBee® ZigBee
. MQTT
traffic is routed toTCP
socket of the configuredMQTT Broker
.Arduino
board is used as sensor (See example)
Usually microcontrollers like Arduino
doesn't have network stack.
If you use a MQTT
library to communicate with broker you still need network stack.
The only way to communicate with world is a Serial
. Serial
is simple and really popular.
A lot of RF modules do work via Serial
interface.
Unfortunately on other side you get Serial
as well in case of XBee® ZigBee
.
MQTT
broker doesn't support Serial
connection directly and we need to pack data from Serial
to TCP
:
Arduino
--> Serial
--> RF
<---z---> RF
--> Serial
--> xbee-gateway
--> TCP
--> MQTT Broker
- Connect
XBee® ZigBee Coordinator
to PC/RPi/etc where the application is installed. - Launch the application.
- Do not forget to power ON all nodes with
XBee® ZigBee
wireless interfaces.
- Install XCTU.
- Use
XCTU
for installing the firmware to theXBee®
devices. XBee® ZigBee
network must have only oneCoordinator
.XBee® ZigBee Coordinator
must be connected to thePC
were you plan to run the application.- All other devices in the network must be
XBee® ZigBee End Device
orXBee® ZigBee Router
.
- Coordinator must have the firmware with
ZigBee Coordinator API
functional set. - Use XCTU to set
AP
(API mode) option to 0x2 (escapes). - Use XCTU to set
BD
(Baud Rate) to57600
.
- Devices must have the firmware with
ZigBee End Device
orZigBee Router
functional set. - Use XCTU to set
PAN ID
. It must be equal with Coordinator. - Use XCTU to set
DH
andDL
to 0x0 (send data to Coordinator).
Install Cmake with version 3.0.2
or later.
Install the compiler with C++11
support.
Install Boost libraries with version 1.45
or later.
Install OpenSSL development libraries.
Install Jansson development libraries.
Download source code including submodules:
git clone <repository url> --recursive
- Create a
build directory
for out of source compilation:
mkdir <build directory>
- Go to the
build directory
:
cd <build directory>
- Use
Cmake
to prepare the build:
cmake <path to sources>
- Use
make
to start the build process:
make
- The resulting binary file is located in
<build directory>/bin/
- Create a
build directory
for out of source compilation:
mkdir <build directory>
- Go to the
build directory
:
cd <build directory>
- Use
cmake
to prepare the build:
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug <path to sources>
- Import the project from the
build directory
(File -> Import -> General -> Existing Projects into Workspace
) - Use
Project -> Build Project
to start the build process
- Pull pre built
Docker
image of the cross compiler :
docker pull monstrenyatko/rpi-cross-compiler
- Create a
build directory
for out of source compilation:
mkdir <build directory>
- Go to the
build directory
:
cd <build directory>
- Use script to build
deb
package:
<path to sources>/build/docker_raspberrypi/build.sh <path to sources>
- The resulting
deb
file is located in<build directory>
Configuration file is done in JSON format.
{
"logger":{
"level":"INFO"
},
"serial":{
"name":"/dev/usbserial",
"baud": 57600
},
"tcp":{
"address":"test.mosquitto.org",
"port": 1883
}
}
Application logger settings.
logger
Set verbose level.
Value | Description |
ERROR | Prints only errors |
WARN | ERROR level + warnings |
INFO | WARN level + processing information |
DEBUG | INFO level + debug information |
TRACE | DEBUG level + messages content |
Path to logfile like "/var/log/my.log"
.
Serial port settings.
serial
Path to serial port device like "/dev/usbserial"
.
Serial port baud rate like 57600
.
TCP
connection settings.
tcp
Server address like "test.mosquitto.org"
Server port like 1883
MQTT
protocol settings.
mqtt
Resets TCP
connection when CONNECT
message is detected.
Significantly improves establishing of the MQTT
connection when a client is not able to control TCP
connection.
When a MQTT
client is not able to perform authentication by its own, this option allows injecting of the JWT
authentication token to the CONNECT
message. The token is injected as user-name
in the CONNECT
message.
The behavior is compatible with mosquitto-auth-plug.
The JWT
token contains following claims:
Claim | Type | Description |
user | String | The client XBee MAC address in HEX format |
exp | Number | Expiration time on or after which the token must not be accepted (See RFC 7519) in the Epoch or Unix time-stamp format |
Additionally, the TCP
connection will be reset on JWT
expiration to force client to re-send
the CONNECT
message and trigger the generation of the fresh JWT
.
Recommended to enable XBee® ZigBee
protocol level encryption to avoid malicious devices.
JWT
generation settings.
jwt
Number of seconds after which the token must not be accepted.
The secret key
value used to sign the token.
The path to file with secret key
value. Retrieved value overrides the key
option value when provided.