2

I'd like to establish a Bluetooth communication between an Android phone and a remote device. The class of the remote device is a basic one just a simple Bluetooth adapter. When I use the Bluetooth scan devices function, the phone recognizes devices from different class (ex. computer, phone, Bluetooth headset) but not this one. I tried it on a Samsung Galaxy Theos and a HTC Wildfire with Android 2.1 but I got the same result with both. Is that possible that the phone manufacturer or Android filters certain class of devices? Otherwise, is there another way to make this device discoverable?

Thanks in advance.

lorenth

lorenth
  • 63
  • 1
  • 1
  • 6
  • Did you check that your remote device is discovarable? I had problems with a bluetooth headset in the past; it just required the right button presses to make it publicly visible. – dorzey Nov 18 '10 at 14:50
  • Hi dorzey, thanks for answering me back. This one has no button. It's a very basic Bluetooth adapter powered by a RJ45 cable. A green light notices that is powered and consequently visible by other devices. Actually I tried on a Nokia 3109 with J2ME embedded before and it recognized the remote device without problem. So I think the problem does not come from the remote device. Thanks for your help – lorenth Nov 18 '10 at 15:33
  • Anyone else has an idea? – lorenth Nov 19 '10 at 09:15
  • can you point us to the adapter you are using and if it is a commercial one ? – Dennis Mathews Nov 19 '10 at 12:17
  • Thanks for answering me back Dennis. It's a Bluetooth dongle adapter using Bluetooth Serial Port Profile for communication. The device is not a commercial one. – lorenth Nov 19 '10 at 15:41

4 Answers4

5

I was able to work around the issue not by changing things at the Android end but by changing the class of the bluetooth adapter. I know this doesn't solve the original issue of class 0x00 devices being blocked, but at least you can use a BT serial device with android despite the bug.

I bought a Bluetooth serial converter from ebay (link here: http://www.ebay.co.uk/itm/Bluetooth-RS232-serial-Converter-Module-Adapter-Board-/190508188703?pt=LH_DefaultDomain_0&hash=item2c5b2c441f ) which, as expected, wasn't recognized by my HTC Desire in its default configuration.

I didn't want to try the app by Zorn software mentioned above, because some people reported it messing up their HTC phones. Instead, I found from the BT device's AT commands datasheet that you can change, among other parameters, the device's class number by using an UART connection and a terminal program.

It took me a while to figure out that you can't use the Bluetooth serial connection to access the configuration interface, but that you must use the physical RX and TX pins on the device instead. You also need to connect the pin named "Key" to Vcc to activate the command mode. So I used an AVR serial programmer device's RS232 to UART interface to connect to the RX/TX pins and used Realterm as the terminal program. This got the AT command interface working once I had the right baudrate, 38400, and swapped the RX and TX leads which I initially connected the wrong way around.

I used the generator here http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html to get a valid non-zero class number (I used object transfer/computer/desktop workstation, which amounts to 0x100104), and entered it to the device with the command

at+class=100104\r\n

where \r\n indicates Enter (see the datasheet).

After switching the BT adapter off, disconnecting the "Key" pin and switching on again, I was able to pair it with my phone the normal way. Data transfer also worked. I again used the AVR programmer's UART and Realterm to send some data (a Hello World message in ASCII) to the RX/TX pins of the adapter. In the Android end, I used the app SENA Bterm to receive the data.

I hope this helps someone do interesting things with their phones and embedded systems.

Clint
  • 51
  • 1
  • 1
3

Ok after some research on the web, for those who want to develop a Bluetooth application on Android (tested on 2.1 Eclair I don't know for other versions) It seems that some phone manufacturer decided to ignore any bluetooth device which advertises itself as class 0×00 and wont allow connections, fire off Intents on discovery or even list it on the bluetooth settings page. Here what it looks like in debugging mode in the LogCat section of Eclipse

DTUN_HCID Device [00:09:EF:58:04:38] class is 0x00 -  skip it

I tried it on a Samsung Galaxy 3 teos and a HTC Wildfire. Apparently it works fine on the Nexus One. Well too bad Google stopped selling it. If some of you tested on other phones and it works please let us know.

Lorenth

lorenth
  • 63
  • 1
  • 1
  • 6
0

I have tested BlueTooth connections to a serial (Class 0x00) device on some different flavours of Android, with these results:

Android 2.1 (Orange or O2, can't remmeber) : pairs ok Toshiba Netbook running Android 2.2 : pairs ok HTC Desire, Vodafone, Android 2.2 : fails to discover device HTC Desire HD, Vodafone, Android 2.2 : fails to discover device

So it is quite possible that some phone companies have blocked 0x00 access. I am in touch with Vodafone to a) get clarification and b) persuade them if possible to fix this. I'll post if I get anything useful.

David

  • Hi David. Sorry it's been a while. Thanks for the information. Did you get some news about this since last time? – lorenth Jan 27 '11 at 15:41
0

UPDATE: This solution relies on access to read logcat from within your app, so will not work on modern versions of Android (> about 3.0). Answer left here with updated link in case someone is using Android v2.x.

Assuming you are writing an app for your phone, I have written a class that works around this issue:

http://zornsoftware.codenature.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

I can confirm the LG Optimus One, and also the Samsung Galaxy S (both Android 2.2) both suffer from this problem. I have contacted LG and Samsung about it and will post back any results i hear.

Mr. Bungle
  • 1,696
  • 17
  • 21
  • Hi Mr. Bungle. Good stuff! Thanks for sharing your solution ;) I had not think to do it like this! Actually I was a newbie on Android when I was working on it. So I've had to change the class of my bluetooth device to make it work! Anyway, I'm pretty sure it's not really a bug the fact that it's wrote explicitly inside the code to avoid the 0x00 class. I think manufacturers omitted it by re-writing the code. For what reason? I don't know but it's strange that Google with the Nexus is almost the only one who did not do that. If you've got some answers from them, let us know. Thanks. – lorenth May 24 '11 at 14:17
  • 1
    Can you please share your changed class so that we can use it? Or please update your answer and leave a comment here. – Reaz Murshed Feb 09 '16 at 17:55
  • @Bungle your link looks wrong, it gets redirected to http://talsit.info/ where there is nothing about Android – Shirish Herwade Jul 22 '16 at 13:33