BT Bonding and Android

Introduction

Bluetooth Low Energy has a feature of being able to use an encrypted connection in which the Central and the Device negotiate a pair of encryption keys. When the two sides agree to persistently store these keys, it is called Bonding. By default, the BGX device uses encryption and requests that Bonding occur. Some Android devices work properly with bonding, but some Android devices do not behave in the expected way.

There are two possible errors that can occur:

  1. The BGX requests encryption but not bonding and the Android device indicates it will discard the encryption key, but the Android device stores the key anyway. The result of this is that subsequent connections fail.
  2. The BGX requests encryption and bonding and the Android device indicates it will store the encryption key, but the Android device discards the key anway. The result of this is that subsequent connections fail.

In order to prevent scenario 1, we set bonding as the default for BGX. However, if you have turned off bonding on your BGX, be aware that some Android devices have been observed to retain the key anyway. In order to connect a second time, open the Bluetooth settings, select the BGX device, and click "forget this device" to clear the encryption key from the phone.

If bonding is on for your BGX (this is the default), some Android devices have been observed to erroneously discard the encryption key. When this occurs, the command clrb can be issued to the BGX in COMMAND mode in order to clear its bonding table to allow the Android device to connect. You may see the message BOND_FAIL sent by the BGX through its serial lines.

BOND_FAIL

A general troubleshooting step for BOND_FAIL is to clear the bonding on the phone and use the clrb command on the BGX device. If you encounter peristent connection problems resulting in BOND_FAIL it may indicate one of the above scenarios. Also, if you update to the 1.1.1229.0 BGX Firmware, some types of BOND_FAIL errors are prevented.