i'm writting an app which sends byte codes from a tablet to a µ-controler. Everything worked fine on the Lenovo A1 (Androi 2.3) and Samsung Galaxy Tab 7 Plus N (Android 3.2). Now i'm having issues with the new Samsung Galaxy Tab 2 (Android 4.0).
I'm able to pair with the Bluetooth antenna (which is connected to the µ-controller and communicates over the serial protocol). When I start the app I'm asked again to enter the password and to pair. After I enter the pairing password my main layout is visible but a connection isn't established.
The LogCat in eclipse tells me:
06-19 16:00:20.656: V/BluetoothSocket.cpp(3189): availableNative
06-19 16:00:20.664: V/BluetoothSocket.cpp(3189): abortNative
06-19 16:00:20.664: V/BluetoothSocket.cpp(3189): ...asocket_abort(49) complete
06-19 16:00:20.664: I/ActivityManager(185): No longer want com.google.android.partnersetup (pid 3220): hidden #16
06-19 16:00:20.671: V/BluetoothSocket.cpp(3189): availableNative
06-19 16:00:20.671: V/BluetoothSocket.cpp(3189): destroyNative
06-19 16:00:20.671: V/BluetoothSocket.cpp(3189): ...asocket_destroy(49) complete
06-19 16:00:20.679: D/KeyguardViewMediator(185): setHidden false
06-19 16:00:20.679: W/System.err(3189): java.io.IOException: socket closed
06-19 16:00:20.679: W/System.err(3189): at android.bluetooth.BluetoothSocket.available(BluetoothSocket.java:370)
06-19 16:00:20.679: W/System.err(3189): at android.bluetooth.BluetoothInputStream.available(BluetoothInputStream.java:40)
06-19 16:00:20.679: W/System.err(3189): at java.io.BufferedInputStream.available(BufferedInputStream.java:114)
06-19 16:00:20.687: W/System.err(3189): at ebs.alphadidact.control.ReceiveThread.run(ReceiveThread.java:79)
Further more is the LogCat receiving a thousand times the message:
V/BluetoothSocket.cpp(3189): availableNative
So as I searched in the web i found a few guys with a similar problem but no solution. Does someone know something about this issue?
Maybe it is a compability problem between the antenna and android 4.0. I don't think that the error is in my code because as I said the same code is running on older android versions perfectly.
Ok, I found out what the problem is. I'm not sure if it is just a Samsung problem or an Android ICS problem.
I tried to connect to the antenna as usual by using (to get the Socket):
clientSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
Well it seems that it doesn't work out with my antenna and Tablet setup, so I tried:
clientSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
This does work. Ther first option forced the system to unpair the antenna and later ask for pairing again.
Actually creating an insecure socket is the same as connecting two unpaired devices. This is clearly not the best way to handle it.
I have found that Android tries to repair to the device, and then it rejects the pairing response. After this bizzare behavior, it will accept the next connection attempt!
I also tried the Android bugtracker: Bluetooth RFCOMM Server Socket no longer connects properly to embedded device on ICS 4.0.3.
Still waiting for a response...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With