This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to pair with master by button press instead of passkey?

Hi, I need to pair with the master after pressing the button in my slave device, instead of asking for passkey. Through the master control panel, i can able to see that, when the select device button is pressed, the master connects with the slave, which is in advertising mode. Even-though the passkey method is available to provide security, we are interested in doing it with the button press on slave (some what easier and also secure). So when slave is in advertise mode, and master discovered the slave, master should select the slave and the button on the slave should be pressed to establish the connection. I also don't know what happens(what event occurs) when the master selects slave for connection.

Regards, Balaji

  • Are you sure you need pairing instead of a plain connection? You may be able to use directed advertisement packets to request the master to connect to you then use the 'just works' method of pairing (which is a passkey of 000000 if I remember correctly)

  • It isn't quite clear to me exactly what you need, but if you only want to be available for new devices when the user presses a button, and otherwise only be connectable for devices that are already bonded, you should look into using whitelisting.

    Whitelisting allows a Peripheral to be connectable only for Centrals that it is already bonded with. If you use this by default, and only starts advertising without whitelist when the user presses a button, you should be able to achieve what you need.

    Almost all the SDK examples use a whitelist, for example the ble_app_proximity.

Related