How can I add custom BLE GATT services to an ESP BLE MESH node? - bluetooth-lowenergy

I am currently trying to add BLE GATT services to an ESP32 which is part of a BLE mesh network. I am currently using NimBLE as the stack in an ESP-IDF project.
The confusing part is because the GATT server initialization is handled internally in the code when initializing the BLE MESH node. Hence, I do not have the handle to the GATT server to add or modify the services and characteristics it is advertising.
Can somebody point me in the right direction please?

Related

Can a single BLE module be connected to a mesh and have a point-to-point connection?

I want to know if it's possible to use a BLE module for both mesh networking and point-to-point connections at the same time.
Rationale:
The embedded linux (EL) product that I am designing needs to be able to connect to BLE peripherals like a heart rate monitor (sports grade, not medical) and the product needs to communicate with others of its kind.
I also need a very low power way of sending data from all EL devices to the internet. Ideally with only one of the products supplying a connection to the internet.
I am open to other solutions or reasons why this might not be a good approach even if it's possible.
Here is a rough block diagram of what I'm trying to achieve:
The block diagram does not show a HR connected to every EL device, however this would be a possibility as well.
Green = Embedded Linux Devices
Red = Heart Rate Monitors
Blue = An internet connection to the cloud
Yellow = connections between Embedded Devices
Option 1 - WiFi
The first option I considered was a wifi connection between the EL devices, however this will consume much more power than BLE.
Option 2 - BLE mesh
Using a BLE mesh seems like the best solution, if and only if, it's possible to do point-to-point connection at the same time.
Yes, this behaviour is specified in the BLE Mesh Profile specification in chapter 2.3.11. What you are looking for is a Proxy Node:
Proxy feature – the ability to receive and retransmit mesh messages between GATT and
advertising bearers.
Also take a look at the Ultimate Mesh Tutorial where they also describe the proxy node:
To allow communication with a mesh network from a non-mesh-supported BLE device, a special type of node called a proxy node can be utilized. A proxy node acts as an intermediary and utilizes GATT operations to allow other nodes outside of the mesh network to interface and interact with the network.
The protocol used in this case is called the proxy protocol, which is intended to be used with a connection-enabled device (using GATT).
This is of course hardware and software dependent. Not every hardware or software stack supports BLE mesh functionality.
The wikipedia article for Bluetooth mesh networking has a list of currently availible software stack supporting BLE mesh.

Implementing DTLS handshake for the Bluetooth low energy devices

I am trying to implement a DTLS handshake between two BLE devices. For this, I wanted to use the L2CAP channel of the BLE to communicate with the messages coming from the DTLS. Basically, I want to open a DTLS tunnel with the help of L2CAP from the BLE stack. I am using the mbedTLS library for this. From the documentation of MbedTLS (https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS), I understood that I need to set the mbed_tls_ssl_set_bio() function which has the read and write call back functions that communicates with the BLE top layers(L2CAP). I am using the dialog's DA14695 dongles for the implementation. I am not very sure about the read and write call back functions that needs to be written to communicate with the L2CAP channel of the BLE. Somebody experienced with opening a TLS/DTLS tunnel with the BLE top layers can help.
Thanks in advance

Raspberry Pi3 BLE only accepts a single connection

I have created a BLE peripheral that exposes a GATT service. It uses BlueZ 5.50, but it seems that only one device can connect to the GATT service. When the device is connected, then other devices can't see it anymore. It's not showing up in a scan anymore and if it was already scanned, then I can't connect to it anymore.
It seems to be a limitation or configuration issue in BlueZ, because when using the Paypal GATT library it can handle multiple connections. As far as I know, the RPi3 BLE chip should be able to handle up to 10 connections.
Does anyone know if this can be done using BlueZ?
The Paypal GATT library directly connects to the HCI device and bypasses most of the kernel stuff. BlueZ depends on kernel drivers and user-space applications and is capable if the driver reports that the controller allows multiple connections. You need a decent BLE controller and a recent kernel to make it work.
More information can be found in https://github.com/bluez/bluez/issues/12.

Kickstart for BLE CC2541 programming [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to firmware programming and I need to program BLE CC2541. Where should I start as a beginner to understand the codes and alter it that I already have.
While this question is likely to get closed as "Too Broad", I think I would make an attempt to get you started.
I hope you plan to go through documentation provided by TI guys. (CC2541 is Texas Instruments product)
While that document will explain how CC2541 works, you still need to know how BLE works and how it is implemented.
Its different than classic Bluetooth that BLE (generally) is preferred to communicate by means of service/s (with characterstic/s bundled up into them), be them Standard or Custom. Depending upon your area of application you can select one of the standard services implementation.
For more info on services, check Bluetooth Developer Portal
I guess, if you really want to have a good start at it, then understand these terms and their fundamentals:
Master device in BLE (Assuming that you know this already)
Slave device in BLE (Assuming that you know this already)
GATT Profile
GATT Database
GATT Client
GATT Server
Just to get you started:
GATT Profile:
BLE allows you to send data over to the other device after establishing the BLE communication link, only via a defined way, called GATT Profile. Many a people refer the same as GATT Protocol. The data is transferred through characteristics which are bundled into services. There can be multiple services defined within the device and a service can be either the standard one or the custom service defined by a GATT developer.
GATT Database
The structure of definitions of these services is known as the GATT Database. Where does this reside? Is the structure known to the Master as well as Slave?
GATT Server
The BLE device which holds this GATT structure is a GATT Server, in your case the hardware having that CC2541 chip. The way GATT is to be developed and the chip is programmed with it, is entirely manufacturer dependent.
GATT Client
Usually a BLE-enabled smartphone or Gateway device is the GATT client.
The GATT structure, more technically, the UUIDs of the services and the characteristics are shared between GATT Server and GATT Client. That is how BLE works, that is how a smartphone application reads a particular service from the BLE device.
Apart from this you need to know about GAP Service which handles the connection related things.
Welcome to StackOverflow! Coding is easy only if you know the concept well.
May be you would want to see this question: Getting no response whatsoever for similar reason.

Programming a BLE Beacon to connect with server

I am developing a solution where, Fixed BLE beacon detects a moving BLE device and sends the relevant data to the server using wifi/ethernet/etc. All the examples I have found have BLE beacons talking to the mobile phone which in my case isnt true. AFIK an embedded systems engineer can configure the fixed beacon to send data to server. BUT is there any ready to use solution that lets the beacon connect to backend? Thanks.
You mention having a "[f]ixed BLE beacon [detect] a moving BLE device". Understand that this is very different from the way an Apple-style BLE iBeacon works, which is a transmit only device. (I mention this because the question is tagged with ibeacon.)
What you are describing is probably better described as either a beacon scanner or a BLE scanner. My company has a Raspberry Pi-based product that can scan for beacons and take programmatic action based on detections. We have a blog post about how to make a beacon turn on a lamp using this device, but you could just as easily make it contact a server when a BLE device is detected.

Resources