frawau / aioblescan

Python only library to scan and decode advertised BLE info. Uses asyncio. Can decode Ruuvi Tag. Can broadcast EddyStone packets.
MIT License
125 stars 62 forks source link

Extended scan filters duplicates #37

Closed prensing closed 3 years ago

prensing commented 3 years ago

I was testing the code for the first time against an ATC thermometer, and only getting 1 packet, yet I could get it every time right near the start. I eventually realized that the default code was picking the Extended scan and that is set to filter duplicates. The non-extended shows all.

Definitely not good to have that inconsistency.

frawau commented 3 years ago

I am not entirely sure I understand your point. ( I did not write the ATC thermometer plugin) When I run the ATC prugin, I can see some info. If I use the raw mode and fillter the MAC address, I can see more packets including 2 different types of service data uuid, fe:95 and 18:1a. As far as I can tell, the ATC plugin only decodes one of them. Where do you see an inconsistency?

Ernst79 commented 3 years ago

fe:95 is Xiaomi MiBeacon format, 18:1a is ATC advertisement format. ATC firmware can send both at the same time.

As far as I can see on line 872 is that the non-extended scan is also filtering duplicates. @prensing, where did you find that non-extended format is not filtered for duplicates?

prensing commented 3 years ago

My apologies: my initial report clearly did not describe the issue correctly. The ATC thermometer decode is working fine.

The issue/inconsistency is in the main program aioblescan, specifically routine BLEScanRequester.send_scan_request(). If it does not use the extended scan, then it passes "False" to HCI_Cmd_LE_Scan_Enable, indicating to not remove duplicates. However, if it does use the extended scan, then the current code uses (line 1808): command = HCI_Cmd_LE_Set_Extended_Scan_Enable(True, 1) But "1" means to remove duplicates. To not remove dups, I believe it should be "0".