-
Notifications
You must be signed in to change notification settings - Fork 304
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
bluez: Linux kernel always de-duplicates advertisements #235
Comments
@dhalbert thank you for this post. I was developing and testing my application on ThinkPad laptop and everything worked as expected, but when deployed on Raspberry Pi, not all packets were visible in This is my workaround: After scanning is started in # 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) However, one additional problem still persists: every 11 seconds,
which causes filters to be enabled again. I cannot get around those 10 seconds even by executing e.g. (
|
Hi, Just a newcomer into Bleak/BlueZ, but I think I was hit by this same issue. I'm monitoring some Xiaomi BLE thermometers whose firmware was switched to that of pvvx Victor. With this new firmware such thermometers send the measured temperature/humidity/battery level on their advertisement data, and, in order to save battery, they are supposed to be scanned passively. On Windows I'm able to monitor them using a callback registered when calling the bleak.BleakScanner constructor. The callback is invoked each time an advertisement from these thermometers is received, no deduplication. But on Linux (on a Raspberry Zero 2W) it is mandatory to pass argument Passing a But, being the scan started, doing: Also, actively scanning in Linux didn't show the issue, so it seems restricted to passive scanning in Linux. Hope this helps, thanks and regards. |
Hi again, I have just noticed that this de-duplication (on Linux —Debian Bookworm— on a Raspberry Pi Zero 2 W) when passively scanning does not happen using an external Bluetooth dongle (an rtl8761 based one). Curious… Regards. |
bluetoothctl -v
) in case of Linux: 5.53One issue with scanning using
bluez
is that the current Linux kernel support always turns on de-duplication of advertisements. This makes it difficult or impossible to use multiple advertisements to transmit changing data in a connectionless way. See this thread in the linux-bluetooth mailing list. @tannewt first encountered this while working on Adafruit_CircuitPython_BLE_BroadcastNet.Around line 875 (right now) in https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/bluetooth/hci_request.c:
@dlech noted:
In Adafruit_Blinka_bleio, we have gotten around this for now by using
hcitool
orbluetoothctl
to initiate scanning, andhcidump
to look at the raw data. However, this requires adding privileges to those commands. See our README for more details. The code is here, in particular_use_hcitool()
and_start_scan_hcitool()
.(Originally mentioned in #206 (comment) and #230 (comment))
The text was updated successfully, but these errors were encountered: