[riot-notifications] [RIOT-OS/RIOT] pkg/nimble/netif: add nimble_netif_accept_direct() (#16603)

Hauke Petersen notifications at github.com
Thu Jul 1 11:30:21 CEST 2021


### Contribution description
This PR extends `nimble_netif` to support connecting to other devices by sending directed advertising packets (`DIRECT_IND`). This is a special type of advertising packets has as payload only a target BLE address. These packets are ignored by all other nodes except the one directly addressed by this included address. 

Using these advertisements is useful for e.g. reconnecting to a specific node after a connection loss... I am using this in a more advanced BLE connection manager (PR will follow soon).

This PR also extends the `ble` shell command to expose this new functionality -> use `ble adv direct xx:xx:xx:xx:xx:xx` to trigger directed advertisements. But note: you won't be able to see them e.g. on the nrfConnect mobile app, if the given address does not match your scanning device...

### Testing procedure
- flash `gnrc_networking` to any two supported BLE devices, for `nrf52840`-based nodes make sure you enable `nimble_netif`...
- get the BLE address of node A -> `ble info`
- let node B send directed advertisements: `ble adv direct ADD_OF_NODE_A`
- start scanning with node A _> `ble scan`
-> you should see the directed advertising packets from node B, they should have type `DIRECT_IND_HD`

Example:
```
A:
2021-07-01 11:27:43,631 # ble info
2021-07-01 11:27:43,637 # Own Address: CE:57:7A:19:D7:37 -> [FE80::CE57:7AFF:FE19:D737]

B:
> ble adv direct CE:57:7A:19:D7:37
2021-07-01 11:28:06,211 # ble adv direct CE:57:7A:19:D7:37
2021-07-01 11:28:06,213 # DBG: direct adv
2021-07-01 11:28:06,217 # success: started to send directed advertisements

A:
> ble scan
2021-07-01 11:28:15,856 # ble scan
2021-07-01 11:28:15,858 # scanning (for 500ms) ...
2021-07-01 11:28:16,359 # done
...
2021-07-01 11:28:16,432 # [ 7] c9:88:95:ba:ec:98 (RANDOM) [DIRECT_IND_HD] "undefined", adv_msg_cnt: 3, adv_int: 103831us, last_rssi: -25
....
> ble connect 7
2021-07-01 11:28:47,693 # ble connect 7
2021-07-01 11:28:47,698 # initiated connection procedure with C9:88:95:BA:EC:98
> 2021-07-01 11:28:47,809 # event: handle 0 -> CONNECTED as MASTER (C9:88:95:BA:EC:98)

B:
> 2021-07-01 11:28:47,759 # event: handle 0 -> CONNECTED as SLAVE (CE:57:7A:19:D7:37)
```

### Issues/PRs references
None
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * pkg/nimble/netif: add nimble_netif_accept_direct()
  * sc/nimble_netif: add cmd for diricted advertising

-- File Changes --

    M pkg/nimble/netif/include/nimble_netif.h (16)
    M pkg/nimble/netif/nimble_netif.c (37)
    M sys/shell/commands/sc_nimble_netif.c (50)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/16603.patch
https://github.com/RIOT-OS/RIOT/pull/16603.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/16603
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210701/481c5b5e/attachment.htm>


More information about the notifications mailing list