This framework includes all necessary tools and scripts to run Bluetooth Mesh experiments using BlueZ and TPy on Linux based nodes.
In order to support Bluetooth Mesh, some features of the Linux kernel have to be enabled, which are not part of the default configuration. These features are user-space interfaces for cryptographic functions:
- Cryptographic API
- "CMAC Support"
- "User-space interface for hash algorithm"
- "User-space interface for symmetric key cipher algorithms"
It is also necessary to compile BlueZ in order to in coorporate our changes.
The following commands install BlueZ with all dependencies on a current Debian Linux:
-
General dependencies apt-get install -y git bc libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev autoconf
-
jscon-c 0.13.1
wget https://github.com/json-c/json-c/archive/jason-c-0.13.1-20180305.tar.gz
tar -xvf json-c-0.13.1-20180305.tar.gz
cd json-c-0.13.1-20180305
./configure --prefix=/usr --disable-static
make -j 4 && make install
- Install ELL 0.17
wget https://mirrors.edge.kernel.org/pub/linux/libs/ell-0.17.tar.xz
tar -xvf ell-0.17.tar.xz
cd ell-0.17
./configure --prefix=/usr
make -j 4 && make install
- Install BlueZ
git clone --depth 1 --branch 5.50 https://github.com/bluez/bluez.git
cd pybluemesh
./bootstrap-configure
mkdir build
cd build
../configure --enable-mesh --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var
make -j 4 && make install
- Check if everything works. It should return version 5.50.
meshctl -v
Before a device can act as a node in a Bluetooth Mesh network, it has to be provisioned. Using our PyBlueMesh provisioning is done via configuration files that contain all necessary information. Including the network key, application keys, models and the application keys bound to them. The JSON format is used for the configuration files.
- Example file:
master_models = {
"1001" : 1, # OnOff client
"00e0d0f1" : 2 # Stats client
}
nodes_models = {
"1000" : 1, # OnOff server
"1001" : 1, # OnOff client
"00e0d0f0": 2 # Stats server
}
Using the provided provision.py script the necessary config files can be generated for all clients.
- Usage: provision.py [args]
Available options:
-h Show this help
-n n Add n nodes to the network (default 2)
-a n Add n additional appkeys to the network (default 0)
-p xxxx Set provisioner address. Must be 4 hex digits (default 0077)
-s xxxx Set first node address (default 0100)
-o dir Save JSON files in dir (default ./)
In order to run btmesh, we need to disable the bluetoothd daemon and start btmesh with the node specific configuration:
systemctl stop bluetoothd
btmesh --index 0 --config node0001.json
Afterwards a command prompt will appear, where we can manually send packets:
[btmesh]> onoff-send 0001 on
[btmesh]> onoff-send 0001 off
| URI | Description |
|---|---|
/mesh/api_test |
test if the API is running |
/mesh/log |
Returns the log output generated by BlueZ |
/mesh/onoff/client/<target>/<state> |
Send a message to node with state |
/mesh/onoff/server/state |
Returns the current state of the OnOff server |
/mesh/stats/data |
Returns all collected statistics data |
/mesh/stats/beacon/<target>/<ttl> |
Sends a beacon message to node with TTL |
- Lars Almon, Flor Álvarez, Laurenz Kamp, and Matthias Hollick. The King is Dead Long Live the King! Towards Systematic Performance Evaluation of Heterogeneous Bluetooth Mesh Networks in Real World Environments. In the proceedings of the 44th Conference on Local Computer Networks (LCN), Osnabrueck, Germany, 2019, pp. 389-397, https://doi.org/10.1109/LCN44214.2019.8990765
PyBlueMesh is licensed under the GNU General Public License v3.0. The license is found in the 'LICENSE' file.