Skip to content

Commit

Permalink
Wait for scan response before reporting discovered peripheral
Browse files Browse the repository at this point in the history
Only applies to connectable peripherals, non-connecatable
will be reported immediately becase a scan response does
not apply.
  • Loading branch information
sandeepmistry authored and yashaswini-hanji committed Mar 27, 2017
1 parent ca254ef commit da4a5e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ BLEDeviceManager::BLEDeviceManager():
memset(_peer_adv_data, 0, sizeof(_peer_adv_data));
memset(_peer_adv_data_len, 0, sizeof(_peer_adv_data_len));
memset(_peer_scan_rsp_data, 0, sizeof(_peer_scan_rsp_data));
memset(_peer_scan_rsp_data_len, 0, sizeof(_peer_scan_rsp_data_len));
memset(_peer_scan_rsp_data_len, -1, sizeof(_peer_scan_rsp_data_len));
memset(_peer_adv_rssi, 0, sizeof(_peer_adv_rssi));

memset(_peer_adv_connectable, 0, sizeof(_peer_adv_connectable));
Expand Down Expand Up @@ -1384,7 +1384,7 @@ BLEDevice BLEDeviceManager::available()
{
uint64_t timestamp_delta = timestamp - _peer_adv_mill[i];
temp = &_peer_adv_buffer[i];
if ((timestamp_delta <= 2000) && (max_delta < timestamp_delta))
if ((timestamp_delta <= 2000) && (max_delta < timestamp_delta) && (_peer_scan_rsp_data_len[i] >= 0 || !_peer_adv_connectable[i]))
{
// Eable the duplicate filter
if (_adv_duplicate_filter_enabled &&
Expand Down Expand Up @@ -1446,7 +1446,7 @@ bool BLEDeviceManager::setAdvertiseBuffer(const bt_addr_le_t* bt_addr,
if (max_delta > 2000) // expired
{
index = i;
_peer_scan_rsp_data_len[index] = 0; // Invalid the scan response
_peer_scan_rsp_data_len[index] = -1; // Invalid the scan response
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/CurieBLE/src/internal/BLEDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class BLEDeviceManager
uint8_t _peer_adv_data[BLE_MAX_ADV_BUFFER_CFG][BLE_MAX_ADV_SIZE];
uint8_t _peer_adv_data_len[BLE_MAX_ADV_BUFFER_CFG];
uint8_t _peer_scan_rsp_data[BLE_MAX_ADV_BUFFER_CFG][BLE_MAX_ADV_SIZE];
uint8_t _peer_scan_rsp_data_len[BLE_MAX_ADV_BUFFER_CFG];
int8_t _peer_scan_rsp_data_len[BLE_MAX_ADV_BUFFER_CFG];
int8_t _peer_adv_rssi[BLE_MAX_ADV_BUFFER_CFG];
bool _peer_adv_connectable[BLE_MAX_ADV_BUFFER_CFG];

Expand Down

0 comments on commit da4a5e4

Please sign in to comment.