Skip to content

Unable to connect again after an out of range #1036

@morgan-wild

Description

@morgan-wild

I'm trying to connect 2 ESP32 with NimBle and the Arduino Framework.

I use the latest version of NimBLE-Arduino 2.3.6

Globally it works very well, excepted one thing at the client side I described in this use case:

  • My client device finds the gatt server and connects without any problem.
  • If I turn off my server, the onDisconnect event is fired (normal) and my client restarts a scan.
  • If I turn on my server now, the client detects it and connect again (still normal).
  • If I move one of these devices out of the range, the onDisconnect event is fired (still normal).
  • But if I move back the device in the range, the client detects the server, try to connect but stay stucked.

There is no onConnect, onConnectFail or onDisconnect event fired.

If I don't touch the server and restart the client, everything is good again.

I used client->connect as the async way.

    _pClient->setClientCallbacks(new BluetoothClientCallbacks(this));
    _pClient->setConnectTimeout(5000);
    
    if (!_pClient->connect(true, true, false)) {

        NimBLEDevice::deleteClient(_pClient);

        Serial.println("Failed to start async connect");

        return false;
    }

    Serial.println("Connecting...");

There is something broken or smething special to know in this case?

16:37:42.018 > onScanDiscovered <- CLIENT STARTS
16:37:42.034 > onScanResult
16:37:42.034 > onScanDiscovered
16:37:42.051 > onScanResult
16:37:42.084 > onScanDiscovered
16:37:42.100 > onScanResult
16:37:42.100 > Advertised Device found:Name: GroundModule, Address: 30:c6:f7:c2:f5:3a, serviceUUID: 77777777-7777-7777-0006-000000000000
16:37:42.166 > Connecting...
16:37:42.461 > onConnect
16:37:44.118 > Discovered 3 services <- CLIENT CONNECTED AND LISTENING NOTIFICATIONS
16:37:44.410 > #000000 <-RECEVING SOME NOTIFICATIONS FROM A CHARACTERISTIC
16:37:52.710 > #FFFFFF
16:37:53.561 > #000000
16:37:54.660 > #000000
16:37:55.760 > #FFFFFF
16:37:56.610 > #000000
16:37:57.611 > #000000
16:38:46.374 > onDisconnected <- OUT OF RANGE STARTS HERE
16:38:46.400 > onScanDiscovered
16:38:46.400 > onScanResult
16:38:46.417 > onScanDiscovered
16:38:48.919 > onScanResult
16:38:49.410 > onScanDiscovered
16:38:49.919 > onScanDiscovered
16:38:49.919 > onScanResult
16:38:50.411 > onScanResult  <- COMING BACK HERE
16:38:50.411 > Advertised Device found:Name: GroundModule, Address: 30:c6:f7:c2:f5:3a, serviceUUID: 77777777-7777-7777-0006-000000000000
16:38:50.475 > Connecting...  <-STUCKED

```




Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions