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

Reconnecting to a already bonded device sometimes does not work

Hello,
I have a strange problem and I am not sure how to approach it.

The problem is that the connection sometimes does not get established. This issue appears on Android phones. The bonding in beforehand works fine and most of the time the reconnect works good as well. But sometimes nothing happens. On first sight the peripheral and the phone does not react when both get activated. There is no error in the peripherals logs (I output messages on pretty much all adv, pm and peer events). And here comes the strange part. If you check in the phones bluetooth settings, the peripheral is just gone. If you turn bluetooth off and on again, the peripheral appears again and the connection gets established.
I have not seen this behavior on iPhones or Windows.
I have tested on different Android phone brands and versions (6,7,8,9,10). On some it appears regularly on others it doesn't appear at all. I could not see any pattern.

I am developing the peripheral based on the ble_app_hids_keyboard example.
The chip is a ublox ANNA-B112, which is a nRF52832; using SES and SDK17.0.2 and softdevice 7.2.0
I am using a public address for the ublox chip.

I am using whitelist with a limit of 1 so only one device can be used with the peripheral. A function to delete all bonds is implemented to be able to bond with another device if needed.
The settings I use are:

#define APP_BLE_OBSERVER_PRIO               3                               
#define APP_BLE_CONN_CFG_TAG                1                               

#define APP_ADV_FAST_INTERVAL               32					
#define APP_ADV_SLOW_INTERVAL               1216                            

#define APP_ADV_FAST_DURATION               3000                            
#define APP_ADV_SLOW_DURATION               18000                           

#define MIN_CONN_INTERVAL                   MSEC_TO_UNITS(15, UNIT_1_25_MS)	
#define MAX_CONN_INTERVAL                   MSEC_TO_UNITS(45, UNIT_1_25_MS)	
#define SLAVE_LATENCY                       8					
#define CONN_SUP_TIMEOUT                    MSEC_TO_UNITS(2000, UNIT_10_MS)	

#define FIRST_CONN_PARAMS_UPDATE_DELAY      APP_TIMER_TICKS(5000)           
#define NEXT_CONN_PARAMS_UPDATE_DELAY       APP_TIMER_TICKS(30000)          
#define MAX_CONN_PARAMS_UPDATE_COUNT        3                               

#define SEC_PARAM_BOND                      1                               
#define SEC_PARAM_MITM                      0                               
#define SEC_PARAM_LESC                      0                               
#define SEC_PARAM_KEYPRESS                  0                               
#define SEC_PARAM_IO_CAPABILITIES           BLE_GAP_IO_CAPS_NONE            
#define SEC_PARAM_OOB                       0                               
#define SEC_PARAM_MIN_KEY_SIZE              7                               
#define SEC_PARAM_MAX_KEY_SIZE              16                              

The security settings for the services are SEC_JUST_WORKS

I have trouble reproducing this error. It just occurs. Sometimes on the next reconnect, sometimes on the next day.

But I managed to capture the occurence with a sniffer. The first picture is where the connection worked fine:

I cut off the picture but the master continues exploring the services and characteristics and so on. After that I turned my peripheral off (using BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION) and turned it on again and this is everything that happens:

After a few seconds the peripheral disconnects and starts advertising again.

Does anyone have a clue what is going on here? 

Parents Reply Children
Related