Bluetooth Cross Platform Compatible for Android Bluetooth

I have a Bluetooth service that I programmed for .Net on a Windows computer and I would like my Android 2.1 phone to connect to it. The server is listening on the same UUID that Android uses to connect. But the connection does not work.

When I try to connect to devices that do not listen to this UUID, I get an exception with the message "Service discovery failed," but when I try to connect to a server that listens for the correct UUID, a message box pops up:

"The problem was with the Bluetooth device."

And I get an exception with the message "Connection timeout". Thus, it looks like the server and Android are communicating, but there is some kind of failure in the process of establishing a connection. I know that Android requires the server to be paired with the phone and also encrypted the communication channel. Does anyone know what specifications are used for this? I would like my server to correctly respond to a connection attempt.

Thanks!

+3
android cross-platform bluetooth
source share
4 answers

I realized what was going wrong. The problem is that you need to connect the remote device to Android before trying to establish a connection, because the pairing dialog does not always work. I'm not sure if the error is on the Android side or on the other side of the device, but I have never been shown a dialog asking for an authentication code or displaying an authentication code on any device. So it looks like there are some compatibility issues. But if you explicitly connect devices in advance, then the connection works.

+1
source share

You're right. I have the same problem when I try to connect to an RS232 device with the BluetoothChat sample program.

1- If not connected, I get two errors in a row:

03-03 13:38:20.020: ERROR/BluetoothService.cpp(2077): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) // Probably because we're calling cancelDiscovery() as a "security" (it already been cancelled at some point beforehand) 03-03 13:38:20.040: ERROR/BluetoothEventLoop.cpp(2077): onCreateDeviceResult: D-Bus error: org.bluez.Error.AlreadyExists (Device already exists) // This I don't understand 

2- After connecting via Bluetooth settings, no problem. The connection is excellent and the program works.

I tried to check the source of Android myself, but considering that I am a beginner, it is quite difficult. If an experienced guy could fix this, it would be great.

+1
source share

To answer Thomas - Profile Profile SPP (Serial Port Profile) is broken down on several HTC Android models, even versions 2.1, but it does not match the model.

HTC Desire - not working.
HTC Legend - Bad, but it works for a while? HTC Hero with regular ROMs - some of them work well, some do not work at all, and some work poorly while playing sound.

+1
source share

All previous answers are at a mark; essentially, a connection is required for a connection.

However, I was getting an error even after pairing. (I first tried connecting without pairing).

The workaround was to restart the phone once. And now he can connect to the paired device in order. It sounds simple, but I spent quite a bit of time debugging it. Hope it is useful to someone there.

0
source share

All Articles