Coder Social home page Coder Social logo

androidsmoothbluetooth's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidsmoothbluetooth's Issues

No way to connect to a specific device

Not always do we want to let the device connect to just any device found around.

Most of the applications would need to connect to specific devices around, may it be user's choice or preconfigured to control one specific device.

Failed to connect

Hello sir, I am very new to android and I tried using your library. After selecting the desired bluetooth device I am getting the same result "Failed to connect to device". as shown in your documentation, I also tried to connect to an android phone by setting connectionto.Android devices in the constructor, but all in vain. Can you please help?

Paired code

Hi,

i use this library, but i need help with one question. I must connect to device, but i need send paired code.

How i can send paired code in connectionTo(device)?

Connection fails with paired devices

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?

In android arsenal DeviceAdapter raises a proble due to incorrect usage.

Use it in this way might solve the issue.

new MaterialDialog.Builder(this)
.title(R.string.socialNetworks)
// second parameter is an optional layout manager. Must be a LinearLayoutManager or GridLayoutManager.
.adapter(new ButtonItemAdapter(this, R.array.socialNetworks), null)
.show();

Problem to connect : no BluetoothService while connect method is called

I read your source code to understand why it does not connect smoothly and I found that no BluetoothService is avalaible before you call connect(), but for the case of a server you don't have to need to search and try to pair to another device. The client has to connect to the server.
Example : device1 is my server, device2 is my client. Device1 is visible, device2 tries to connect to device1 but it fails. We can repeat this operation several times it will always fail. But if device1 tries to connect to device2 it will work because both have called connect(), so both have already a BluetoothService instance.
My solution is to add these lines

if (!isServiceAvailable()) {
            setupService();
}
startService(mIsAndroid, mIsSecure); 

in the end of the constructor, and it works correctly (I already tested it).

Hope it will help
LAcrym0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.