Bluetooth LE Troubleshooting
Bluetooth classic is easy. Pair a device, then use it.
Bluetooth LE is a bit more difficult. The standard (4.0, 4.1, 4.2) offers different security features and bluetooth device use different subsets.
Succesful connection with Bluetooth LE devices highly depends on the combination of your Bluetooth device and Android version.
Bluetooth LE vendors
Bluetooth LE devices offering a serial service are typically based on these two SoC:
- Texas Instruments CC2540, CC2541
- Nordic Semiconductor nRF51822, ...
The Bluetooth LE standard does not define a serial protocol, so each of the vendors above defined its own GATT service + characteristic UUIDs. This app supports both.
The Bluetooth LE standard uses the terms pairing & bonding differently than Android, where you get a pairing request for bluetooth bonding.
For simplicity I use the term pairing.
There are various complaints about the Android Bluetooth stack (e.g. here
) but basically no solutions.
I also observed slow connection setup and connection failures or disconnects, in most cases resolved by retries or turning bluetooth off and on in android system settings.
Tested Bluetooth devices
BBC micro:bit based on nRF51822
- The BBC micro:bit offers 3 different security modes:
- Unsecure - no pairing
- JustWorks - pairing without pin
- Passkey - pairing with pin
- Use Scanning for BLE devices in my android app only for Unsecure mode
- Pairing has to be done in android bluetooth settings after pressing A+B+Reset
- After uploading a new HEX file, the micro:bit has to be paired again
|Status ||Security Mode||Android Device |
|-all- ||Samsung S3 with Android 6.0 |
|-all- ||Samsung S3 NEO with Android 4.4|
CC41-A based on CC2541
- It was sold as HM-10, but AT+HELP reveiled, that it is a clone from www.bolutek.com with less and slightly different AT commands. Here you can find a comparison and the data sheets.
- This device offers 4 different security modes:
- AT+TYPE0 - unsecure / no pairing
- AT+TYPE1 - non-working. each connect restarted pairing
- AT+TYPE2 - non-working. each connect restarted pairing
- AT+TYPE3 - pairing with pin
- Changing the security mode only becomes effective with power toggle or AT+RESET
- Pairing has to be done in the app when connecting the first time, not in the android bluetooth settings
- Somewhere i read, that this device uses an outdated TI library causing pairing problems
|Status ||Security Mode ||Android Device |
| ||AT+TYPE0 ||Samsung S3 with Android 6.0 |
- First connection after android bluetooth restart can be very slow (up to 30 seconds) and gets lost after some seconds
- Sometimes turning android bluetooth off and on again is the only option to recover from connection failures or connection loss
| ||AT+TYPE0 ||Samsung S3 NEO with Android 4.4|
|AT+TYPE3 ||Samsung S3 with Android 6.0 |
- The android pairing dialogs sometimes open in foreground, sometimes you have to pick them from the android notification area
- After pairing the bluetooth device was sometimes not in a connectible state, could be resolved with power toggle
- Connection sometimes only successful after several retries
- sporadic connection failure or connection loss, typically better after
- turning android bluetooth off and on again
- re-pairing (unpair with long click on device in this app or in android bluetooth settings)
- Pairing from android bluetooth settings not possible. Fails with 'incorrect PIN or passkey'
| ||AT+TYPE3 ||Samsung S3 NEO with Android 4.4|
- Either the pairing dialog was shown or the connection was lost after 1/2 second
- Pairing from android bluetooth settings possible, but does not help
Scanning & Pairing Overview
Depending on bluetooth device and security mode, registering of new devices is different:
|Bluetooth Device||Security Mode||SCAN in App ||Pairing in App ||Pairing in Android|
|BBC micro:bit ||Unsecure ||✓||— ||— |
|BBC micro:bit ||JustWorks ||— ||— ||✓|
|BBC micro:bit ||Passkey ||— ||— ||✓|
|CC41-A ||AT+TYPE0 ||✓||— ||— |
|CC41-A ||AT+TYPE3 ||✓||✓||— |
If you have results for other devices, please contact me at email@example.com