I'm trying to connect my Android app with a Bluetooth (classic) peripheral.
After finding the device through a scan, I create a BluetoothSocket without problems. However, mySocket.connect() blocks forever.
public void run(BluetoothAdapter mBluetoothAdapter) {
// Cancel discovery because it otherwise slows down the connection.
mBluetoothAdapter.cancelDiscovery();
try {
// Connect to the remote device through the socket. This call blocks
// until it succeeds or throws an exception.
mySocket.connect();
} catch (IOException connectException) {
// Unable to connect; close the socket and return.
try {
mySocket.close();
} catch (IOException closeException) {
Log.e(TAG, "Could not close the client socket", closeException);
}
return;
}
}
Why a connection timeout error is not thrown?
PS: both my app and the peripheral make use of the default UUID ("00001101-0000-1000-8000-00805F9B34FB"), so this should not be my problem.