Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I bond a Bluetooth Low Energy device?

I want to pair my Android cellphone with a BLE device using createBond and setPin as in this StackOverflow question.

I'm using a TI SensorTag, and I am able to get it to connect, but I want to get it to bond so that I don't have to scan for it later.

Unfortunately, when I use createBond (or when I try to pair through Android Bluetooth Settings), my phone wants a PIN. I have not been able to find the PIN online, and some people I've asked say that BLE devices can't bond (that they only use the Just Works method). Does anyone know the SensorTag PIN, where to find it, or whether I'm just completely off base?

like image 778
Zatricion Avatar asked Jan 23 '26 14:01

Zatricion


2 Answers

Android notwithstanding, BLE is a branch of Bluetooth 4.0 and, as such, should supporting pairing and bonding.

Technically, the "Just Works" method still implies bonding. However, in my experience it isn't necessary for both Android and iOS devices to connect and read from BLE devices that have authentication disabled.

like image 115
Kevin Avatar answered Jan 27 '26 00:01

Kevin


My experience with the TI SensorTag data using Android is that it does not bond. The TI SensorTag uses the Just Works BLE method.

This is the sequence I use to communicate with the TI SensorTag, based on the information in http://developer.android.com/guide/topics/connectivity/bluetooth-le.html

  1. press the button on the SensorTag. This will cause it to listen for Scan requests.
  2. call startLeScan(). Wait for callback.
  3. in your onLeScan() callback, save the device of the discovered TISensorTag.
  4. On the UI thread, call device.connectGatt() and wait for callback.
  5. In your onConnectionStateChange(), call discoverServices() and wait for callback.
  6. In your onServicesDiscovered(), notify your UI thread that you are connected.
  7. In your UI thread, start a read of a GATT Characteristic with readCharacteristic(). Wait for callback.
  8. In your onCharacteristicRead(), call one of the getValue() methods.
  9. Call BluetoothGatt.close(). This call is important. If your app exits without calling close(), the Bluetooth Stack may become unusable and you will need to reboot your phone.
like image 23
Bradford Needham Avatar answered Jan 27 '26 02:01

Bradford Needham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!