Skip to content

Support multiple bonded hosts without requiring factory reset#23

Open
Swissola wants to merge 1 commit into
anthropics:mainfrom
Swissola:multi-host-bonding
Open

Support multiple bonded hosts without requiring factory reset#23
Swissola wants to merge 1 commit into
anthropics:mainfrom
Swissola:multi-host-bonding

Conversation

@Swissola
Copy link
Copy Markdown

Summary

  • Tracks the current connection peer BD address via the extended onConnect(BLEServer*, esp_ble_gatts_cb_param_t*) overload
  • Adds bleRemoveCurrentBond() which removes only the currently connected peer LTK from NVS
  • The unpair JSON command now calls bleRemoveCurrentBond() instead of bleClearBonds(), so each host unpairs itself independently
  • bleClearBonds() is preserved unchanged and still called on factory reset

Motivation

The existing unpair command wipes all stored bonds, which means switching between a home PC and work laptop requires a full factory reset and re-pairing both devices. The ESP32 BLE stack supports up to 7 simultaneous bonds — this change makes full use of that by letting each host manage its own bond independently.

Behaviour after this change

  • Multiple hosts (e.g. desktop + laptop + Pi) can all bond and auto-reconnect without interfering with each other
  • A host sending {"cmd":"unpair"} removes only its own bond
  • First-time pairing with a new host works identically to before (passkey flow unchanged)
  • Factory reset still wipes all bonds via bleClearBonds()
  • No changes to the wire protocol or JSON command structure
  • LE Secure Connections + MITM security model preserved

Test plan

  • Pair two hosts, unpair one, confirm the other still auto-reconnects
  • Factory reset clears all bonds
  • New host pairing passkey flow works as before
  • bleConnected() / bleSecure() / blePasskey() behaviour unchanged

🤖 Generated with Claude Code

Track the current peer BD address in onConnect (extended overload).
bleRemoveCurrentBond() removes only that peer's LTK from NVS. The
"unpair" JSON command now calls this instead of bleClearBonds(), so
each host unpairs itself independently. bleClearBonds() is reserved
for factory reset only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant