Code Monkey home page Code Monkey logo

mqttoble's Introduction

MQTToBLE

This repo contains a set of tools that you can use to set up a simple, scalable, MQTT over BLE implementation.

WARNING: This is not in a usable state yet!

Getting Started

On a PC:

  • Install an MQTT server at the default port on localhost
  • Install node.js and npm
  • cd nodejs_bridge;nodejs index.js
  • cd nodejs_server;nodejs index.js
  • Connect to an Espruino device and upload espruino_node

How it works

You have 3 main components:

  • MQTToBLE nodes - low power Bluetooth LE devices that want to use MQTT
  • MQTToBLE bridge - powered Bluetooth LE devices with internet connections. These communicate with MQTToBLE nodes and connect to a MQTToBLE server
  • MQTToBLE server - a server with an internet connection. This controls everything, choosing the nearest MQTToBLE bridge and telling it to connect to a MQTToBLE node

Note: The directories within this repo are for implementations of components for different platforms.

Summary:

  • Each MQTToBLE node implements the MQTT protocol, and then uses BLE to transport the MQTT datastream.
  • A MQTToBLE node spends 99% of its time as a normal BLE advertiser.
  • An MQTToBLE bridge will connect to a MQTToBLE node when there is data to be sent to is or the MQTToBLE node advertises that it has data it needs to send. The bridge will then disconnect after a short period of inactivity.

Each MQTToBLE node advertises the following 128 bit Service UUIDs:

  • ac910000-43be-801f-3ffc-65d26351c312 - Implements MQTToBLE, but no data to send
  • ac910001-43be-801f-3ffc-65d26351c312 - Implements MQTToBLE, there is data ready to send

Each MQTToBLE node also has the following BLE service and characteristics (much like Nordic UART):

  • Service ac910001-43be-801f-3ffc-65d26351c312
  • TX Characteristic ac910002-43be-801f-3ffc-65d26351c312 - from bridge TO node
  • RX Characteristic ac910003-43be-801f-3ffc-65d26351c312 - from node TO bridge

Security

Currently this is not implemented, however:

  • An MQTToBLE bridge could bond with every device it connects to
  • A PIN could be added to MQTToBLE nodes and the MQTToBLE server could be made aware of the PINs of all enrolled devices.

Bridge -> Server comms

These are also done over MQTT:

  • Each bridge has a name
  • MQTToBLE/{bridgename}/advertise {addr:str, rssi:int, dataReady:bool} is sent from the bridge for each advertisement received
  • To connect, server sends MQTToBLE/{bridgename}/tx {addr:str, data:[...]} to the bridge, which can contain empty ([]) data. Data to be sent must be chunked into 20 byte chunks already by the server.
  • When data is received, the bridge sends MQTToBLE/{bridgename}/rx {addr:str, data:[...]} to the server with any received data packets

TODO

Nodes

  • More node implementations. ESP32 Arduino, nRF51/2 C code

Bridges

  • More testing/hardening of ESP32 implementation
  • Report back TX complete/fail
  • Some kind of configuration other than the .h file (HTTP server?) so one binary can be used on multiple devices

Server

  • Handle TX complete/fail messages
  • Keep track of whether a bridge is busy and don't send it more data if it is

mqttoble's People

Contributors

gfwilliams avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.