Skip to content

Latest commit

 

History

History
84 lines (57 loc) · 3.8 KB

README.md

File metadata and controls

84 lines (57 loc) · 3.8 KB

rusty-mqtt

A bridge between the MQTT broker of TTN and ThingsBoard in Rust built for the Internet of Things 19/20 course during the Engineering in Computer Science Master's Degree.

LinkedIn Profile

Leonardo Razovic

Assignment 1/2/3

Prerequisites

  1. Rust, you can install it using rustup
  2. A working instance of ThingsBoard
  3. A B-L072Z-LRWAN1 LoRa kit or an IoT-LAB Account
  4. An account on The Things Network

Usage

USAGE:
    rusty-mqtt [OPTIONS] --TTN-port <RPORT> --server <SERVER> --topic <TOPIC> --username <USER_NAME>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -k, --TTN-port <RPORT>        TTN MQTT server port [default: 1883]
    -s, --server <SERVER>         ThingsBoard MQTT server address [default: 0.0.0.0]
    -t, --topic <TOPIC>           TTN topic to subscribe
    -p, --port <TPORT>            ThingsBoard MQTT Server port [default: 1883]
    -r, --TTN-address <TTN>       TTN MQTT server address [default: eu1.thethings.network]
    -u, --username <USER_NAME>    ThingsBoard gateway device ACCESS_TOKEN

In the src folder you need a file credentials.rs containing the App ID and the App Access Key from the TTN Application Console. You can modify and rename the sample_credentials.rs file as reference. In the TTN Application Console we must specify a custom decoder function like:

function Decoder(bytes, port) {
  var result = "";
  for (var byte in bytes){
    result += String.fromCharCode(bytes[byte]);
  } 
  return {"result": result };
}

Example

cargo run --release -- -t "#" -u "A1_TEST_TOKEN" -r "eu1.cloud.thethings.network"

Usefull Links

Assignment 4

I developed an HTML5 application using the Generic Sensor API that collects data from the accelerator sensor of the mobile phone. A User Activity Recognition model is executed both on the device (Edge-based approach) and ThingsBoard (Cloud-based approach).

The application is hosted using GitHub Pages and it's available here. You simply need to enter a ThingsBoard Device Access Token and after pressing the start button data from the accelerometer is sent to ThingsBoard using the Telemetry Upload HTTP API.

Blog Posts

Assignment 1: The MQTT protocol using ThingsBoard, Rust and React

Assignment 2: How to setup an Async MQTT transparent bridge in Rust

Assignment 3: The LoRaWAN communication protocol using RIOT, ThingsBoard and Rust

Assignment 4: Generic Sensor API, Sensors For The Web!

YouTube Videos

Assignment 1: https://www.youtube.com/watch?v=6th-NgDjC1w&feature=youtu.be

Assignment 2: https://youtu.be/JiG8LkaZDtQ

Assignment 3: https://www.youtube.com/watch?v=bsJNijxUCw0

Assignment 4: https://www.youtube.com/watch?v=d5ZlM878lms