开发者

Trouble with the Buffer using bluetooth of android

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); 
           } 


</code>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