+
+ // Check if any device is discovered.
+ if (NULL == g_edrDeviceList)
+ {
+ // Wait for BT devices to be discovered.
+
+ // Number of times to wait for discovery to complete.
+ int const RETRIES = 5;
+
+ uint64_t const TIMEOUT = 2 * MICROSECS_PER_SEC; // Microseconds
+
+ bool devicesDiscovered = false;
+ for (size_t i = 0; NULL == g_edrDeviceList && i < RETRIES && !g_isStopping;
+ ++i)
+ {
+ if (ca_cond_wait_for(g_deviceDescCond, g_edrDeviceListMutex,
+ TIMEOUT) == 0)
+ {
+ devicesDiscovered = true;
+ }
+ }
+ if (!devicesDiscovered || g_isStopping)
+ {
+ goto exit;
+ }
+ }
+