I have this information from the user manual of my peripheral of interest:
6.2.2 Pairing/Bonding After connection, the collector should initiate pairing with the PERIPHERAL BLE. The PERIPHERAL BLE uses the Just Works pairing method with bonding support. Upon successful pairing, the collector should initiate bonding, and the PERIPHERAL BLE will save the long term bonding key associated with the collector. The PERIPHERAL BLE requires the collector to be bonded in order to encrypt the connection. When bonding is complete, the collector should encrypt the connection. If the PERIPHERAL BLE detects that the connection remains unencrypted after four seconds, it will send a slave security request to the collector. The collector should accept the request which will trigger the pairing or encryption sequence. If the connection remains unencrypted four seconds after the PERIPHERAL BLE sends the slave security request, the connection will be considered insecure and the PERIPHERAL BLE will close the connection. After the collector is bonded with the PERIPHERAL BLE, the collector should encrypt subsequent connections immediately. If the encryption process fails, it is likely that either the collector or PERIPHERAL BLE has deleted its bond key. When this occurs, the PERIPHERAL BLE will delete its bond key if present. It is recommended that the collector also delete its bond key if present. The subsequent connection will trigger the pairing process, a new bond will be created, and the collector will be able to encrypt the connection. Note: The PERIPHERAL BLEβs default security mode places further restrictions on bonding. See 6.3.1.3.2 for more information.
Learn about how Paring and Bonding with Bluetooth while also taking into account, security implications of these procedures.
floitsch05/01/2024 08:44 PM
I will have a look at it tomorrow. I'm working on BLE right now anyway.
1
z3ugma05/01/2024 08:45 PM
thanks, Florian. you're very helpful in all this!
z3ugma05/01/2024 08:45 PM
thanks for the PR for handles
1
z3ugma05/01/2024 08:47 PM
Current behavior is that when I do adapter := ble.Adapter
central := adapter.central
address := find_by_name central DEV_NAME
remote_device := central.connect address
then it just hangs on connect for a very long time, minutes at least
z3ugma05/01/2024 08:48 PM
FWIW the same behavior when I attempt to connect using nRFConnect iOS app connecting to the device
floitsch05/01/2024 08:49 PM
I have in my to-do list to add a timeout to connecting. Even for non-encrypted devices it sometimes fails without any event from the lower layer.
z3ugma05/01/2024 08:50 PM
yeah I've been using with_timeout and catching to implement that
floitsch05/01/2024 08:51 PM
I will look at the code tomorrow, but what happens if you use connect --secure?
floitsch05/01/2024 08:51 PM
Maybe that already uses "just works"
z3ugma05/01/2024 08:53 PM
same hang. it immediately finds a device matching DEV_NAME and then when it moves on to connect, hangs
Hello - I am excited to find this code available on Arduino. Thank you for the library. For my ESP32, I am attempting to set up a simple secure GATT BLE bonding with the "Just Works" pair...
z3ugma05/01/2024 09:10 PM
^^ breadcrumb from NimBLE
floitsch05/01/2024 09:11 PM
Hehe. I sent the same link to my work email a few minutes ago.
floitsch05/01/2024 09:12 PM
I think that's what the --secure flag does, though.
z3ugma05/01/2024 09:12 PM
that might be when the ESP32 is acting as the server, not the client
floitsch05/01/2024 09:14 PM
Hmm. Didn't find any reference to setSecurityAuth, but that might be the Arduino wrapper.
Program your microcontrollers in a fast and robust high-level language. - toitlang/toit
floitsch05/01/2024 09:19 PM
The way it's currently implemented: when we get the MTU event and we want a secure connection we ble_gap_security_exchange
z3ugma05/01/2024 09:19 PM
okay, I think I've got it. The --secure flag is what was needed. Additionally, my device has a 2-minute window exactly after inserting the batteries that it will attempt new connections
floitsch05/01/2024 09:20 PM
Nice.
floitsch05/01/2024 09:20 PM
So that sounds like --secure is indeed doing a "Just works" security. I will add documentation