Friday, April 13, 2012

Stupid Bluetooth behavior of Android phones

It seem that every post I type I feel the need to start it with Google, Google, Google... what am I going to do with you... It is just because I think you are doing good, but not good enough...

I've developed a Bluetooth packet protocol, any application that wants to be used on a wide enough variety of devices, and use Bluetooth on an Android platform, should take the following under consideration:

  • First, my stack overflow question... about an IllegalMonitorStateException, This one was a bugger, I've added a toast to the user to restart the phone.
  • Second, to my surprise there are different buffering implementations, for example, on the same LG phone, in the first few packets arriving, the first ~150 bytes are ZEROs, no data... probably due to the fact that a connection has just been established.
    This problem happens when calling one of the read(...) methods which does NOT block, surprisingly calling repeatably to read(), which DOES block, would result in the correct buffer. 
  • Here is yet another problem I'm facing, hopefully this will be solvable...
  • 08/06/2012, I've encountered another issue with the Bluetooth socket on an other Android device, once the Bluetooth connection is terminated.
    On some devices the next byte read() from the stream returns -1, instead of throwing a IOException.

Will keep it coming as I go...

Sites with good invaluable information:
android-bluetooth-api-connect-to-multiple-devices
connecting-to-a-already-paired-bluetooth-device
this
this
this

No comments:

Post a Comment