Skip to content

Latest commit

 

History

History

ServerRpi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ServerRpi

Responsible for receivng data data from LocalRpi using MQTT. Stores data in database implemented using sqlite3. Receives data requests from MobileApp using MQTT then fetches data from database and sends it to MobileApp. Hosts mosquitto broker for MQTT. Implemented on RPI 4B board.

Database

Uses SQLite as a database engine. Database is directly created and handled from Rust code using rusqlite.

Table Diagram

image

MQTT

Is implemented using eclipse paho.mqtt.rust. Uses AsynClient for subscribing and publishing with help of tokio for rust asynchronous runtime. Subscribing and parsing messages is implemented using message callback. Mosquitto broker is being hosted directly on RPI.

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 curl git sqlite3 protobuf-compiler cmake libssl-dev mosquitto

2. Setup mosquitto broker

chmod 777 setup_mosquitto_broker.sh
sudo setup_mosquitto_broker.sh

3. Install rust

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

4. Build and run

RUST_LOG=info cargo run

Roadmap

  • Protobuf
  • Implement database
    • Implement CREATE TABLES for devices and lamp_data
    • Implement SELECT/INSERT requests for devices and lamp_data
    • Implement SELECT requests for lamp_data depending on device_name, timestamp
    • Unit tests for all free functions
  • Implement MQTT
    • Mosquitto broker
    • find and add MQTT library
    • Handler for some MQTT library
    • specify topics and payloads
    • Unit tests for all free functions
  • Integrate database with MQTT
  • update README