Fix delayed advertising when first called.

This commit is contained in:
h2zero 2020-09-02 12:05:05 -06:00
parent bd0c7992ef
commit 26b3ba3e8f

View file

@ -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;