BLE disconnects after BT pairing failed - qt

Linux Raspbian Jessie Lite, Bluez 5.40.
I have a GATT server and my own agent for incoming "standard" bluetooth connections (i.e. A2DP).
I can successfully "connect" to the GATT server, but if the user doesn't accept the pairing confirmation (from the BT) I receive this error:
qt.bluetooth.bluez: Failed to create pairing "org.freedesktop.DBus.Error.NoReply"
as expected, but after a couple of seconds also the BLE connection will drop.
I wonder if it's the correct behavior. I thought the BLE and BT connections are indipendent each other.

If you are using two Bluetooth smart ready device(BR/EDR/LE), then the BLE connection would be over BR/EDR, so it is make sense that your BLE also disconnected.

Related

BLE: What could cause BLE connection establishment to fail

I am trying to implement a Bluetooth Low Energy Host on a system with SAM E54 with FreeRTOS. The bluetooth stack I am using is Nimble (Mynewt-NimBLE from Apache). I am trying to connect the SAM E54 to a nRF52840 Dongle (driven with nRF Connect Desktop application).
When I set my device as Central (as a 4.x device, with no 5.x capabilities), the device can connect to another device without error.
But when I switch on the 5.x capabilities, (basically by changing a define's value and calling another API function), and try to connect to the same peripheral, it fails 9 out of 10 times, triggering a "connection supervisor timeout" on both the server and the client.
I tried changing the supervisor timeout value, but it won't fix the problems. When a connection is bound to be successful, the central's information is displayed immediately on nRF Connect. When connection establishment is going to fail, I know it right away (before the connection supervisor timeout is triggered) because no information about the central is displayed on nRF Connect.
Once the connection is established, it can stay on for hours, so I don't think this is an RF noise issue.
I know NimBLE is not initially designed for SAM E54 and FreeRTOS, and surely the problem comes from a wrong implementation or configuration of the stack. But right now I feel like I've tested everything, and I don't know where to dig for solutions.
The actual questions are :
To start a connection using 4.x BLE capabilities, some HCI commands packets are sent. Should these packets be any different than the packets sent when I enable the 5.x capabilities ? In both cases, I am connecting to a 4.x device.
What step of the connection establishment process fails when both server & client "think' they are connected, yet don't exchange information?

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.

ESP8266 connection to a Arduino Nano

I am trying to connect a WiFi module (ESP8266) to a "funduino" development board (Arduino Nano) but I have no success. Since I tried so much schematics I've found on the internet about the connection between them two, I kindly ask here if is anyone who succeed in "pairing" this two devices.
I am asking for the schematic and a functional source code.
Regards
The ESP-01 by default comes with nonOS SDK bootloader that communicated via AT commands, you can find the complete command set from Expressif here. This is designed for an MCU (like Arduino Nano) to use it purely as an WiFi module rather than using it as a stand-alone MCU (for which it will require NodeMCU SDK).
If you ever upload an Arduino sketch up to the ESP-01, it will erase the AT Command firmware.
Assuming your ESP-01 is still having the AT Command firmware. What #Ben provided is a sketch that allows you to type AT commands via the Serial Monitor to internact with the ESP-01, it is manual, and good for testing if ESP-01 is working (you type AT and press return on Serial Monitor, the ESP-01 will ack with Ok) but not practical as a real application. The minimum commands required to established an WiFi connection with ESP-01 is listed below.
AT+CIPMUX=1 - Enable single (0) or multiple connection (1) to the web server.
Multiple connection is a good option if you are repeatedly sending
out or reading data from the Internet.
AT+CWMODE=3 - Set WiFi mode: 1 is station mode (ESP8266 is client), 2 is AP mode
(ESP8266 acts like a WiFi router where your phone or PC can connect),
3 is AP+station mode (make the ESP8266 do both)
AT+CWJAP=“<your-ssid>”,”<your-pw>” - Connect to your WiFi. Provide your SSID name
and password inside the double qoutes.
AT+CIFSR - This returns the IP address of the module, indicating that it has
successfully connected to your WiFi router.
Once the WiFi connection is established, you can further communicate with the ESP-01 via the connection, like accessing a website for example:
AT+CIPSTART=0,"TCP", "www.example.com","80” - Start TCP or UDP connection. The
0 is the id of the connection.
AT+CIPSEND=0,16 - Command to tell the module data is ready to be sent. 0 is the
connection id, and 16 is the length of the data to be sent.
After this command, the ESP8266 will reply with the “>”
character to tell us that it will be waiting for the data to be
sent. If successful, the module will reply with “SEND OK”
GET / HTTP/1.1 - Send the http header, and other data, etc...
You can write your own sketch to automate those AT commands for interacting with with ESP-01 once you understand the AT commands required for establish a WiFi connection.
Here are two resources that I personally found extremely useful for doing more than connecting to WiFi.
STM32-ESP-01 Web Server - although this is for interfacing with STM32, the main difference is the pin assignment, so you should be able to port to Arduino easily.
MQTT via ESP-01
As for hardware interface, please noted that what #Ben provided is correct in principle, but you need to be aware that the ESP-01(ESP8266 to be precise) is a 3V3 MCU, so the connection is depended on what kind of host board you are using. If you are using Arduino Uno/Nano, both are having a 5V MCU, you will need a voltage divider (two resistors to drop the voltage to 3v3 before connecting to ESP-01) or a level shifter chip at least for the ESP-01 Rx pin to avoid the potential damage to the ESP-01.

Is running HM10 on a soft-serial enable the Low Energy charecteristics ? If so, how can the UUIDs and GATT profiles be tweaked in this case ?

I've been tinkering with the HM-10 board for a few weeks now, trying to push data from phone to module and vice-versa. The ultimate goal was to enable the BLE mode and tweak with the characteristics and GATT profiles. I'm pretty new to this domain so can anyone help me out ?
And is there any way we can interface the HM-10 with the hardware rx-tx channel instead of soft-serial ?
Your question is still not very clear, but i think you mean sending AT-commands over BLE-radio.
To make this possible you have to change the MODE using serial connection.
In standard mode the device can only be configured over the serial connection (pins RXD and TXD) using AT commands.
AT+MODE0: It only accepts AT-commands over the serial connection (RXD/TXD)
until a central device connects to the module.
AT+MODE1: Same as MODE0, once a connection is established,
AT-commands can be sent over BLE and manipulate some PIO pins on
the device.
AT+MODE2: Same as MODE0, once a connection is established,
AT-commands can be sent over BLE.
To test it just send a string to hm-10 as "AT\r\n" and it will respond with OK.
Update:
You cannot change the services and characteristics with AT-commands.
There are a lot of other things you can change,like advertising, setup a beacon and change a lot of settings.
For a full list of AT commands and more see the official data sheet:
http://www.jnhuamao.cn/bluetooth41_en.zip

Can a peripheral can be connected to multiple centrals?

From this book it says
A peripheral can be connected to multiple centrals.
can any BLE module do this? More specifically can bluegiga 112 do it? If not what are the BLE modules that can work as a peripheral connected to multiple devices?
The same book also states
Once the connection is established, the peripheral stops advertising and the two devices can begin exchanging data in both directions
so if the peripheral stops advertising how will it accept more connections as mentioned above? How will other scanners detect this peripheral?
Tim Tisdall is correct. That solution works for specification 4.1, but not for 4.0. As you mentioned above, you cannot establish a connection with a device that is not discoverable, and since it stops advertising upon connection establishment, it is impossible to have a peripheral connected to multiple centrals.
Any peripheral BLE device can "broadcast" it's attributes/characteristic values in GATT profile. So, any central device interested in the value can potentially "connect" to the BLE peripheral to get that broadcast message. So, that's what i believe is a use case for "A peripheral can be connected to multiple centrals."
I don't think the peripheral stops advertising it's presence just because it's connected to a certain central device. Any device can still see it's presence when it does a scan.

Resources