Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection fails with paired devices #2

Open
nologinatgit opened this issue Sep 15, 2015 · 1 comment
Open

Connection fails with paired devices #2

nologinatgit opened this issue Sep 15, 2015 · 1 comment

Comments

@nologinatgit
Copy link

I have 2 paired Android devices, and I have this code:

mSmoothBluetooth = new SmoothBluetooth(this, SmoothBluetooth.ConnectionTo.ANDROID_DEVICE, SmoothBluetooth.Connection.SECURE, mListener);
mSmoothBluetooth.tryConnection();

 private SmoothBluetooth.Listener mListener = new SmoothBluetooth.Listener() {
    @Override
    public void onBluetoothNotSupported() {
      //device does not support bluetooth
    }

    @Override
    public void onBluetoothNotEnabled() {
      //bluetooth is disabled, probably call Intent request to enable bluetooth
    }

    @Override
    public void onConnecting(Device device) {
      //called when connecting to particular device
      Log.w("DEBUG","Connecting to device "+device.getName());
    }

    @Override
    public void onConnected(Device device) {
      //called when connected to particular device
      Log.w("DEBUG","Connected device "+device.getName());
    }

    @Override
    public void onDisconnected() {
      //called when disconnected from device
    }

    @Override
    public void onConnectionFailed(Device device) {
      //called when connection failed to particular device
      Log.w("DEBUG","Connection failed to device "+device.getName());
    }
 @Override
    public void onDiscoveryStarted() {
      //called when discovery is started
    }

    @Override
    public void onDiscoveryFinished() {
      //called when discovery is finished
    }

    @Override
    public void onNoDevicesFound() {
      //called when no devices found
    }

    @Override
    public void onDevicesFound(List list, SmoothBluetooth.ConnectionCallback connectionCallback)
    {
      Log.w("DEBUG","Found devices");
      if(list.size()==1)
      {
        Log.w("DEBUG", "Found 1 device");
        Log.w("DEBUG", "Device is paired: "+list.get(0).isPaired());
        connectionCallback.connectTo(list.get(0));
      }
    }
    @Override
    public void onDataReceived(int data) {
      //receives all bytes
    }
  };

I always get this log:

D/BluetoothManager? Paired devices: 1
W/DEBUG? Found devices
W/DEBUG? Found 1 device
W/DEBUG? Device is paired: true
W/DEBUG? Connecting to device GT-S5830i
D/BluetoothService? setState() 0 -> 1
D/BluetoothService? setState() 1 -> 2
D/BluetoothService? setState() 2 -> 1
W/DEBUG? Connection failed to device GT-S5830i

Why does the connection fail if they are paired already?

@nologinatgit nologinatgit changed the title Connection failes with paired devices Connection fails with paired devices Sep 16, 2015
@ravenfeld
Copy link

Me to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants