I want to connect from my application in an Android device to a remote device (paired). The remote device is the HC-05 module.
my code is:
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //Standard SerialPortService ID try { mSocket = MyDevice.createRfcommSocketToServiceRecord(uuid); } catch (IOException e) { Toast.makeText(this, "S", Toast.LENGTH_SHORT).show(); } ba.cancelDiscovery(); try { mSocket.connect(); } catch (IOException e){ Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); Log.e("YOUR_APP_LOG_TAG1", "I got an error", e); } try { mOutputStream = mSocket.getOutputStream(); mInputStream = mSocket.getInputStream(); } catch (IOException e) { Toast.makeText(this, "io", Toast.LENGTH_SHORT).show(); }
But I get an error in the mSocket.connect () line.
Mistake:
reading failed socket can be closed or timeout read ret
Please, help.
android bluetooth arduino
user3223395
source share