Pairing SPP bluetooth devices with Android phones

Update: I have turned the below class into an app which I’ve made available in the Google Play Store called Bluetooth Class Zero. It is a simple application which just enables pairing with bluetooth class zero devices without having to root & patch your phone.

————————————–

I bought a Bluetooth Bee from Seeed Studios, which is an SPP (Serial Port Profile) bluetooth device, with the intention of writing an app for Android that communicates with a remote data logger. Unfortunately, it turns out that there’s a bug in the BroadComm bluetooth stack that is used by most Android phone manufacturers (LG, HTC, Samsung are affected, but not the Google Nexus phones) that prevents discovery to this and all other bluetooth devices that report their Class of Device (CoD) code as 0x00. This is the case for many SPP bluetooth devices, and SPP is probably the most common bluetooth profile (at least it’s the most basic – just straight serial comms) so this bug is pretty nasty.

Basically, if you perform a scan for devices, your SPP device will not show up, and in the logs you will see:

ERROR/DTUN_HCID4(663): Device [00:18:E4:0C:6E:CA] class is 0x00 – skip it.

The code for the Broadcom bluetooth stack is open source, so the bug is plain for all to see here. The bug has been reported on StackOverflow and elsewhere.

Until Broadcom and/or all users of their bluetooth stack fix this issue (by simply removing the IF block that skips devices whose CoD is 0x00), the only way to connect to your SPP device from Android is to read the log files, looking for the above error, extract the device address, and manually initiate a connection in code. After this, your SPP device will appear along with all your other bluetooth devices in the bluetooth settings page on your phone, and you can successfully communicate using the bluetooth API provided by Google.

I have written a re-usable class that implements this workaround, which you can download from here.

How to use (from your Activity class):

(new BluetoothClassZeroDiscoveryTask(
    this, 
    new BluetoothDiscoveryCallback())).execute();

Where BluetoothDiscoveryCallback is a class defined e.g. in your Activity. The call method will be called after the discovery task completes, and is passed the complete list of paired bluetooth devices, including those that are undiscoverable due to the above bug.

private class BluetoothDiscoveryCallback
    implements Action<ArrayList<BluetoothDevice>>
{
	public void call(ArrayList<BluetoothDevice> devices)
	{
		// Now you have the list of ALL available devices, 
		// including those that report class 0x00.
	}
}

// Java equivalent of the built-in Action from C#.
public interface Action<T>
{
	void call(T target);
}

You’ll also need to add READ_LOGS permission to your manifest file:

<uses-permission android:name="android.permission.READ_LOGS" />

Feel free to suggest improvements to the code, I’m new to Android and haven’t done Java in ages :)

P.S. Hassle your phone manufacturer to fix this bug so this workaround is not needed!

App Screenshots:

After pressing “Start Discovery”, if any bluetooth class zero devices were found (but ignored), you will get the standard pairing dialog:

After entering the correct PIN code, your device will be listed alongside others in your bluetooth settings:

The app requires Android 2.1+. It’s been tested on the following phones:


Manufacturer Model Android Version Affected Results
LG Optimus One 2.2 Yes Works
HTC Desire HD 2.2 Yes Works, but unfortunately may interfere with networking / bluetooth operation.
Samsung Galaxy S (I9000) 2.2 Yes Fails
Samsung Galaxy Player 50 2.1 Yes Works

The app is free to use, if you find it useful, feel free to make small donation :)

