Repository navigation
nimble/host: add BLE_SM_SEC_REQ_AUTO_PAIR - #2287
tonywestonuk wants to merge 1 commit into
Conversation
When a peer sends a Security Request and no keys are stored for it, the host immediately replies with a Pairing Request from inside ble_sm_sec_req_rx(). Some peripherals (e.g. the Okida OT-2000 BLE module used in older Glen Dimplex/Stoves ovens) send a Security Request as soon as the connection is established and do not respond to a Pairing Request sent that early; pairing then times out. The same devices pair fine when the central initiates pairing a moment later, which the Core Spec allows (Vol 3, Part H, 2.4.6: the central may initiate pairing in response to a Security Request, it is not required to). Add a syscfg setting BLE_SM_SEC_REQ_AUTO_PAIR (default 1, stock behaviour) mirrored in ble_hs_cfg.sm_sec_req_auto_pair. When cleared, a Security Request from a peer with no stored keys is accepted but no Pairing Request is sent; the application initiates pairing itself with ble_gap_security_initiate(). Store errors other than BLE_HS_ENOENT are still propagated. Peers with stored keys are unaffected.
sjanc
left a comment
There was a problem hiding this comment.
Hi,
I'm not sure if this is correct approach.
Unlike what commit message states, spec requires central (shall) to start pairing after receiving Security Request
If this is for IOP issue with specific device, I'd rather suggest to allow delaying sending Pairing Request by specified delay. Specification doesn't forbid that from what I can see (however I'd suggest to keep this delay low, likely way below 30s). This should be under opt-in MYNEWT_VAL() option.
You may also make this timer one-shot per connection, where this would delay Pairing Request only if connection was established less than specified time before.
|
Thanks @sjanc, good catch! You're right, I misread the spec there. I'll give your delay idea a go. First I'll check how long this oven actually needs, then update the PR with an opt-in, one-shot-per-connection delay. I'll report back soon 🙂 |
|
Thanks again @sjanc. I've done the measurement, and it turns out no host change is needed. Setup: ESP32-C3 with NimBLE-Arduino 2.5.1, 50 ms connection interval, SMP PDUs timestamped in So I'm closing this. Thanks for pushing back; it led to the actual bug. |
When a peer sends a Security Request and no keys are stored for it, the host immediately replies with a Pairing Request from inside ble_sm_sec_req_rx(). Some peripherals (e.g. the Okida OT-2000 BLE module used in older Glen Dimplex/Stoves ovens) send a Security Request as soon as the connection is established and do not respond to a Pairing Request sent that early; pairing then times out. The same devices pair fine when the central initiates pairing a moment later, which the Core Spec allows (Vol 3, Part H, 2.4.6: the central may initiate pairing in response to a Security Request, it is not required to).
Add a syscfg setting BLE_SM_SEC_REQ_AUTO_PAIR (default 1, stock behaviour) mirrored in ble_hs_cfg.sm_sec_req_auto_pair. When cleared, a Security Request from a peer with no stored keys is accepted but no Pairing Request is sent; the application initiates pairing itself with ble_gap_security_initiate(). Store errors other than BLE_HS_ENOENT are still propagated. Peers with stored keys are unaffected.