[riot-notifications] [RIOT-OS/RIOT] nimble_scanner: rework to enable scanning BLE5 PHYs and extended advertisements (#16843)

Hauke Petersen notifications at github.com
Mon Sep 13 22:21:23 CEST 2021


### Contribution description
This PR makes the `nimble_scanner` more powerful by adding the means to also scan for extended advertisements and also for scanning using the coded PHY mode. Furthermore, the new design wraps transparently on top of both NimBLEs extended- and non-extended advertising interfaces, whichever is compiled in. 

NimBLE offers two different sets of APIs, depending if extended advertisements are enabled or not (value of `MYNEWT_VAL_BLE_EXT_ADV `). Once extended advertisements are enabled, the non-extended functions are still callable, but simply return a not-supported error. So once this option is enabled, the extended APIs have to be used for legacy as well as extended advertisements. As using the extended advertising features in NimBLE (`MYNEWT_VAL_BLE_EXT_ADV := 1`) adds significant ROM usage to the build, it is desirable for the scanner to work with both configurations, so users can select between extended features and reduced code size. By having the `nimble_scanner` design decoupled from the underlying NimBLE APIs, we allow users to switch between both modes without having to touch their calls to the `nimble_scanner` API.

To achieve this however, this PR breaks the existing API in some points. I think this is well worth it, as the API changes make the API more robust and future proof. Also this is not one of our high-impact APIs...

### Testing procedure
- compile and run the NimBLE scanner examples (`examples/nimble_scanner`) as-is -> should scan legacy advertisings just fine
- compile the scanner example with `USEMODULE="nimble_phy_coded nimble_phy_2mbit" (best on a nrf52840-based board) and verify that it also picks up extended advertisements

With BLE5 nodes around and extended advertisements enabled, the scan result will look something like this:
```
2021-09-13 21:44:46,098 # scan 2000                                                                                                                                                                                                            
2021-09-13 21:44:46,100 # Scanning for 2000 ms now ...                                                                                                                                                                                         
2021-09-13 21:44:48,102 # Done, results:                                                                                                                                                                                                       
2021-09-13 21:44:48,113 # [ 0] 00:04:2f:8e:3a:0f (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "2;0:04:2F:8E:3A:0F;eTRV", adv_msg_cnt: 1, adv_int: 0us, last_rssi: -84                                                                                   
2021-09-13 21:44:48,123 # [ 1] 88:c6:26:8f:8e:36 (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "", adv_msg_cnt: 7, adv_int: 258387us, last_rssi: -89                                                                                                     
2021-09-13 21:44:48,134 # [ 2] 57:4c:42:f5:b6:e0 (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "TL100_B6E0", adv_msg_cnt: 59, adv_int: 33571us, last_rssi: -52                                                                                           
2021-09-13 21:44:48,153 # [ 3] d8:0f:99:30:b8:be (PUBLIC) [EXT-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 28, adv_int: 70198us, last_rssi: -79                                                                                                 
2021-09-13 21:44:48,165 # [ 4] c8:d0:83:ec:1b:e6 (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 10, adv_int: 109683us, last_rssi: -54                                                                                           
2021-09-13 21:44:48,178 # [ 5] 7c:ad:30:72:98:69 (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 41, adv_int: 45193us, last_rssi: -65                                                                                            
2021-09-13 21:44:48,184 # [ 6] 29:91:a7:51:9c:4e (RANDOM) [NONCONN_IND] phy:1M-1M "undefined", adv_msg_cnt: 6, adv_int: 307346us, last_rssi: -65                                                                                               
2021-09-13 21:44:48,190 # [ 7] 46:06:42:60:1e:8a (RANDOM) [EXT-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 3, adv_int: 561542us, last_rssi: -76                                                                                                 
2021-09-13 21:44:48,198 # [ 8] 7c:8a:66:3f:ed:c5 (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "42750CMI", adv_msg_cnt: 5, adv_int: 249503us, last_rssi: -87                                                                                             
2021-09-13 21:44:48,209 # [ 9] 2a:1e:80:4f:94:2e (RANDOM) [NONCONN_IND] phy:1M-1M "undefined", adv_msg_cnt: 8, adv_int: 207876us, last_rssi: -86                                                                                               
2021-09-13 21:44:48,222 # [10] 65:e5:2a:30:37:06 (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 17, adv_int: 95695us, last_rssi: -77                                                                                            
2021-09-13 21:44:48,230 # [11] 7b:3c:39:6c:94:cf (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 3, adv_int: 181036us, last_rssi: -87                                                                                            
2021-09-13 21:44:48,241 # [12] a4:30:7a:85:77:fb (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 1, adv_int: 0us, last_rssi: -86                                                                                                 
2021-09-13 21:44:48,252 # [13] 60:d7:ed:41:09:78 (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 1, adv_int: 0us, last_rssi: -78
2021-09-13 21:44:48,262 # [14] 1c:1a:c0:9b:55:65 (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 6, adv_int: 152604us, last_rssi: -82
2021-09-13 21:44:48,273 # [15] db:e4:f4:c2:21:da (RANDOM) [EXT-CONN] phy:CODED-CODED "horstus", adv_msg_cnt: 5, adv_int: 240250us, last_rssi: -54
2021-09-13 21:44:48,284 # [16] 40:78:7a:04:4b:02 (RANDOM) [EXT-CONN-SCAN] phy:1M-N/A "undefined", adv_msg_cnt: 6, adv_int: 138475us, last_rssi: -80
2021-09-13 21:44:48,294 # [17] 08:17:98:bd:3e:e0 (RANDOM) [NONCONN_IND] phy:1M-1M "undefined", adv_msg_cnt: 6, adv_int: 151663us, last_rssi: -56
2021-09-13 21:44:48,306 # [18] 00:04:2f:8e:3a:a6 (PUBLIC) [EXT-CONN-SCAN] phy:1M-N/A "2;0:04:2F:8E:3A:A6;eTRV", adv_msg_cnt: 1, adv_int: 0us, last_rssi: -87
2021-09-13 21:44:48,316 # [19] 04:9f:cf:c4:5d:8b (RANDOM) [NONCONN_IND] phy:1M-1M "undefined", adv_msg_cnt: 1, adv_int: 0us, last_rssi: -81
```


### Issues/PRs references
rebased on top of/waiting for https://github.com/RIOT-OS/RIOT/pull/16839
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/16843

-- Commit Summary --

  * nimble/scanner: rename and optimize status func
  * nimble/scanner: migrate to use errno return values
  * shell/sc_nimble_netif: adapt to scanner API change
  * cpu/nrf52: add features for coded and 2Mbit PHYs
  * pkg/nimble: improve readablility in Makefile.dep
  * pkg/nimble: add config options for BLE5 PHYs
  * pkg/nimble/scanner: rework to enable BLE5 scanning
  * pkg/nimble/scanlist: adapt to scanner changes
  * examples/nimble_scanner: adapt to scanner changes

-- File Changes --

    M cpu/nrf52/Makefile.features (7)
    M examples/nimble_scanner/main.c (27)
    M makefiles/pseudomodules.inc.mk (3)
    M pkg/nimble/Makefile (2)
    M pkg/nimble/Makefile.dep (12)
    M pkg/nimble/Makefile.include (27)
    M pkg/nimble/scanlist/include/nimble_scanlist.h (6)
    M pkg/nimble/scanlist/nimble_scanlist.c (7)
    M pkg/nimble/scanlist/nimble_scanlist_print.c (28)
    M pkg/nimble/scanner/include/nimble_scanner.h (92)
    M pkg/nimble/scanner/nimble_scanner.c (102)
    M sys/shell/commands/sc_nimble_netif.c (2)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/16843.patch
https://github.com/RIOT-OS/RIOT/pull/16843.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16843
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210913/277bc9d3/attachment-0001.htm>


More information about the notifications mailing list