Skip to content

Commit 67291e0

Browse files
committed
Fix GIT 497 CurieBLE: SensorTag example no longer works out of the box
Add timeout mechanism to promise the scan response can be returned. Changed Files BLEDeviceManager.cpp -The available API use timeout mechanism to get the device
1 parent 82eb1be commit 67291e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: libraries/CurieBLE/src/internal/BLEDeviceManager.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,9 @@ BLEDevice BLEDeviceManager::available()
13701370
{
13711371
uint64_t timestamp_delta = timestamp - _peer_adv_mill[i];
13721372
temp = &_peer_adv_buffer[i];
1373-
if ((timestamp_delta <= 2000) && (max_delta < timestamp_delta))
1373+
if ((timestamp_delta >= 800) && // Wait scan response coming || _peer_scan_rsp_data_len[i] >= 0
1374+
(timestamp_delta <= 2000) && // Check timeout
1375+
(max_delta < timestamp_delta))
13741376
{
13751377
// Eable the duplicate filter
13761378
if (_adv_duplicate_filter_enabled &&
@@ -1461,7 +1463,8 @@ bool BLEDeviceManager::setAdvertiseBuffer(const bt_addr_le_t* bt_addr,
14611463
_peer_adv_data_len[index] = data_len;
14621464
_peer_adv_rssi[index] = rssi;
14631465
// Update the timestamp
1464-
_peer_adv_mill[index] = timestamp;
1466+
if (timestamp - _peer_adv_mill[index] > 1000)
1467+
_peer_adv_mill[index] = timestamp;
14651468
_peer_adv_connectable[index] = connectable;
14661469
retval = true;
14671470
}
@@ -1503,7 +1506,9 @@ bool BLEDeviceManager::setScanRespBuffer(const bt_addr_le_t* bt_addr,
15031506
_peer_scan_rsp_data_len[index] = data_len;
15041507
//_peer_adv_rssi[index] = rssi;
15051508
// Update the timestamp
1506-
_peer_adv_mill[index] = timestamp;
1509+
if (timestamp - _peer_adv_mill[index] > 1000)
1510+
_peer_adv_mill[index] = timestamp;
1511+
//_peer_adv_mill[index] = timestamp;
15071512
retval = true;
15081513
}
15091514

0 commit comments

Comments
 (0)