- 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
(http://mqtt.org) protocol overXBee® ZigBee
. MQTT
traffic is routed toTCP
socket of the configuredMQTT Broker
.Arduino
board is used as sensor (See https://github.com/monstrenyatko/butler-arduino-sensor)
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 where the application is installed. - Launch the application.
- Do not forget to power ON all nodes with
XBee® ZigBee
wireless interfaces.
- Install
XCTU
(http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/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
(http://www.cmake.org) with version 2.8
or later.
Install the compiler with C++11
support.
Install Boost
(http://www.boost.org) library with version 1.45
or later.
- Create a
build directory
for out of source compilation:
mkdir build
- Go to the
build directory
:
cd build
- 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
- Go to the
build directory
:
cd build
- 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
- Download or build your own
GCC
based toolchain forARM Linux
with hardware floating point support.
See http://crosstool-ng.org - Install all dependencies to the toolchain
rootfs
.
A lot of prebuilt libraries are available on official repository (http://archive.raspbian.org/raspbian). Just unpack files torootfs
. - Create a
build directory
for out of source compilation:
mkdir build
- Go to the
build directory
:
cd build
- Configure environment:
export RASPBERRY_PI_TOOLCHAIN_PREFIX=arm-raspberry-linux-gnueabihf-
export RASPBERRY_PI_TOOLCHAIN=$HOME/raspberrypi/toolchain
export RASPBERRY_PI_ROOTFS=$HOME/raspberrypi/rootfs
- Use
Cmake
to prepare the build:
cmake -D CMAKE_TOOLCHAIN_FILE=build/cmake/Toolchain/raspberrypi.cmake -D CMAKE_BUILD_TYPE=Release \
-D PACKAGE_SYSTEM_NAME=raspbian <path to sources>
- Use
make
to start the build process:
make
- The resulting binary file is located in
<build directory>/bin/
- Use
make
to builddeb
package:
make package
- The resulting
deb
file is located in<build directory>
Configuration file is done in JSON
(http://www.json.org) format.
######Example:
{
"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 |
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