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

Scan issue #238

Closed
EkanshAg opened this issue Feb 17, 2016 · 15 comments
Closed

Scan issue #238

EkanshAg opened this issue Feb 17, 2016 · 15 comments
Labels

Comments

@EkanshAg
Copy link

No device gets displayed, when scanning is done.

@randdusing
Copy link
Owner

Do you have any devices advertising as Bluetooth LE devices?

@slegouffe
Copy link

Hi ! Same for me, trying to scan for my Rasp 2 from my Nexus 5 on which the app is running. But nothing appear in console.log :-/
I'm unable to see the Rasp as everything seems to be ok. Note that I can pair my Nexus 5 and my Rasp when I use standard pairing (ie. directly from 6.0 android bluetooth menu). Here is my Rasp BlueTooth info :
hci0: Type: BR/EDR Bus: USB
BD Address: 00:1A:7D:DA:71:13 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:1516 acl:0 sco:0 events:77 errors:0
TX bytes:1303 acl:0 sco:0 commands:77 errors:0
Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'xxxxxxxx'
Class: 0x420100
Service Classes: Networking, Telephony
Device Class: Computer, Uncategorized
HCI Version: 4.0 (0x6) Revision: 0x22bb
LMP Version: 4.0 (0x6) Subversion: 0x22bb
Manufacturer: Cambridge Silicon Radio (10)

Thx

@randdusing
Copy link
Owner

Android 6.0 requires location permissions to find unpaired devices. You will need to use hasPermission and requestPermission functions to ensure the permissions are good. Also, I'm not familiar with Raspberry Pi. Does it support Bluetooth, Bluetooth LE or both?

@slegouffe
Copy link

Thx for your quick answer !
Ok it works when I use "requestPermission", mean I can list my Mac...but still not get my RPi.
I'm investigating about that and come back as soon as I found a solution.

@slegouffe
Copy link

Hi !
Ok now I can see my Rasp ! Yeepppii !
The tricks, on my pi, I just add this command :

sudo hciconfig hci leadv 3

So next step, pairing...

@randdusing
Copy link
Owner

Anyone still having issues?

@titoasty
Copy link

Yes I just tried today with API23, added requestPermission and everything, but no device appeared (although I have 3 ibeacons around me, perfectly detected on other apps)

(HTC One M8 with Android 6.0)

here is the code I'm using :

` var scan = function() {
console.log('scanning...');

        bluetoothle.startScan(function(res) {
            console.log('found :\n' + JSON.stringify(res, null, 4));
        }, function() {
            console.log('cannot scan');
        }, {
            services: []
        });
    };

    bluetoothle.initialize(function() {
        bluetoothle.isLocationEnabled(function(res) {
            console.log('isLocationEnabled=' + res.isLocationEnabled);

            if(!res.isLocationEnabled) {
                bluetoothle.requestPermission(function() {
                    scan();
                }, function() {
                    console.log('permission denied');
                });
            } else {
                scan();
            }
        });
    }, {
        request: true
    });

`

nothing fancy, just checking for bluetooth, permission and go for scan.

@randdusing
Copy link
Owner

You need to check hasPermission in addition to IsLocationEnabled

@titoasty
Copy link

I already use requestPermission to ask for permission (which is done correctly).
I removed this line of code but after requestPermission the hasPermission returns true, so no problem on this side.

full old code :

        bluetoothle.initialize(function() {
            bluetoothle.isLocationEnabled(function(res) {
                console.log('isLocationEnabled=' + res.isLocationEnabled);

                if(!res.isLocationEnabled) {
                    bluetoothle.hasPermission(function(e) {
                        console.log('hasPermission='+e.hasPermission);

                        if(e.hasPermission) {
                            scan();
                        } else {
                            bluetoothle.requestPermission(function() {
                                scan();
                            }, function() {
                                console.log('permission denied');
                            });
                        }
                    });
                } else {
                    scan();
                }
            });
        }, {
            request: true
        });

@titoasty
Copy link

Found the problem !
So, it's not a permission problem, but location needs to be enabled (as you said). but I assumed it was activated with the request:true in my function call, which is a big misread.

Now, two questions :

  1. Why other BLE apps don't need to activate location to find ble devices ? (I tried with Locate)
  2. Is there a way to activate location with the plugin ? (perhaps another misread)

Thanks

@titoasty
Copy link

Answering my own question, this should need a requestLocation function.
I will look into it to add this one (definitely a must have, now).

@randdusing
Copy link
Owner

There's no requestLocation function in the plugin. I looked into it previously but don't remember why I didn't include it. I can look into it again.

@titoasty
Copy link

After some more tests, I can confirm that Location is definitely needed now with API 23, and so a requestLocation function may be very useful.

Location disabled : nothing returned
Location enabled : find all BLE devices

@randdusing
Copy link
Owner

Plugin has a requestLocation function as of v3.3.0!

@titoasty
Copy link

Thumbs up!
Thanks a lot
Le 23 mars 2016 22:14, "Rand Dusing" notifications@github.com a écrit :

Plugin has a requestLocation function as of v3.3.0!


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#238 (comment)

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

No branches or pull requests

4 participants