1. Are you ready for the Galaxy S20? Here is everything we know so far!

Trouble with the Buffer using bluetooth of android

Discussion in 'Android Development' started by lugopaco, Sep 5, 2011.

  1. lugopaco

    lugopaco Newbie
    Thread Starter

    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 (Text):
    1.    
    2.  
    3. private BluetoothSocket btSocket = null;
    4. try {
    5.             btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
    6.  
    7.        } catch (IOException e) {
    8.  
    9.        }
    10.            try {
    11.                 outStream = btSocket.getOutputStream();
    12.  
    13.            } catch (IOException e) {
    14.                 Log.e(TAG, "ON RESUME: Output stream creation failed.", e);
    15.            }
    16.  
    17. byte[] msgBuffer = message.getBytes();
    18.            try {
    19.                 outStream.write(msgBuffer);
    20.  
    21.            } catch (IOException e) {
    22.                 Log.e(TAG, "ON RESUME: Exception during write.", e);
    23.            }
    24.  
    25.  
    26.  
    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.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. alostpacket

    alostpacket Over Macho Grande?

    moved to application development forum :)


    have you tried wrapping the OutputStream in a BufferedOutputStream?
     
    lugopaco likes this.
  3. lugopaco

    lugopaco Newbie
    Thread Starter

    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!!!
     
  4. alostpacket

    alostpacket Over Macho Grande?

    You're welcome, glad you got it sorted :)
     
Loading...

Share This Page

Loading...