One issue with scanning using bluez is that the current Linux kernel support always turns on de-duplication of advertisements. See this thread in the linux-bluetooth mailing list. - dhalbert's comment on GitHub
Even if you perform
sudo bluetoothctl
menu scan
duplicate-data on
or pass {"DuplicateData": true}
to D-Bus API SetDiscoveryFilter()
, kernel driver will always send the following HCI command when the scanning is started:
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
Scanning: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Using hcitool lescan --duplicates
bypasses kernel interpretation of BT MGMT command and send proper HCI command (Filter duplicates: Disabled (0x00)).
My workaround, as explained in comment on GitHub is the following (source of hci_le_set_scan_enable command):
# This is executed every time after 'scan on' is executed in bluetoothctl.
# First, disable ongoing scan enabled by bluetoothctl - if this is not executed
# then next command to enable scanning will result in Command Disallowed (0x0c)
# status. Fortunatelly, bluetoothctl seems not to be bothered by execution of
# this commands.
hcitool cmd 0x08 0x000C 0x00 0x00
# This results in
# < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
# Scanning: Disabled (0x00)
# Filter duplicates: Disabled (0x00)
# > HCI Event: Command Complete (0x0e) plen 4
# LE Set Scan Enable (0x08|0x000c) ncmd 1
# Status: Success (0x00)
# Now, enable scanning with duplicate filtering disabled
hcitool cmd 0x08 0x000C 0x01 0x00
# This results in
# < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
# Scanning: Enabled (0x01)
# Filter duplicates: Disabled (0x00)
# > HCI Event: Command Complete (0x0e) plen 4
# LE Set Scan Enable (0x08|0x000c) ncmd 1
# Status: Success (0x00)
# and bluetoothctl now reports all packets, as if the 'duplicate-data on'
# actually works as expected. Note: 'duplicate-data on' shall still be
# executed to prevent additional layer of filtering in bluetoothd itself.
For other workaround using hcitool lescan --duplicates
+ hciump
, check Adafruit_Blinka_bleio.
Note, however, that both workarounds require elevated privileges.