Skip to content

Jira 802, BLE Central scan() to filter Peripheral adv, git #369 #457

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
Feb 24, 2017

Conversation

SidLeung
Copy link
Contributor

New feature:

  • Request from Arduino to make our Central BLE library to
    scan Peripheral similar to an Apple device.
  • When filter is set, advertisement from a Peripheral will
    only show up once (until scan is stop and start again) with
    the available() call. Otherwise, a Peripheral will appear
    as often as the Central can detect its advertisement.
  • Unlike an Apple device, the 101 operates under memory
    constraints. Thus, the maximum number of filter entries
    is limited to 20. In other words, if ther are more than
    20 Peripherals, the filter will NOT be able to filter out
    all the advertisement all the time. A Peripherla WILL
    show up multiple times when available() is called.

Code mods:

  1. BLECommon.h:
    • Definition of the filter entries size.
  2. BLEDeviceManager.cpp:
    • Peripheral filtering initialization at
      startScanningWithDuplicates().
    • Added deviceInDuplicateFilterBuffer() for search a newly
      detected Peripheral against a recorded list of devices.
    • Added updateDuplicateFilter() to record any newly
      detected Peripoheral.
    • At available(), check for duplicated Peripheral prior
      to return it to caller. Discard any reported Peripheral.
      Record any newly detected one prior to return it to
      caller.

@SidLeung
Copy link
Contributor Author

This PR originates from #453.

@bigdinotech @eriknyquist , please review the code change.

@russmcinnis @noelpaz , please perform system testing. To verify the resolution, you can scan the Russ tower (with 20 Peripherals) with filtering turn on.

@russmcinnis
Copy link
Contributor

looks good so far with a few devices. Will try for more than 20. Working on sketch to compare and keep count.

New feature:
  - Request from Arduino to make our Central BLE library to
    scan Peripheral similar to an Apple device.
  - When filter is set, advertisement from a Peripheral will
    only show up once (until scan is stop and start again) with
    the available() call.  Otherwise, a Peripheral will appear
    as often as the Central can detect its advertisement.
  - Unlike an Apple device, the 101 operates under memory
    constraints.  Thus, the maximum number of filter entries
    is limited to 20.  In other words, if ther are more than
    20 Peripherals, the filter will NOT be able to filter out
    all the advertisement all the time.  A Peripherla WILL
    show up multiple times when available() is called.

Code mods:
1. BLECommon.h:
   - Definition of the filter entries size.
2. BLEDeviceManager.cpp:
   - Peripheral filtering initialization at
     startScanningWithDuplicates().
   - Added deviceInDuplicateFilterBuffer() for search a newly
     detected Peripheral against a recorded list of devices.
   - Added updateDuplicateFilter() to record any newly
     detected Peripoheral.
   - At available(), check for duplicated Peripheral prior
     to return it to caller.  Discard any reported Peripheral.
     Record any newly detected one prior to return it to
     caller.
@SidLeung
Copy link
Contributor Author

@yashaswini-hanji , please merge this PR to main trunk and close out the ticket 802. Thanks.

@ndgbuilder ndgbuilder merged commit f4a1880 into arduino:master Feb 24, 2017
@yashaswini-hanji
Copy link
Contributor

PR merged. Jira 802 is closed.

SidLeung added a commit to SidLeung/corelibs-arduino101 that referenced this pull request Mar 22, 2017
Bug fixed:
  This feature was implemented in PR arduino#457, merged, and released
in Deneb.RC1.  However, it was discovered that the logic was
inverted and was report as Git issue arduino#476.  BLE scan() and
input parameter withDuplicates is true means reporting all
Peripherals detected regardless how many times it was reported.

Code mods:
1.  libraries/CurieBLE/src/BLEDevice.cpp:
    - In startScan, calls the correct routine to scan for all
      Peripherals if withDuplicates is true.  Otherwise,
      just scan for new ones.
2.  libraries/CurieBLE/src/BLEDevice.h:
    - Prototyping.
3.  libraries/CurieBLE/src/internal/BLEDeviceManager.h,
    libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
    - Modified header comment to reflect the input parameter
      withDuplictes correct meaning.
    - Default the input parameter, withDupilcates, as true.
    - And, consequently, eliminated some redundant methods.
SidLeung added a commit to SidLeung/corelibs-arduino101 that referenced this pull request Mar 22, 2017
Bug fixed:
  This feature was implemented in PR arduino#457, merged, and released
in Deneb.RC1.  However, it was discovered that the logic was
inverted and was report as Git issue arduino#476.  BLE scan() and
input parameter withDuplicates is true means reporting all
Peripherals detected regardless how many times it was reported.

Code mods:
1.  libraries/CurieBLE/src/BLEDevice.cpp:
    - In startScan, calls the correct routine to scan for all
      Peripherals if withDuplicates is true.  Otherwise,
      just scan for new ones.
2.  libraries/CurieBLE/src/BLEDevice.h:
    - Prototyping.
3.  libraries/CurieBLE/src/internal/BLEDeviceManager.h,
    libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
    - Modified header comment to reflect the input parameter
      withDuplictes correct meaning.
    - Default the input parameter, withDupilcates, as true.
    - And, consequently, eliminated some redundant methods.
SidLeung added a commit to SidLeung/corelibs-arduino101 that referenced this pull request Mar 22, 2017
Bug fixed:
  This feature was implemented in PR arduino#457, merged, and released
in Deneb.RC1.  However, it was discovered that the logic was
inverted and was report as Git issue arduino#476.  BLE scan() and
input parameter withDuplicates is true means reporting all
Peripherals detected regardless how many times it was reported.

Code mods:
1.  libraries/CurieBLE/src/BLEDevice.cpp:
    - In startScan, calls the correct routine to scan for all
      Peripherals if withDuplicates is true.  Otherwise,
      just scan for new ones.
2.  libraries/CurieBLE/src/BLEDevice.h:
    - Prototyping.
3.  libraries/CurieBLE/src/internal/BLEDeviceManager.h,
    libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
    - Modified header comment to reflect the input parameter
      withDuplictes correct meaning.
    - Default the input parameter, withDupilcates, as true.
    - And, consequently, eliminated some redundant methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants