This project allows the built-in BLE module and one plugged-in BLE module to cooperate on Raspberry Pi 3 model B. With this project and two BLE modules, multiple Pi 3s can form a BLE tree network. There are four main processes in this project: Master Agent (gatttool.c), Slave Agent (main_v2.js & characteristic_v2.js), Scan Center (server_scan.py) and Sensor Center (sensorCenter.cpp).
Install bleno first. Note that bluetoothd
should be disabled as the document of bleno
describes.
- Clone this repository under the directory
/home/pi/Documents
. - Clone bleno repository under this directory (
/home/pi/Documents/BLE
). - Change the directory.
cd ./centers
- Compile and build
sensorCenter
.
make
- Change the directory.
cd ../bluez-5.43/attrib
- Compile and build
gatttool
.
make
- Finally, go back to the home directory of this repository.
cd ../../
Before running the project, a setting file should be named info.txt
and put in /home/pi/Documents
. Proper setting file can be referred to info_example.txt.
Before running the project, the plugged-in BLE module must be reset every time after the Pi 3 is turned on. Use:
sudo bash centers/reset.sh
If the terminal shows
bleno - echo
on -> stateChange: poweredOn
on -> advertisingStart: success
then the process of reseting is complete.
Press Ctrl
+ c
to exit.
Use:
sudo bash run_v2.sh
To stop the project, press Ctrl
+ c
first to stop the foreground process first and type
sudo bash stop.sh
in terminal.
To allow a user device to interact with the BLE network, please download the Android Studio project and build it on a Android phone. After the app is built, simply execute it and the device will be connected to the BLE network automatically.