78 comments

  1. This is an interesting and creative hack. For what it’s worth I tried my Seeedstudio bluetooth module with the SGS and it did scan and pair up OK. I’m using Samsung’s Android 2.3.3, (JVO version). I’m not sure if this means they’ve fixed the bug (probably not!) or the Seeedstudio module I have is different. I have a DFRobot bluetooth module that works as well. They’re both based on the CSR BlueCore chips.

    • HI, got the same module and I was unable to discover it. My PC can but my phone doesn’t. Did you use Arudino for controlling the device?

  2. This is an interesting and creative hack. For what it’s worth I tried my Seeedstudio bluetooth module with the SGS and it did scan and pair up OK. I’m using Samsung’s Android 2.3.3, (JVO version). I’m not sure if this means they’ve fixed the bug (probably not!) or the Seeedstudio module I have is different. I have a DFRobot bluetooth module that works as well. They’re both based on the CSR BlueCore chips.

    • HI, got the same module and I was unable to discover it. My PC can but my phone doesn’t. Did you use Arudino for controlling the device?

  3. Hello.

    Congratulations for your App it seems to be very useful.

    However I have an HTC Desire and i was trying to pair it with the Bluetooth Bee form SeedStudio but it wasn’t posible due to the issue that you reported. Even with your application i’m able to pair it but when i iitiate the serial communication it starts to become buggy.

    Do you have any solution for this?

  4. Hello.

    Congratulations for your App it seems to be very useful.

    However I have an HTC Desire and i was trying to pair it with the Bluetooth Bee form SeedStudio but it wasn’t posible due to the issue that you reported. Even with your application i’m able to pair it but when i iitiate the serial communication it starts to become buggy.

    Do you have any solution for this?

  5. Hi,

    Just wanted to let you know that thanks to your amazing app, I can now connect with my HTC Desire (2.2) to the Bluetooth Bee!
    Thanks!

  6. Hi,

    Just wanted to let you know that thanks to your amazing app, I can now connect with my HTC Desire (2.2) to the Bluetooth Bee!
    Thanks!

  7. Thanks for this great app! I’ve managed to pair my HTC Desire (2.2) with Seeedstudio’s Bluetooth Bee but can’t get them to connect. Does anyone here have any solutions?

  8. Thanks for this great app! I’ve managed to pair my HTC Desire (2.2) with Seeedstudio’s Bluetooth Bee but can’t get them to connect. Does anyone here have any solutions?

  9. I just tried this on a MyTouch 4G, and now I can’t change any of the wireless settings. When I try to open them, I get a dialog saying that the settings process is not responding. And there’s no way to change them now.

  10. I just tried this on a MyTouch 4G, and now I can’t change any of the wireless settings. When I try to open them, I get a dialog saying that the settings process is not responding. And there’s no way to change them now.

    • Just did a factory reset and tried the app again. It finds the device (seedstudio BT) but fails to properly open the pairing request and then stops responding. But this time it did not mess up the bluetooth settings in the phone.

      It leaves a pairing request on the top bar, but selecting it results in the “settings” app crashing.

      Running the app again does not bring up a new pairing request. It just scans for a while then stalls and reports “there was a problem pairing with the device”

    • Just did a factory reset and tried the app again. It finds the device (seedstudio BT) but fails to properly open the pairing request and then stops responding. But this time it did not mess up the bluetooth settings in the phone.

      It leaves a pairing request on the top bar, but selecting it results in the “settings” app crashing.

      Running the app again does not bring up a new pairing request. It just scans for a while then stalls and reports “there was a problem pairing with the device”

  11. After usuing this prog on HTC DHD bluetooth setting always crash when bluetooth activated.

    How fix it without hard reset?

  12. After usuing this prog on HTC DHD bluetooth setting always crash when bluetooth activated.

    How fix it without hard reset?

  13. Hi,
    I have tried this app on HTC desire HD, OS version2.3.3. This is not detecting nokia BH-106 device. The same device is connecting to other phones. Can you please give me necessary steps?

    I have tried as follows.

    1. Switch on nokia bh-106
    2. Blue tooth on in phone
    3. Make phone discoverable
    4. Tried with this software to detect device (previously I scanned for devices, no results)

    Thanks in advance
    Regards,
    Seshadri

    • I found the problem….

      I have reset the settings in the Nokia BH-106, and pressed long time until indicator continuously glow…then scan for devices …

      At last I have paired Bluetooth headset….

  14. Hi,
    I have tried this app on HTC desire HD, OS version2.3.3. This is not detecting nokia BH-106 device. The same device is connecting to other phones. Can you please give me necessary steps?

    I have tried as follows.

    1. Switch on nokia bh-106
    2. Blue tooth on in phone
    3. Make phone discoverable
    4. Tried with this software to detect device (previously I scanned for devices, no results)

    Thanks in advance
    Regards,
    Seshadri

    • I found the problem….

      I have reset the settings in the Nokia BH-106, and pressed long time until indicator continuously glow…then scan for devices …

      At last I have paired Bluetooth headset….

  15. Great App!
    Phone: Samsung Galaxy Ace w/ Android 2.3.3
    BT-Device: GNS 5870 GPS-Receiver
    The scan found the GPS at once and paired with it. Thought I have to buy a different receiver that speaks another language than SPP…

  16. Great App!
    Phone: Samsung Galaxy Ace w/ Android 2.3.3
    BT-Device: GNS 5870 GPS-Receiver
    The scan found the GPS at once and paired with it. Thought I have to buy a different receiver that speaks another language than SPP…

  17. What would have to be done to make a Wiimote work? Its a problem plaguing a large range of phones (Htc, LG, Samsung..) supposedly because in incomplete BT stack, but your explanation is different.. An app allowing the wiimote pairing would be a good idea ($).

  18. What would have to be done to make a Wiimote work? Its a problem plaguing a large range of phones (Htc, LG, Samsung..) supposedly because in incomplete BT stack, but your explanation is different.. An app allowing the wiimote pairing would be a good idea ($).

  19. Suddenly this software stop detecting COD zero after upgrading my Samsung Galaxy Y to the latest firmware (2.3.6),

    Could you help me on this?

  20. Suddenly this software stop detecting COD zero after upgrading my Samsung Galaxy Y to the latest firmware (2.3.6),

    Could you help me on this?

  21. Unfortunately, I’ve recently updated my Galaxy Ace from Android 2.3.3 to 2.3.6. Judging from other comments this operation breaks your app. I haven’t tested it however on 2.3.3, because I bought my bluetooth SPP device after this upgrade.

    Nevertheless, currently it isn’t working on Samsung Galaxy Ace. It’s a pity, because app would be _very_ useful!

  22. Unfortunately, I’ve recently updated my Galaxy Ace from Android 2.3.3 to 2.3.6. Judging from other comments this operation breaks your app. I haven’t tested it however on 2.3.3, because I bought my bluetooth SPP device after this upgrade.

    Nevertheless, currently it isn’t working on Samsung Galaxy Ace. It’s a pity, because app would be _very_ useful!

  23. Hi,

    Thanks for your efforts regarding SPP and Android Phones such as the Galaxy Ace. I’m now facing the same problems. I have bought an OBD2 Bluetooth Adapter (ELM327) which uses SPP, but won’t connect to my 2.3.6 Android Smartphone. I’m afraid your promising app doesn’t work any more. Is there any chance you could release a 2.3.6-compatible version for it anytime soon?

    Regards

    Trizz

  24. Hi,

    Thanks for your efforts regarding SPP and Android Phones such as the Galaxy Ace. I’m now facing the same problems. I have bought an OBD2 Bluetooth Adapter (ELM327) which uses SPP, but won’t connect to my 2.3.6 Android Smartphone. I’m afraid your promising app doesn’t work any more. Is there any chance you could release a 2.3.6-compatible version for it anytime soon?

    Regards

    Trizz

  25. Is there any solution for android 2.3.6?
    I’ve emailed to samsung support, but they told me to contact the vendor of the spp bluetooth device!!
    The device works properly with other android phones (not using 2.3.6)

  26. Is there any solution for android 2.3.6?
    I’ve emailed to samsung support, but they told me to contact the vendor of the spp bluetooth device!!
    The device works properly with other android phones (not using 2.3.6)

  27. i have the same problem. i upgraded my samsung galaxy fit to 2.3.6 a while back. now i am doing a project with btbee hc06. my bluetooth scans mobiles but not the spp module. but it is detected in sony xperia mini without any tweak. please help soon. i have a deadline.

  28. i have the same problem. i upgraded my samsung galaxy fit to 2.3.6 a while back. now i am doing a project with btbee hc06. my bluetooth scans mobiles but not the spp module. but it is detected in sony xperia mini without any tweak. please help soon. i have a deadline.

  29. GOOD!! very well, like says Chris: you made my day (and month, and years (JA JA))

    This works in LG-P500h Android 2.2.1

    Thank you

  30. GOOD!! very well, like says Chris: you made my day (and month, and years (JA JA))

    This works in LG-P500h Android 2.2.1

    Thank you

  31. Thanks for making this and publishing the code. I plan to use the code in an app I am writing to control a class zero BT device so it should come in very useful. What would also be useful is a comprehensive list of all the phones that have been reported to have this problem and those that have been reported to be discoverable using your workaround. Could you start a wiki page that users could edit, giving their phones and whether they are discoverable before and after using your code? That would be wonderful. I will be happy to give you and your site a reference on my page.

  32. Thanks for making this and publishing the code. I plan to use the code in an app I am writing to control a class zero BT device so it should come in very useful. What would also be useful is a comprehensive list of all the phones that have been reported to have this problem and those that have been reported to be discoverable using your workaround. Could you start a wiki page that users could edit, giving their phones and whether they are discoverable before and after using your code? That would be wonderful. I will be happy to give you and your site a reference on my page.

  33. The application seams to solve a common problem to arduino+bt shields developers.
    I have a LG optimus one but i did upgraded the Android version and the application crashes on the discovery phase…is there any workarround?

  34. The application seams to solve a common problem to arduino+bt shields developers.
    I have a LG optimus one but i did upgraded the Android version and the application crashes on the discovery phase…is there any workarround?

  35. Bonjour,

    Avez vous trouver une solution pour galaxy ace en 2.3.6 ?? car mon ELM327 ne fonctionne pas…!!

    SVP aidez moi…..

  36. Bonjour,

    Avez vous trouver une solution pour galaxy ace en 2.3.6 ?? car mon ELM327 ne fonctionne pas…!!

    SVP aidez moi…..

  37. Hi,

    Any news about fixing it on Galaxy Ace (S5830)? Does anybody know why it doesnt work on this phone?

    • Samsung is responsibile for fixing this problem. The software here is only a workaround. Please contact Samsung.

      As a side note, new Samsung Galaxy Gio (Android version 2.3.6) devices also suffers from the same Bluetooth problem. Older Gio devices (Android version 2.3.3) do not have this problem.

    • It’s absolutely unknown which Samsung Model supports SPP profile. Also the official internet sites gives wrong information about Bluetooth SPP. I bought 3 different Samsung Model like S5360, S5830i and Galaxy S2. And nothing. Connection attemption released. Some models(S5830i) can pair but not anymore. Not related Android version.

  38. Hi,

    Any news about fixing it on Galaxy Ace (S5830)? Does anybody know why it doesnt work on this phone?

    • Samsung is responsibile for fixing this problem. The software here is only a workaround. Please contact Samsung.

      As a side note, new Samsung Galaxy Gio (Android version 2.3.6) devices also suffers from the same Bluetooth problem. Older Gio devices (Android version 2.3.3) do not have this problem.

    • It’s absolutely unknown which Samsung Model supports SPP profile. Also the official internet sites gives wrong information about Bluetooth SPP. I bought 3 different Samsung Model like S5360, S5830i and Galaxy S2. And nothing. Connection attemption released. Some models(S5830i) can pair but not anymore. Not related Android version.

  39. Hi,

    I am really new to Android and the ADB, etc. I tried your app and it doesn’t work on my Android Samsung Galaxy Q (2.3.6) phone. Is there some other way for me to make the modifications you showed on my phone (perhaps using android development board).
    Any advise would be highly appeciated.

    Thanks so much,
    Kind regards,
    Nooman Mufti

  40. Hi,

    I am really new to Android and the ADB, etc. I tried your app and it doesn’t work on my Android Samsung Galaxy Q (2.3.6) phone. Is there some other way for me to make the modifications you showed on my phone (perhaps using android development board).
    Any advise would be highly appeciated.

    Thanks so much,
    Kind regards,
    Nooman Mufti

  41. Hi,

    Faced with the same problem. I am trying to connect my Android 2.3.6 (Samsung Galaxy Q) to a JY-MCU (the same as the Bee but the basic chip only). This app didn’t work so I tried the BluePair app which I bought!. It allows me to manually enter the MAC address of the device and I can pair to it.
    The problem is that the Amarino software I am using to communicate with my Arduino tries to again ‘scan’ for the bluetooth device and doesn’t see the already paired device. In contrast the Bluetooth API of the phone sees the paired device. Is there some way to force the other softwares to see the existing added device ?

    Or is there some way for me to use the Java class you uploaded. I am close to 0 experience working on Android Dev Kit but can follow any instructions you might be kind enough to give.

    Thanks so much,
    Kind regards,
    Nooman

  42. Hi,

    Faced with the same problem. I am trying to connect my Android 2.3.6 (Samsung Galaxy Q) to a JY-MCU (the same as the Bee but the basic chip only). This app didn’t work so I tried the BluePair app which I bought!. It allows me to manually enter the MAC address of the device and I can pair to it.
    The problem is that the Amarino software I am using to communicate with my Arduino tries to again ‘scan’ for the bluetooth device and doesn’t see the already paired device. In contrast the Bluetooth API of the phone sees the paired device. Is there some way to force the other softwares to see the existing added device ?

    Or is there some way for me to use the Java class you uploaded. I am close to 0 experience working on Android Dev Kit but can follow any instructions you might be kind enough to give.

    Thanks so much,
    Kind regards,
    Nooman