You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi when i try to make a connection with a device it gives me this error
read failed, socket might closed or timeout, read ret: -1
After making a connection with the device , the phone send a connection request with a pair number and the other phone accepts it , but it still gives me the error.
this is my code rxBluetooth.observeDevices() .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<BluetoothDevice>() { @Override public void accept(BluetoothDevice bluetoothDevice) throws Exception { if(bluetoothDevice.getName() != null && bluetoothDevice.getName().equals("Test")) { Log.e("RxBt",bluetoothDevice.getName()); rxBluetooth.cancelDiscovery(); connectToDevice(bluetoothDevice); } if(bluetoothDevice.getAddress() != null) Log.e("RxBt",bluetoothDevice.getAddress()); //addDevice(bluetoothDevice); } });
Connecting to device method
private void connectToDevice(BluetoothDevice bluetoothDevice) { Log.e("connectToDevice()","connectToDevice invoked."); UUID uuid = UUID.fromString("f77d314e-9730-4a0b-a3a8-0d283eff53ea"); rxBluetooth.observeConnectDevice(bluetoothDevice, uuid) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<BluetoothSocket>() { @Override public void accept(BluetoothSocket socket) throws Exception { // Connected to the device, do anything with the socket Log.e("connectToDevice()","Start of Connection."); } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { Log.e("connectToDevice()",throwable.getMessage()); } }); }
The text was updated successfully, but these errors were encountered:
Hi when i try to make a connection with a device it gives me this error
After making a connection with the device , the phone send a connection request with a pair number and the other phone accepts it , but it still gives me the error.
this is my code
rxBluetooth.observeDevices() .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<BluetoothDevice>() { @Override public void accept(BluetoothDevice bluetoothDevice) throws Exception { if(bluetoothDevice.getName() != null && bluetoothDevice.getName().equals("Test")) { Log.e("RxBt",bluetoothDevice.getName()); rxBluetooth.cancelDiscovery(); connectToDevice(bluetoothDevice); } if(bluetoothDevice.getAddress() != null) Log.e("RxBt",bluetoothDevice.getAddress()); //addDevice(bluetoothDevice); } });
Connecting to device method
private void connectToDevice(BluetoothDevice bluetoothDevice) { Log.e("connectToDevice()","connectToDevice invoked."); UUID uuid = UUID.fromString("f77d314e-9730-4a0b-a3a8-0d283eff53ea"); rxBluetooth.observeConnectDevice(bluetoothDevice, uuid) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<BluetoothSocket>() { @Override public void accept(BluetoothSocket socket) throws Exception { // Connected to the device, do anything with the socket Log.e("connectToDevice()","Start of Connection."); } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { Log.e("connectToDevice()",throwable.getMessage()); } }); }
The text was updated successfully, but these errors were encountered: