Skip to content

Commit ae3be89

Browse files
committed
Fix delayed advertising when first called.
1 parent c262749 commit ae3be89

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/NimBLEAdvertising.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ void NimBLEAdvertising::start() {
227227
if(pServer != nullptr) {
228228
if(!pServer->m_gattsStarted){
229229
pServer->start();
230+
// When the server instance is created it resets GATT which
231+
// seems to put the controller in a sleep loop? This causes a delay when
232+
// advertising is started the first time. To avoid this we call ble_gap_adv_stop
233+
// to get the controller ready.
234+
ble_gap_adv_stop();
230235
} else if(pServer->getConnectedCount() >= NIMBLE_MAX_CONNECTIONS) {
231236
NIMBLE_LOGW(LOG_TAG, "Max connections reached - not advertising");
232237
return;

0 commit comments

Comments
 (0)