Skip to content

Latest commit

 

History

History

LocalRpi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

LocalRpi

Responsible for gathering data from LampControllers using BLE and sending it to ServerRpi via cellular network using LTE module. Data is send via MQTT protocol. After receiving the data from LampController LocalRpi adds current timestamp to data. Communication with LTE module is carried out with the help of the AT commands. Implemented on RPI 4B board.

BLE

Scans for surrounding devices and connects to them based on the Tx charasteristic name, gathers data from characteristics disconencts and looks for another device. Can also send data directly to devices Rx characteristics. Implemented using btleplug library with help of tokio library for rust asynchronous runtime.

Cellular MQTT

Uses A7670E LTE Cat-1 HAT for connecting to cellular network. LocalRpi communicates with Hat using AT commands to publish and subscribe to MQTT topics.

Protobuf

Protobuf files are generated during cargo build process and are put in target directory. For more information about generation process of proto files look at build.rs or rust-protobuf docs.

Getting started

1. Install dependencies

sudo apt-get install build-essential bluez bluetooth pi-bluetooth libbluetooth-dev protobuf-compiler curl

2. Install rust

curl https://sh.rustup.rs -sSf | sh

3.

4. Enable bluez for pi user

  • open bluetooth.conf file using text editor

    sudo nano /etc/dbus-1/system.d/bluetooth.conf
  • add following lines before </busconfig> tag

    <policy user="pi">
        <allow send_destination="org.bluez"/>
        <allow send_interface="org.bluez.Agent1"/>
        <allow send_interface="org.bluez.GattCharacteristic1"/>
        <allow send_interface="org.bluez.GattDescriptor1"/>
        <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
        <allow send_interface="org.freedesktop.DBus.Properties"/>
    </policy>

4. Build and run

RUST_LOG=info cargo run

5. Run tests (Optional)

cargo test