Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Switching between two different bonds at certain times

Hi everyone,

I've been working on the firmware for a BLE keyboard, this is my first big project using the nRF5 SDK and everything's been going great so far. I'm using an nRF52840 with SoftDevice s140 and SDK version 17.0. A good portion of the firmware I've developed so far is based on the ble_app_hids_keyboard example in the nRF5 SDK. 

In this example the peer manager library is used to manage the bond between the keyboard and the central device and set an advertising whitelist if a bond already exists, I've extended it to include a "pair button" that can be held down which will delete the bonding/whitelist information and begin advertising again. This is working great, exactly how I expected/wanted. 

The keyboard PCB also includes a switch with the intention of having two seperate peers with only one being active at anytime. When the user flicks the switch the keyboard disconnects from the current central device and start advertising again with a different name. I'm thinking of it as essentially a different ble device at this stage, with no knowledge of the peers/bonds it was using when the switch was in the other state. When the switch is flicked back it then uses the old peer information again

My question is about how functionality like this would best be implemented. Essentially I want to double up the current functionality so that there are two sets of saved bonds/peers and two whitelists that I can switch between based on the state of this hardware switch.

I understand that the peer manager library can save multiple peers but I can't work out how to tell one peer from another (i.e. is this a peer that is stored for when the switch is in state 0 or when it is in state 1?) Is that is possible at all? Is this something that I can achieve with the peer manager as is or do I need to implement my own storage of the peer information? I only really need to store two peers (one for switch state 0 and one for switch state 1) so it isn't too complex hopefully.

Any thoughts or ideas on how this kind of functionality could be achieved would be greatly appreciated. And apologies if this have been covered somewhere else, I had a search around but I was exactly sure what the best search terms were for this problem.

Parents Reply Children
Related