BLE device not disconnecting - bluetooth-lowenergy

I am working with BLE devices. and using nrf controller with bluez 5.4 code.
I am customizing gatttool source code so that multiple devices can connect and disconnect.
My focus part for now is how to disconnect ble device using gatttool apis.
I had found one solution in code that we can use:
g_io_channel_shutdown();
g_io_channel_unref();
These 2 APIs are use to disconnect ble device.
I am using nrf connect application in my mobile to connect generate dummy ble device so that I can perform operations.
When I use this for disconnecting device any other formalities are needed in between or only these APIs are ok?
I am not able to disconnect using these APIs.Some time it is give effect and some time it is not working.
If any one have idea abut this please respond.
Thanks in advance.

Do you mean Bluez 5.4 or Bluez 5.40? Either way, they are quite old releases.
gatttool is one of the BlueZ tools that has been deprecated in BlueZ.
Ideally you would be using the BlueZ DBus API to interact with BlueZ.
Not sure if you are creating a GATT Server (peripheral device) or GATT client (Central Device) but there are examples of both in the BlueZ source:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-server
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-client
These examples are in Python, but most languages have DBus libraries to help access the API which are documented at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/device-api.txt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt

Related

Re-enable Bluez advertising after connection, through d-bus interface

I have a BLE Gatt server, which is setup using the d-bus bluez interface (version 5.54).
Advertising is working using org.bluez.LEAdvertisingManager1 and can be viewed using a BLE scanner Android app.
Making a connection to the server stops the device from advertising, and it is no longer visible on a BLE scanner.
Disconnecting doesn't start advertising again.
I've seen the same issue described here, with a solution using hcitool commands.
Is there a way to re-enable advertising using the d-bus interface only?

Why use mqtt server for BLE gateway?

I have a BLE temperature sensor, which should send measurements to an ESP32 via a BLE connection and my plan was that the ESP32 could send the measurements via WiFi to my database (Firebase Realtime Database). However, I have seen from a few tutorials that a mqtt server would be neccesary (see the screenshot below - link to the video: https://www.youtube.com/watch?v=PBYCG-ypvRY). Could someone please explain to me why the mqtt component is neccesary? Currently I am measuring temperatures using my ESP32 (without the BLE temperautre sensors) and sending them directly to the database, so I am confused as to why with BLE I would need a mqtt server.
Thanks for your help in advance!
You don't need MQTT. It's just one of the IoT-friendly protocol alternatives (like HTTPS, AMQP, CoAP, homebrew, etc) available to you for device-to-server communication. There are pros and cons to each one. It's up to you to choose whatever solution is relevant to your system.
If you've already implemented the Firebase HTTPS interface and it does the job, you're done.
If you are having problems, note that the Google IoT Core also prescribes MQTT (or, alternatively HTTPS) as an underlying messaging protocol - used together with the Device SDK for Embedded C. But this is for people who want to have a large-scale authentication and management solution for their devices. By all means, stick to your existing solution if it works.

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.

Create the Pairing limitation on HC-05 sensor

I have been trying to set the limit of pairing the Bluetooth device HC-05(interface by Arduino controller) with my smartphone.
I have tried making this solution work with AT command
AT+INQM=<Param>,<Param2>,<Param3>
Example: AT+INQM=1,9,48\r\n
But instead of converting AT commands using serial.h with embedded C, I am looking for any dedicated library which helps to work this kind solution in using Arduino.
Basically, with the help of Bluetooth device connect to Arduino Nano, I want to send the altimeter sensor data to my smartphone.
During the connection, HC-05 should be responding any one device at a time, if another smartphone tries to pair then the error will be shown.
Please share your advice on this.
Yes there are some libraries in arduino but these are only meant for connection and pairing and low energy connections. We don't have any dedicated library from where we can control the mode of operation of HC05 or any bluetooth module. like bypassing or accessing GAP and GATT services of bluetooth. However there is a way to flash HC-05. But we can only use it for updating the firmware of this device. This github repo is dedicated for this purpose . Hope it helps you

Testing Microchip RN4871 BLE Module with Raspberry Pi 3

I got a Microchip RN4871 BLE Module and want it to act as beacon.
So, I connected over UART and executed the following commands:
SS,20
SC,2
NB,09,656667
I am able to scan and connect to it using hcitool and gattool command. Now I want to verify whether the beacon functionality is working or not. I mean the device is periodically broadcasting Beacon packets or not..
How can I verify that.. Is there any android application which can help or can i do with raspberry pi 3 as it has in built Bluetooth Chip
There are some really nice apps from nordic for free available. I like the nrF connect app. I guess it will help you.

Resources