Skip to content
Emanuele Giacomini edited this page Jan 3, 2020 · 4 revisions

BE-Mesh ESP32

In this project, you will see an implementation of the BE-MESH paradigm for BLE mesh networks presented the last year.

The protocol relies on the top layer of the BLE stack, composed by the GAP (Generic Access Profile) and the GATT (Generic Attribute Profile). Briefly, we will understand how GAP/GATT profiles work:

GAP

The GAP protocol handles the connection mechanisms between devices, of which we can distinguish 4 roles (however only 2 are used now):

  • Peripheral: Device that advertises its presence to neighbour devices
  • Central: Device that scans for advertisements, and initiate connections with other devices.

GATT

The GATT protocol handles data exchange between devices. Here we can define two additional roles:

  • Server: Exposes data through the use of a Service Table, cannot directly send data to clients, however, it can notify them about changes on the Service table
  • Client: Can execute write/read operations on the Server.

Notice that these roles are not exclusive, hence a device can be concurrently a Client and a Server.

Be-Mesh protocol

The purpose of Be-Mesh is to provide the tools to establish a dynamic scatter-net across multiple BLE devices (Both Android smartphones and ESP32 nodes). The protocol should be able to recover from losses in order to maintain the biggest possible network.

Two roles are defined in the protocol:

  • Server
    • Peripheral (GAP)
    • Server/Client (GATT)
    • Establish at most 7 connections with other devices
  • Client
    • Central (GAP)
    • Client (GATT)
    • Establish a connection with a single server device.

TODO: Insert Be-Mesh issues and solutions

User Guide

What you need

The project relies on the ExpressIf ESP toolchain. You can follow their installation guide here

Cloning the repo

First step is to clone the repository in the home directory, or inside your default workspace directory

git clone https://github.com/BE-Mesh/esp32-ble-mesh.git

Building

In order to build the project, we need to launch idf.py build routine inside the project directory.

In Linux Terminal

cd esp32-ble-mesh/
idf.py build

Flashing Firmware

If the build was succesful, you should see on the terminal the following text

Project build complete. To flash, run this command:
../../esp/esp-idf/components/esptool_py/esptool/esptool.py -p (PORT) -b 460800 --after hard_reset 
write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000
build/partition_table/partition-table.bin 0x10000 build/esp32_ble_mesh.bin
or run 'idf.py -p (PORT) flash'

Usually the ESP gets mapped by a Linux OS into the /dev/ttyUSB0 port, therefore the next command you should type is the following

idf.py -p /dev/ttyUSB0 flash

You should see the script trying to connect with the ESP32 module.