Skip to content

Jira 896, BLE scan withDuplicates logic inversion, git 476 #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
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
18 changes: 1 addition & 17 deletions libraries/CurieBLE/src/BLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,38 +247,22 @@ bool BLEDevice::startScan(bool withDuplicates)
}
else
{
return BLEDeviceManager::instance()->startScanning();
return BLEDeviceManager::instance()->startScanningNewPeripherals();
}
}


void BLEDevice::scan()
{
scan(false);
}

void BLEDevice::scan(bool withDuplicates)
{
BLEDeviceManager::instance()->clearAdvertiseCritical();
startScan(withDuplicates);
}

void BLEDevice::scanForName(String name)
{
scanForName(name, false);
}

void BLEDevice::scanForName(String name, bool withDuplicates)
{
BLEDeviceManager::instance()->setAdvertiseCritical(name);
startScan(withDuplicates);
}

void BLEDevice::scanForUuid(String uuid)
{
scanForUuid(uuid, false);
}

void BLEDevice::scanForUuid(String uuid, bool withDuplicates)
{
BLEService service_temp(uuid.c_str());
Expand Down
101 changes: 48 additions & 53 deletions libraries/CurieBLE/src/BLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,83 +361,78 @@ class BLEDevice
//void scanForAddress(String address); // Not include in baseline. Add here as feature for feature release.

/**
* @brief Start scanning for peripherals without filter
* @brief Start scanning for peripherals with the option of accepting all detectable
* Peripherals or just the newly detected.
*
* @param none
*
* @return none
*
* @note none
*/
void scan();

/**
* @brief Start scanning for peripherals with filter
*
* @param[in] withDuplicates true - with duplicate filter
* false- without duplicate filter
*
* @return none
*
* @note option to filter out duplicate addresses for Arduino.
* The current only support fileter duplicate mode.
*/
void scan(bool withDuplicates);

/**
* @brief Start scanning for peripherals and filter by device name in ADV
*
* @param name The device's local name.
* @param[in] withDuplicates true - return all detectable Peripherals.
* false- return a detected Peripheral only once.
*
* @return none
*
* @note option to filter out duplicate addresses for Arduino.
* The current only support fileter duplicate mode.
* @note When, withDuplicates = true, accept all detectable Peripherals.
* No Peripheral filtering process applied to the scan result.
* By default, withDuplicates = false, a detected Peripheral is
* reported once.
*/
void scanForName(String name);
void scan(bool withDuplicates = false);

/**
* @brief Start scanning for peripherals and filter by device name in ADV
* @brief Start scanning for peripherals and filter by device name in ADV and
* the option of accepting all detectable Peripherals or just the
* newly detected.
*
* @param[in] name The device's local name.
*
* @param[in] withDuplicates true - with duplicate filter
* false- without duplicate filter
* @param[in] withDuplicates true - return all detectable Peripherals.
* false- return a detected Peripheral only once.
*
* @return none
*
* @note option to filter out duplicate addresses for Arduino.
* The current only support fileter duplicate mode.
* @note When, withDuplicates = true, accept all detectable Peripherals.
* No Peripheral filtering process applied to the scan result.
* By default, withDuplicates = false, a detected Peripheral is
* reported once.
*/
void scanForName(String name, bool withDuplicates);
void scanForName(String name, bool withDuplicates = false);

/**
* @brief Start scanning for peripherals and filter by service in ADV
* @brief Start scanning for peripherals and filter by service in ADV and
* the option of accepting all detectable Peripherals or just the
* newly detected.
*
* @param service The service
* @param[in] service The service
*
* @param[in] withDuplicates true - return all detectable Peripherals.
* false- return a detected Peripheral only once.
*
* @return none
*
* @note none
* @note When, withDuplicates = true, accept all detectable Peripherals.
* No Peripheral filtering process applied to the scan result.
* By default, withDuplicates = false, a detected Peripheral is
* reported once.
*/
void scanForUuid(String uuid);
void scanForUuid(String uuid, bool withDuplicates = false);

/**
* @brief Start scanning for peripherals and filter by service in ADV
* @brief Start scanning for peripherals and filter by MAC address and
* the option of accepting all detectable Peripherals or just the
* newly detected.
*
* @param[in] service The service
* @param[in] macaddr The Peripheral MAC address
*
* @param[in] withDuplicates true - with duplicate filter
* false- without duplicate filter
* @param[in] withDuplicates true - return all detectable Peripherals.
* false- return a detected Peripheral only once.
*
* @return none
*
* @note option to filter out duplicate addresses for Arduino.
* The current only support fileter duplicate mode.
* @note When, withDuplicates = true, accept all detectable Peripherals.
* No Peripheral filtering process applied to the scan result.
* By default, withDuplicates = false, a detected Peripheral is
* reported once.
*/
void scanForUuid(String uuid, bool withDuplicates);

void scanForAddress(String macaddr, bool withDuplicates = true);
void scanForAddress(String macaddr, bool withDuplicates = false);

/**
* @brief Stop scanning for peripherals
*
Expand Down Expand Up @@ -679,15 +674,15 @@ class BLEDevice
void preCheckProfile();

/**
* @brief Start scanning for peripherals with/without duplicate filter
* @brief Start scanning for peripherals with the option of accepting all
* detectable Peripherals or just the newly detected.
*
* @param[in] withDuplicates true - with duplicate filter
* false- without duplicate filter
* @param[in] withDuplicates true - return all detectable Peripherals.
* false- return a detected Peripheral only once.
*
* @return none
*
* @note option to filter out duplicate addresses for Arduino.
* The current only support fileter duplicate mode.
* @note When, withDuplicates = true, accept all detectable Peripherals.
*/
bool startScan(bool withDuplicates);

Expand Down
8 changes: 4 additions & 4 deletions libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void BLEDeviceManager::_clearAdvertiseBuffer()

}

bool BLEDeviceManager::startScanning()
bool BLEDeviceManager::startScanningWithDuplicates()
{
_adv_duplicate_filter_enabled = false;
_scan_param.filter_dup = BT_HCI_LE_SCAN_FILTER_DUP_ENABLE;
Expand All @@ -609,7 +609,7 @@ bool BLEDeviceManager::startScanning()
return true;
}

bool BLEDeviceManager::startScanningWithDuplicates()
bool BLEDeviceManager::startScanningNewPeripherals()
{
_adv_duplicate_filter_enabled = true;
memset(_peer_duplicate_address_buffer, 0, sizeof(_peer_duplicate_address_buffer));
Expand Down Expand Up @@ -1096,8 +1096,8 @@ bool BLEDeviceManager::connect(BLEDevice &device)
_wait_for_connect_peripheral_adv_data_len = _available_for_connect_peripheral_adv_data_len;
_wait_for_connect_peripheral_scan_rsp_data_len = _available_for_connect_peripheral_scan_rsp_data_len;
_wait_for_connect_peripheral_adv_rssi = _available_for_connect_peripheral_adv_rssi;
startScanning();

startScanningWithDuplicates();

pr_debug(LOG_MODULE_BLE, "%s-%d", __FUNCTION__, __LINE__);
// Wait for the connection
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 @@ -310,7 +310,7 @@ class BLEDeviceManager
void setAdvertiseCritical(String name);
void setAdvertiseCritical(BLEService& service);
void setAdvertiseCritical(const char* macaddress);
bool startScanning(); // start scanning for peripherals
bool startScanningNewPeripherals(); // start scanning for new peripherals, don't report the detected ones
bool startScanningWithDuplicates(); // start scanning for peripherals, and report all duplicates
bool stopScanning(); // stop scanning for peripherals

Expand Down