8000 NimBLE Get stuck if pairing is not yet completed · Issue #972 · h2zero/NimBLE-Arduino · GitHub
[go: up one dir, main page]

Skip to content
8000

NimBLE Get stuck if pairing is not yet completed #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
icodk opened this issue May 27, 2025 · 1 comment
Open

NimBLE Get stuck if pairing is not yet completed #972

icodk opened this issue May 27, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@icodk
Copy link
icodk commented May 27, 2025

My program (esp32 Arduino IDE 2) kind of get stuck in the following scenario:
An ESP32 device is starting as a server and advertising until it is being connected by a central (host )
Upon connection estabishment, it retreives a client from the server object by calling:
pClient=pServer->getClient(pServer->getPeerInfo(0));
and acting as a dual role device.
and then use this client to retreive a charecteristic value from a service that the central is offering (CTS).
Specifically by calling
pSvc = pClient->getService("1805"); // CTS SErvice
and then
pChr = pSvc->getCharacteristic("2A2B"); //Current Time characteristic
and
NimBLEAttValue pv=pChr->readValue(pTime); // the actual value
All functioning butiffuly*

*However, in case the central is an IPhone or other IOS device (All IOS devices have a builtin CTS service),
if the devices are not paired/bonded the IOS device will not allow the value to be read.
The problem is that the call to NimBLEAttValue pv=pChr->readValue(pTime); never returned.
The rest of the BLE stack seems to function the Onconnect and OnDisconnect and start advertising if disconnecte.
Also the bonding being complete, but the main task (Arduino loop()) never get the chance to run again, and the device must be reset externally.

It all happend only on the first connetion because next time the bonding is already created.
I tested it with android device with CTS service running and it run as it should.
I also tested it with another chip (CC2340) and I just get en error if the bonding is not completed yet,
because of the IOS restriction.
I tried to check pChr->canRead()) as a guard but this returns true.
A workaround can be to check if the devices are bonded before reading the CTS. however an erro instead of getting stuck will be more elegant.
I also can use (not tested) the onAuthenticationComplete event to signal that the pairing is established.
Thanks for a great library and the dual role capability.

@h2zero
Copy link
Owner
h2zero commented May 27, 2025

Hmm, I haven't thought of this, There is no event handling for this case so the task isn't released. I will look into how to handle this.

@h2zero h2zero added the bug Something isn't working label May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
0