BLE reconnect after light sleep takes too long (XIAO ESP32C3)

I might be misunderstanding somethings.

After looking at the interval and latency descriptions I was very excited because it looked like I was thinking about it all wrong.

My initial idea was to optimize how fast my device reconnects however the definition of latency gave me the idea that the actual trick is to make the client device think that the connection didn’t dropped/end at all.

Thus I’m now requesting a connection parameter update from the client like this

void BLEStatus::onConnect(NimBLEServer* pServer, ble_gap_conn_desc* desc) {
    Serial.println("onConnect");
    size_t numClients = NimBLEDevice::getClientListSize();
    if (numClients > 0) {
        std::list<NimBLEClient*>* clientList = NimBLEDevice::getClientList();
        for (auto it = clientList->begin(); it != clientList->end(); it++) {
            if ((*it)->isConnected()) {
                // pServer->updateConnParams((*it)->getConnId(), 16, 24, 18000, 65535);
                (*it)->updateConnParams(16, 24, 18000, 65535);
            }
        }
    }
}

According to the number’s I have used

  • 16*1.25 = 20 ms min communication interval.
  • 24*1.25 = 30 ms max communication interval.
  • 18000 * 20 = 6 minutes minimum and 18000 * 30 = 9 minutes maximum time until client can say that the connection is no more active.
  • 65535*10 = 10.9 minutes until the connection is considered completely shut off.

So I assumed, unless I’m sleeping more than 6 minutes (let’s say a timer wakes the device up and sends a packet every 3-4 minutes), whenever I wakeup the connection should be instant.

However this is not what I see. Even If I wake up instantly after sleep, the whole connection will be reset and the process will start from scratch which takes 5 seconds all-in-all to reconnect.

Any ideas?