Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ NimBLEServer* NimBLEDevice::m_pServer = nullptr;
#endif
uint32_t NimBLEDevice::m_passkey = 123456;
bool NimBLEDevice::m_synced = false;
SemaphoreHandle_t m_synced_sem = xSemaphoreCreateBinary();
#if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
# if CONFIG_BT_NIMBLE_EXT_ADV
NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
Expand Down Expand Up @@ -807,6 +808,7 @@ void NimBLEDevice::onSync(void)
taskYIELD();

m_synced = true;
xSemaphoreGive(m_synced_sem);

if(initialized) {
#if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
Expand Down Expand Up @@ -906,6 +908,7 @@ void NimBLEDevice::init(const std::string &deviceName) {
}

// Wait for host and controller to sync before returning and accepting new tasks
xSemaphoreTake(m_synced_sem, portMAX_DELAY);
while(!m_synced){
taskYIELD();
}
Expand Down