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

Passive scan returns different address type than active scan for BLE devices #262

Closed
gcelosia opened this issue Mar 26, 2018 · 5 comments
Closed

Comments

@gcelosia
Copy link

Hi,

First, thank you for your work. I really enjoy this Bluetooth python module and its simplicity of use.

Unfortunately, I've discovered that, with passive scan, a found BLE device doesn't have the same address type than if it is discovered during an active scan. I checked the scanned results with Wireshark and it seems that the problem comes from the bluepy python module as Wireshark detects the same device address type whether an active or a passive scan is triggered.

Actually, I'm using the original python code from scanner.py (available in bluepy/bluepy/scanner.py) and I just changed the lines:

  • print(strftime("%Y-%m-%d %H:%M:%S", gmtime()), dev.addr, dev.getScanData())
    BY print(strftime("%Y-%m-%d %H:%M:%S", gmtime()), dev.addr, dev.addrType, dev.getScanData())

  • scanner.scan(10.0, passive=True) BY scanner.scan(10.0)

To illustrate my issue, for instance, when I run an active scan (with scanner.scan(10.0)), I have the following : ... 11:22:33:44:55:66 random.... And, you would have understood it, when I run a passive scan (with scanner.scan(10.0,passive=True)), I have the following : ... 11:22:33:44:55:66 public...

So please, can you fix this little problem ? Or maybe I can help you to do this if you can show me the code part involved in this process of finding device address type ?

Thanks in advance.

G.C.

@gandy92
Copy link
Contributor

gandy92 commented May 19, 2018

Hi,

you want to take a look at hci_monitor_cb() in bluepy-helper.c. I can try to look into this in the next few weeks, unless you'd like to debug it yourself.

Best, Andy.

@gcelosia
Copy link
Author

Hi Andy,

Thanks for your answer. I quickly took a look at hci_monitor_cb() in bluepy-helper.c. It seems not very easy to understand. So it would be nice if you debug it yourself. I think that it will take me more time than you to do the same thing.

Don't hesitate to ping me if you need help, I will try to do my best :).

Cheers,
G.C.

@gandy92
Copy link
Contributor

gandy92 commented May 20, 2018

Hi,
I committed a possible fix to https://github.com/gandy92/bluepy. Unfortunately I don't have any BLE devices advertising with random address, so I cannot test it. May I ask you to to verify the solution before I create a pull request?
Cheers,
Andy.

@gcelosia
Copy link
Author

Andy,

I've just tried your fix with a BLE device which advertises with random address. I've the pleasure to announce you that it works well ! Both active and passive scans show that advertising address used is random for this device. Thank you really much for your good job :).

Cheers,
G.C.

@gandy92
Copy link
Contributor

gandy92 commented May 20, 2018

Great, thanks for the feedback.
Cheers,
Andy.

IanHarvey added a commit that referenced this issue Jun 16, 2018
Fix #262: Return correct address type in passive scan mode
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