Hi, what I want to achieve is to do a list of devices that I may want to connect to, choose one and pair/bond it (at this point, the central is paired with only one peripheral through its lifetime until some reason makes a new pairing with another peripheral necessary).
What is the procedure to do that ?
For the context : the selection will be made in a menu with buttons and a lcd screen.
My only exposure to BLE is the guides (and trying to understand some examples) therefore some things are left obscure to me.
The central and the peripherals are nRF52840 (chips) and the Softdevice is S140.
I am currently taking the ble_app_hrs example as a canevas.
I looked through the multilink example but it didn't help me because the connections are automatic.
Here is what could be a start (not sure if right) :
The first filter is the UUID, only the devices advertising a certain service (UUID) will be monitored.
Then to do the differentiation between the peripherals, the device name is taken (I tried in the BLE_GAP_EVT_ADV_REPORT event in ble_event_handler(), I can find the name "Nordic_HRM" from the peripheral hrs example).
I read that the device name isn't useful after the connection is made so the adress should be saved too to keep track of the pairing right ? The scanning should keep going until the choice is made, but I didn't understand where (event) I can say to wait and not automatically connect to the first peripheral with a good UUID (as it is in the hrs example).
There is a .connect_if_match element that is put to true in scan_init() but it isn't really used elsewhere (but in nrf_ble_scan_connect_with_target() that is called by nrf_ble_scan_on_adv_report() that is called by nrf_ble_scan_on_ble_evt() that is... never called. Because the main handler used is ble_evt_handler() ?). So put it false will not help here.
I didn't talk about the whitelist because I understood that it can only be used if the adresses are hardcoded at the initialization right ?
In short : how to properly do a manual pairing/bonding ? does sd_ble_gap_connect() only help to connect and the bonding (writing in the flash) is managed by the peer_manager somehow ?
Thank you !