1

I'm using the Google sample app code for bluetooth communication http://developer.android.com/guide/topics/connectivity/bluetooth.html

And it works perfectly well for small chunks of data.

However, I'm trying to transmit an Bitmap encoded as a Base64 encoded string and when the data arrives on the receiving device even though it is the correct number of bytes it is frequently out of order. The buffers arrive at ~1024 byte chunks and I'm feeding them in in one write to the inputStream but when all's said and done the file frequently has chunks out of order and is subsequently totally corrupted.

I'm not seeing anyone else complain about this (here on Stack) so I must be doing something wrong, but I'm using mostly the boilerplate code from the sample and it *does work reliably for individual messages that are less than 1024bytes.

I'm wondering if there's any place obvious I should be looking to make sure that the messages are sent in the order in which they're read by the stream.

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
  • do you have any reason to believe that the Bluetooth protocol implements any sort of TCP-like reliability? – mfsiega Apr 30 '14 at 02:07
  • @mfrankli, none whatsoever, but I'm confused by why this isn't addressed anywhere (that I can find). If it's not like TCP then what mechanism should I use to verify the order in which the data is to be written? I actually tried to pass in a version that had info about which piece was which, but the chunks don't come in as self contained pieces, so some might have the end chars from the previous send! – Yevgeny Simkin Apr 30 '14 at 02:09

0 Answers0