intel-iot-devkit / tinyb

TinyB exposes the BLE GATT API for C++, Java and other languages, using BlueZ over DBus.
MIT License
255 stars 114 forks source link

All ble devices are not detected and scanning slow. #98

Open ralf601 opened 7 years ago

ralf601 commented 7 years ago

I am not able to detect all ble devices, there are 150+ beacons in room but i am able to detect only 60~70 beacons and it takes about 1 minute some times and some times 10s to detect.

On other hand i am able to detect 150+ in approx 1 minute on Samsung galaxy s4.

Here is my code:

        BluetoothManager manager = BluetoothManager.getBluetoothManager();
        boolean discoveryStarted = manager.startDiscovery();
        Map<String,BluetoothDevice> devices = new HashMap<>();
        print("The discovery started: " + (discoveryStarted ? "true" : "false"));
        new Thread(new Runnable() {
            @Override
            public void run() {
                // TODO Auto-generated method stub
                while(true){
                    for(BluetoothDevice device : manager.getDevices()){
                        devices.put(device.getAddress(), device);
                    }
                    print("Devices Found:"+devices.size());
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }}
        }).start();
petreeftime commented 7 years ago

This is likely an issue with BlueZ. The only thing TinyB is doing in this case is reading data from it. You should try to open a ticket with them. http://www.bluez.org/contact/

vkolotov commented 6 years ago

Same here @petreeftime @ralf601 . Not all devices get discovered. However there is workaround. Use bluetoothctl tool to set:

[bluetooth]# set-scan-filter-rssi -100

After setting rssi filter to -100, all devices get discovered.

vkolotov commented 6 years ago

Thats why I created this thicket: https://github.com/intel-iot-devkit/tinyb/issues/80