diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index bdf1253..ee9789a 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -227,6 +227,11 @@ void NimBLEAdvertising::start() { if(pServer != nullptr) { if(!pServer->m_gattsStarted){ pServer->start(); + // When the server instance is created it resets GATT which + // seems to put the controller in a sleep loop? This causes a delay when + // advertising is started the first time. To avoid this we call ble_gap_adv_stop + // to get the controller ready. + ble_gap_adv_stop(); } else if(pServer->getConnectedCount() >= NIMBLE_MAX_CONNECTIONS) { NIMBLE_LOGW(LOG_TAG, "Max connections reached - not advertising"); return;