Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

android - Bluetooth device not discoverable

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

where 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...