pairing behavior and the erase_bonds setting

I'm using the HID keyboard as the base example. We're using prototype hardware so the connection gets dropped periodically due to ongoing hardware issues. But this has exposed some behavior that I need to understand for the final device. If I set erase_bonds to "true" I need to "forget" the device in bluetooth settings (on the smartphone) and then re-pair the device every time the connection is dropped. If I set erase_bonds to "false" the device automatically re-connects when the connection is dropped, but the smartphone doesn't see it advertise any longer, which is a problem if you want to connect it to a different smartphone, or the device is purposefully forgotten in the smartphone BT settings. In this case I must re-program the device with erase_bonds set to "true", set up the connection, and then re-program it with erase_bonds set to "false". Ideally what I would obviously like it to do is automatically reconnect when disconnected but continue to advertise if that bonded smartphone no longer has the device in its previously connected list. What do I need to do to implement this behavior?

  • Hi Anthony, 

    The example you are testing (HID keyboard) is  a little bit special. Since it's a keyboard for the best user experience, the phone will automatically connect to it immediately if it's previously bonded without any user interaction. So it will be difficult if you want to share the keyboard between 2 phones. 

    I assume you don't want to support 2 phones to be connected at the same time to the same device , correct ? 

    If you simply one to share the device between 2 phones but not at the same time, I would suggest to use other profile, not the HID profile. 

Related