changing baud rate on bluetooth SPP connection

raij1 picture raij1 · Jun 5, 2012 · Viewed 10k times · Source

I have the requirement to collect bluetooth data from a remote bluetooth device at the rate of 1.15k with bluetooth SPP. I connect to the remote device as follows.

try {
  tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
  Log.e(TAG, "create() failed", e);
}
mmSocket = tmp;
}

public void run() {
  Log.i(TAG, "BEGIN mConnectThread");
  setName("ConnectThread");
  // Always cancel discovery because it will slow down a connection
  mAdapter.cancelDiscovery();
  // Make a connection to the BluetoothSocket
  try {
    // This is a blocking call and will only return on a
    // successful connection or an exception
    mmSocket.connect();
  } catch (IOException e) {
    connectionFailed();
    // Close the socket
    try {
      mmSocket.close();
    } catch (IOException e2) {
      Log.e(TAG, "unable to close() socket during connection failure", e2);
    }

The connection request to the remote device is successful and I can receive the data at the default baud rate of 9600bps.

But when I change the sending baud rate on the remote bluetooth adapter device to 1.15kbps, my application does not receive any packet on bluetooth. As I mentioned above, I have tried the suggestion of this post.

Is there anything I am missing out? Is it true that I do not need to do anything in my application to change the baud rate? Does RFComm channel adjust the baud rate automatically?

I am using Android 2.1-update1 platform.

Regards, Jagmeet

Answer

raij1 picture raij1 · Jun 6, 2012

I found the answer to my questions.

Is it true that I do not need to do anything in my application to change the baud rate?

Answer: No, we do not need to do anything on the client side to change the baud rate. RFComm channel adjusts the baud rate automatically.