• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Trouble with the Buffer using bluetooth of android

lugopaco

Newbie
Mar 31, 2011
30
0
Mexico
I'm using the bluetooth of an android phone to send some data (strings) to an arduino with bluetooth device.
All works like charm... but I can only send 325 strings!!! (each string only contains 2 positive int numbers).
After this, at the logcat of eclipse, appears me this message: "rfc_setup_rx_bufout of buffer: rfc_setup_rx_bufout of buffer: Out of Buffers" each time that the android tries to send a new data.
I can't close the bluetoothsocket and reopen it (or connect) during the application cause I need to send data very fast for my purpose(about 100-200 ms one after another) and there's no time for that. How can I "clear" the buffer? Is it really the problem with the buffer??
Part of the code I'm ussing this:
Code:
private BluetoothSocket btSocket = null; 
try { 
            btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);

       } catch (IOException e) { 

       } 
           try { 
                outStream = btSocket.getOutputStream(); 

           } catch (IOException e) { 
                Log.e(TAG, "ON RESUME: Output stream creation failed.", e); 
           } 

byte[] msgBuffer = message.getBytes(); 
           try { 
                outStream.write(msgBuffer); 

           } catch (IOException e) { 
                Log.e(TAG, "ON RESUME: Exception during write.", e); 
           }

The "message" in message.getBytes(); is actually the string that I'm sending.

Another thing: I'm ussing an array (byte[] msgBuffer). Is there anyway I can make a "loop" to get to the [0] or [1] index after sending the data so this string will never be full cause I would only use 2 values.
Or the problem is with an internal buffer of my phone (samsung GT-I5500) and no with the code?
A will really apreciate any help cause I'm stuck in this.
 
I tried in a mini-Xperia and it worked (I received from the arduino more than 5000 values!! quite enough to do some tests). Actually for the project I'm doing, we will use this phone and the samsung will be part of another part of the work. Many thanks anyway. I will try it late when I've got more time to play with another resources.

Thanks!!!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones