custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.93k stars 248 forks source link

Multiple Bluetooth and hci errors #263

Closed borpin closed 3 years ago

borpin commented 3 years ago

I recently updated Rasbian and am now seeing multiple errors and unstable hci interface. These errors only occur when the ble_monitor is running.

I was running the older (original passive) mitemp_ble (which was stable) when I updated and I saw the errors immediately on Raspbian update. I then updated to ble_monitor and I still see the errors.

I also suffer from the issue of the internal/external Bletooth device issue documented here. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=282948#p1713622

I am seeing lots of hci errors when trying to read Bluetooth data. the hci interfaces crash regularly.

Selection of syslog errors.

Feb 07 06:49:15 hassio kernel: Bluetooth: hci0: advertising data len corrected 18 -> 3
Feb 07 06:49:15 hassio kernel: Bluetooth: hci0: hardware error 0x00
Feb 07 06:49:15 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Feb 07 06:49:28 hassio kernel: Bluetooth: hci1: advertising data len corrected 17 -> 14
Feb 07 06:49:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000

Feb 07 06:51:33 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:51:33 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:51:33 hassio kernel: Bluetooth: hci1: hardware error 0x00
Feb 07 06:51:33 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci1' already present!
Feb 07 06:51:48 hassio kernel: Bluetooth: hci0: advertising data len corrected 28 -> 4
Feb 07 06:51:48 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:48 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:48 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:48 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:49 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 06:51:50 hassio kernel: Bluetooth: hci0: hardware error 0x03
Feb 07 06:51:50 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Feb 07 06:52:07 hassio kernel: Bluetooth: hci0: hardware error 0x00
Feb 07 06:52:08 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: advertising data len corrected 28 -> 4
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: hardware error 0x37
Feb 07 06:52:28 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci1' already present!
Feb 07 06:53:02 hassio kernel: Bluetooth: hci1: advertising data len corrected 18 -> 3
Feb 07 06:53:02 hassio kernel: Bluetooth: hci1: hardware error 0x03
Feb 07 06:53:02 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci1' already present!
Feb 07 06:54:18 hassio apcupsd[612]: Communications with UPS lost.
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:44 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: advertising data len corrected 28 -> 4
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:54:47 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000

Feb 07 07:00:01 hassio kernel: Bluetooth: hci1: command 0x040a tx timeout
Feb 07 07:00:15 hassio kernel: Bluetooth: hci0: hardware error 0x76
Feb 07 07:00:15 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!

HA Log

2021-02-07 06:49:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:50:00 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 50 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] 883 HCI events processed for previous period.
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:50:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:50:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:50:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:50:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:51:00 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 80 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] 1629 HCI events processed for previous period.
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:51:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:51:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:51:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:51:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:52:00 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 75 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] 1645 HCI events processed for previous period.
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:52:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:52:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:52:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:53:01 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 44 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] 787 HCI events processed for previous period.
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:53:01 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:53:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:53:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:53:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:54:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:54:02 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 39 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] 1038 HCI events processed for previous period.
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:54:02 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:54:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:54:50 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-02-07 06:55:02 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:55:03 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 116 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] 2201 HCI events processed for previous period.
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:55:03 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-02-07 06:55:32 DEBUG (Recorder) [homeassistant.components.recorder] Sending keepalive
2021-02-07 06:55:50 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
Ernst79 commented 3 years ago

Based on the above log, ble_monitor is working fine. It receives data and processes it. Nothing strange in the logs.

Regarding the hci logs, I don't have an external dongle myself and haven't seen this issue before. I guess something is wrong with the bluetooth installation. Have you updated the pi-bluetooth package, as suggested in the link you gave? I know @Magalex2x14 has multiple dongles, maybe he has an idea?

borpin commented 3 years ago

I have tried both with the fix and without.

Not tried without the external dongles.

The syslog errors must be being created by the calls made by ble_monitor, as they stop when I disable the integration.

borpin commented 3 years ago

Many more combinations later (all with latest versions of all packages/kernel) - most combinations generated errors of one sort and another - my conclusion is the BT stack on Debian is seriously broken where there are multiple BT adapters in use.

Disconnecting the external BT devices and there are no errors seen (but it only finds 2 of 5 devices, unsurprisingly).

Connecting one of the 2 external devices, only that device is loaded by the kernel (as expected).

I have seen this set of errors once.

Feb 07 10:11:49 hassio kernel: Bluetooth: hci0: advertising data len corrected 25 -> 3
Feb 07 10:11:49 hassio kernel: Bluetooth: hci0: hardware error 0x03
Feb 07 10:11:49 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Feb 07 10:12:37 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:37 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:37 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:37 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:37 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:38 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:38 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:38 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:38 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:38 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: command 0x040c tx timeout
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:40 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:42 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:42 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:42 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:42 hassio kernel: Bluetooth: hci0: Received unexpected HCI Event 00000000
Feb 07 10:12:43 hassio kernel: Bluetooth: hci0: hardware error 0x0c
Feb 07 10:12:43 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Ernst79 commented 3 years ago

The syslog errors must be being created by the calls made by ble_monitor, as they stop when I disable the integration.

But that doesn't mean that ble_monitor is the cause of your problem. ble_monitor is "telling" the system to listen to the HCI interface. We use a slightly modified aioblescan for that. But the issue can still be in either ble_monitor, in aioblescan, in your OS/bluetooth software or even in Linux/kernel itself. Based on your logs, I don't think there is an issue in ble_monitor. My guess (but I'm not an expert at all) you have an an issue in either the firmware of one of the bluetooth radio's or in the bluetooth software.

borpin commented 3 years ago

I just wonder if one of the instructions you are making is causing a conflict with the library due to a recent change in the libraries. This component is doing something to generate the errors.

This setup is a bog standard RPi 4 with fully updated OS/kernel - nothing special.

Whilst I am the only person to notice it, I doubt I am the only one experiencing it. It is one of the flaws with HA OS is that it is difficult to monitor the syslog. Supervised install makes it easier.

Don't get me wrong, it is an excellent component, but something somewhere is not right and most likely is a change in the library/kernel.

Interesting - the Bluetooth service was restarted - first time I have seen this.

Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: USB disconnect, device number 6
Feb 07 11:25:34 hassio bluetoothd[363]: Endpoint unregistered: sender=:1.93 path=/MediaEndpoint/A2DPSink/sbc
Feb 07 11:25:34 hassio bluetoothd[363]: Endpoint unregistered: sender=:1.93 path=/MediaEndpoint/A2DPSource/sbc
Feb 07 11:25:34 hassio NetworkManager[375]: <info>  [1612697134.2305] bluez5: NAP: removed interface 00:1A:7D:DA:71:13
Feb 07 11:25:34 hassio systemd[1]: Starting Load/Save RF Kill Switch Status...
Feb 07 11:25:34 hassio systemd[1]: Stopped target Bluetooth.
Feb 07 11:25:34 hassio systemd[1]: Started Load/Save RF Kill Switch Status.
Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: new full-speed USB device number 8 using xhci_hcd
Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: device descriptor read/64, error -32
Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: New USB device found, idVendor=0a12, idProduct=0001, bcdDevice=88.91
Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
Feb 07 11:25:34 hassio kernel: usb 1-1.2.2: Product: CSR8510 A10
Feb 07 11:25:34 hassio systemd[1]: Started Raspberry Pi bluetooth helper.
Feb 07 11:25:34 hassio systemd[1]: Reached target Bluetooth.
Feb 07 11:25:35 hassio bluetoothd[363]: Sap driver initialization failed.
Feb 07 11:25:35 hassio bluetoothd[363]: sap-server: Operation not permitted (1)
Feb 07 11:25:35 hassio NetworkManager[375]: <info>  [1612697135.1641] bluez5: NAP: added interface 00:1A:7D:DA:71:13
Feb 07 11:25:35 hassio bluetoothd[363]: Endpoint registered: sender=:1.93 path=/MediaEndpoint/A2DPSink/sbc
Feb 07 11:25:35 hassio bluetoothd[363]: Endpoint registered: sender=:1.93 path=/MediaEndpoint/A2DPSource/sbc
Feb 07 11:25:35 hassio bthelper[31033]: Not a UART-attached BT Modem
Feb 07 11:25:35 hassio bluetoothd[363]: Failed to set privacy: Rejected (0x0b)
Feb 07 11:25:35 hassio systemd[1]: bthelper@hci0.service: Succeeded.
Feb 07 11:25:39 hassio systemd[1]: systemd-rfkill.service: Succeeded.
Ernst79 commented 3 years ago

Ok, lets find out what commands are send to the HCI interface. (I didn't write this part myself, so I need to figure it out as well). Below I will try to find out what is exactly does. The communication with the HCI interface is somewhere in aioblescan_ext.py, but it is started from __init__.py in this part.

Lets start with __init__.py. In the code, I think we should look in this part.

            for hci in self._interfaces:
                try:
                    mysocket[hci] = aiobs.create_bt_socket(hci)
                except OSError as error:
                    _LOGGER.error("HCIdump thread: OS error (hci%i): %s", hci, error)
                else:
                    fac[hci] = getattr(self._event_loop, "_create_connection_transport")(
                        mysocket[hci], aiobs.BLEScanRequester, None, None
                    )
                    conn[hci], btctrl[hci] = self._event_loop.run_until_complete(fac[hci])
                    _LOGGER.debug("HCIdump thread: connected to hci%i", hci)
                    btctrl[hci].process = self.process_hci_events
                    try:
                        self._event_loop.run_until_complete(btctrl[hci].send_scan_request(self._active))
                    except RuntimeError as error:
                        _LOGGER.error(
                            "HCIdump thread: Runtime error while sending scan request on hci%i: %s", hci, error
                        )

So, assuming you have hci0 an 1, we first have mysocket[0] = aiobs.create_bt_socket(0). This returns the following: <socket.socket fd=24, family=AddressFamily.AF_BLUETOOTH, type=SocketKind.SOCK_RAW, proto=1>

if no errors occur, we continue with fac[0] = getattr(self._event_loop, "_create_connection_transport")(mysocket[0], aiobs.BLEScanRequester, None, None). This returns the following coroutine object BaseEventLoop._create_connection_transport at 0xadb9e328

Next, we have conn[hci], btctrl[0] = self._event_loop.run_until_complete(fac[0]), which returns <_SelectorSocketTransport fd=24 read=polling write=<idle, bufsize=0>>

And then btctrl[0].process = self.process_hci_events, which returns <bound method HCIdump.process_hci_events of <HCIdump(Thread-4, started 2915037216)>>

This is followed by something similar for hci 1 (can't test this myself)

So, based on the last output, it seems it is making an HCIdump. With two hci interfaces, I assume it is making two HCIdumps at the same time.

Edit: quick question in between, are you using other components that use bluetooth?

borpin commented 3 years ago

quick question in between, are you using other components that use bluetooth?

No.

Just looking at the logs above - it looks like all the errors are outside of this bit and are a result on the main even loop

BLE logs

2021-02-07 06:52:00 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 75 MiBeacon BLE ADV messages processed for 5 measuring device(s).
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] 1645 HCI events processed for previous period.
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: Run
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: connected to hci1
2021-02-07 06:52:00 DEBUG (Thread-2881) [custom_components.ble_monitor] HCIdump thread: start main event_loop

Errors occur here

2021-02-07 06:52:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0

Syslog

Feb 07 06:52:07 hassio kernel: Bluetooth: hci0: hardware error 0x00
Feb 07 06:52:08 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: advertising data len corrected 28 -> 4
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:19 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: Received unexpected HCI Event 00000000
Feb 07 06:52:28 hassio kernel: Bluetooth: hci1: hardware error 0x37
Feb 07 06:52:28 hassio kernel: debugfs: File 'force_bredr_smp' in directory 'hci1' already present!

Currently I am running just one interface. It is better but still crashes occasionally. I'm not using active scan.

Ernst79 commented 3 years ago

This message is only the summary of the result of the "collecting" process, during the set period. It just says in the past period (60 seconds), it has received 0 BLE messages that contain useful data for the binary sensors.

2021-02-07 06:52:49 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0

There is a similar message for (what we call) measuring sensors.

2021-02-07 06:52:00 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 75 MiBeacon BLE ADV messages processed for 5 measuring device(s).

In other words, it has received 75 useful messages for 5 different sensors.

During the period, the component is constantly getting data messages from the hci interface, that are processed. To me it looks like something goes wrong in this process of receiving the data. But what...

borpin commented 3 years ago

This message is only the summary of the result of the "collecting" process,

Yes I was just indicating that the errors are generated by whatever calls are being made (even by the underlying library) between those log entries.

To me it looks like something goes wrong in this process of receiving the data. But what...

I note you say you use a modified library. Has something changed in the base library because of kernel changes that need reflecting in your modified library?

Ernst79 commented 3 years ago

There are some small updates in the underlying library, that are not implemented yet. At first sight, they don't seem that important, but I will update them to stay up to date. We use aioblescan as underlying library.

https://github.com/frawau/aioblescan

At a certain moment, @Magalex2x14 copied the aioblescan library into our component directly, as it was needed to make a change, that was not implemented in the original library. (a workaround for Extended Advertisements see #61)

As said, I will update the latest changes, but...

At the moment, I have an issue myself with Bluetooth. I installed a Conbee II stick and did a apt-get update/upgrade, but after that, it's a big mess. Besides other problems, Bluetooth wasn't working anymore. I managed to get it working via SSH, but for some strange reason, homeassistant (ble_monitor) doesn't receive anything (also when I remove the conbee stick). But when I do sudo hcitool lescan in SSH, ble_monitor receives exactly 1 message per device, and than stops again. No errors in HA.

I need to fix this first. I also ordered an external USB Bluetooth receiver, so maybe I can reproduce your issue later this week (if I get the internal Bluetooth fixed...).

borpin commented 3 years ago

did a apt-get update/upgrade, but after that, it's a big mess.

Yep, that was where my issues started...

Ernst79 commented 3 years ago

Hmm, than maybe we have a similar issue now But for you it is working with one device. I can't get it to work.

For some reason, all my Bluetooth software disappeared. I had to install a lot, which was there in the past (hcidump, bluetooth, bluez, etc etc). I don't understand why this all of a sudden can disappear. But let me not hijack this issue with my problem.

borpin commented 3 years ago

Hmm, than maybe we have a similar issue now But for you it is working with one device. I can't get it to work.

One external device (on a USB/Ethernet cable extender).

Check the apt update did not hold back any packages.

$ uname -a
Linux hassio 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux

Might be worth comparing versions of packages.

Ernst79 commented 3 years ago

I don't have any hold back packages.

~ $ uname -a
Linux raspberrypi4 5.10.14-v7l+ #1401 SMP Mon Feb 8 14:27:07 GMT 2021 armv7l GNU/Linux

I did a dist upgrade yesterday to see if it would fix my issues, but that didn't help.

Ernst79 commented 3 years ago

Yes I was just indicating that the errors are generated by whatever calls are being made (even by the underlying library) between those log entries.

I tried to reproduce what is does, and the aioblescan_ext.py does an hcidump.

<bound method HCIdump.process_hci_events of <HCIdump(Thread-4, started 2915037216)>>

Not sure if it goes wrong on that step, but your logs say that it received an unexpected HCI event

Received unexpected HCI Event 00000000

But I don't have a clue why it at a certain point stops in your case.

Magalex2x14 commented 3 years ago

@Ernst79 is right, the component through the modified aioblescan library just initiates scanning and listens for events on the hci interface(s). The root of the problem must be found at a lower level (kernel - firmware - hardware). The reason why these errors appear only when our component is running is only that the component transfers the interface to an active state (passive BLE scanning), at other times the bt-interface is idle, so there are no errors.

@borpin have you tried rolling back the kernel version you are using? I saw somewhere on the Internet that a rollback to the kernel of the 4.19 branch solves some problems (besides your link in the first post). Unfortunately, I can't say anything right now about how to do this correctly in the case of raspbian, and how quality is support for the Raspberry Pi4 in previous versions of the kernel, this is a subject for googling and reading ...

As for me, I use several different bt-dongles (in addition to the built-in one) and have no problems with bt-subsystem whatsoever. But, unfortunately, I do not use Raspberry PI for HA - I have an old mac mini with Debian (Home Assistant Core, Python venv):

aleksey@mini2x14:~$ cat /etc/debian_version
10.8
aleksey@mini2x14:~$ uname -a
Linux mini2x14 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
aleksey@mini2x14:~$
Magalex2x14 commented 3 years ago

The only inconvenience associated with using multiple dongles is that sometimes the hci interfaces are reindexed in different order after host reboots. For example, today hci0 is a built-in interface, and after the next reboot of the host, it is become as hci1, and some of the dongles took its place. But normally this is not a problem...

borpin commented 3 years ago

I saw somewhere on the Internet that a rollback to the kernel of the 4.19 branch solves some problems

It does seem the newer kernel is a big part of the problem

As for me, I use several different bt-dongles (in addition to the built-in one) and have no problems with bt-subsystem whatsoever.

Neither did I until I did an upgrade.

Ernst79 commented 3 years ago

@borpin My own issue is solved, I guess I either had issues with the SSD being to close or I had an error in my own code during the development. Reinstalling the latest beta of ble_monitor worked.

Back to your issue. What happens if you run an hcidump manually? do you also get these error message than?

borpin commented 3 years ago

What happens if you run an hcidump manually?

Strangely, I get a command not found 😢

Ernst79 commented 3 years ago

How is your HA installed? Venv, supervised or the full home assistant?

borpin commented 3 years ago

Supervised - Raspbian Buster with SSHD

[edit]

 $ sudo apt install bluez-hcidump --dry-run
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  rpi-eeprom-images
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  bluez-hcidump
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst bluez-hcidump (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Conf bluez-hcidump (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Ernst79 commented 3 years ago

I have the same. Please check that you have the latest versions of these.

sudo apt install bluetooth pi-bluetooth bluez blueman bluez-hcidump
blueman is already the newest version (2.0.8-1+deb10u1).
bluetooth is already the newest version (5.50-1.2~deb10u1+rpt2).
bluez is already the newest version (5.50-1.2~deb10u1+rpt2).
pi-bluetooth is already the newest version (0.1.15).
borpin commented 3 years ago

Would appear not - how is it working at all!

$ sudo apt install bluetooth pi-bluetooth bluez blueman bluez-hcidump --dry-run
Reading package lists... Done
Building dependency tree
Reading state information... Done
bluez is already the newest version (5.50-1.2~deb10u1+rpt2).
bluez set to manually installed.
pi-bluetooth is already the newest version (0.1.15).
The following package was automatically installed and is no longer required:
  rpi-eeprom-images
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  bluez-obexd gir1.2-appindicator3-0.1 gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gir1.2-notify-0.7 gir1.2-pango-1.0 gnome-icon-theme libaom0 libappindicator3-1
  libasound2-plugins libasyncns0 libavcodec58 libavresample4 libavutil56 libcodec2-0.8.1 libdbusmenu-glib4 libdbusmenu-gtk3-4 libflac8 libgsm1 libical3 libindicator3-7 libjack-jackd2-0
  libltdl7 libmp3lame0 libogg0 libopenjp2-7 libopus0 liborc-0.4-0 libpangoxft-1.0-0 libpulse-mainloop-glib0 libpulse0 libpulsedsp libshine3 libsndfile1 libsoxr0 libspeex1 libspeexdsp1
  libswresample3 libtdb1 libtheora0 libtwolame0 libva-drm2 libva-x11-2 libva2 libvdpau-va-gl1 libvdpau1 libvorbis0a libvorbisenc2 libvpx5 libwavpack1 libwebrtc-audio-processing1 libx264-155
  libx265-165 libxvidcore4 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers pulseaudio pulseaudio-module-bluetooth pulseaudio-utils python3-cairo python3-gi-cairo rtkit va-driver-all
  vdpau-driver-all
Suggested packages:
  bluez-cups jackd2 opus-tools speex pavumeter pavucontrol paman paprefs
The following NEW packages will be installed:
  blueman bluetooth bluez-hcidump bluez-obexd gir1.2-appindicator3-0.1 gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gir1.2-notify-0.7 gir1.2-pango-1.0 gnome-icon-theme
  libaom0 libappindicator3-1 libasound2-plugins libasyncns0 libavcodec58 libavresample4 libavutil56 libcodec2-0.8.1 libdbusmenu-glib4 libdbusmenu-gtk3-4 libflac8 libgsm1 libical3
  libindicator3-7 libjack-jackd2-0 libltdl7 libmp3lame0 libogg0 libopenjp2-7 libopus0 liborc-0.4-0 libpangoxft-1.0-0 libpulse-mainloop-glib0 libpulse0 libpulsedsp libshine3 libsndfile1
  libsoxr0 libspeex1 libspeexdsp1 libswresample3 libtdb1 libtheora0 libtwolame0 libva-drm2 libva-x11-2 libva2 libvdpau-va-gl1 libvdpau1 libvorbis0a libvorbisenc2 libvpx5 libwavpack1
  libwebrtc-audio-processing1 libx264-155 libx265-165 libxvidcore4 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers pulseaudio pulseaudio-module-bluetooth pulseaudio-utils
  python3-cairo python3-gi-cairo rtkit va-driver-all vdpau-driver-all
0 upgraded, 71 newly installed, 0 to remove and 0 not upgraded.
Inst libical3 (3.0.4-3 Raspbian:stable [armhf])
Inst bluez-obexd (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Inst gnome-icon-theme (3.12.0-3 Raspbian:stable [all])
Inst libasyncns0 (0.8-6 Raspbian:stable [armhf])
Inst libogg0 (1.3.2-1+b2 Raspbian:stable [armhf])
Inst libflac8 (1.3.2-3 Raspbian:stable [armhf])
Inst libvorbis0a (1.3.6-2 Raspbian:stable [armhf])
Inst libvorbisenc2 (1.3.6-2 Raspbian:stable [armhf])
Inst libsndfile1 (1.0.28-6 Raspbian:stable [armhf])
Inst libpulse0 (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst libpulse-mainloop-glib0 (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst gir1.2-atk-1.0 (2.30.0-2 Raspbian:stable [armhf])
Inst gir1.2-freedesktop (1.58.3-2 Raspbian:stable [armhf])
Inst gir1.2-gdkpixbuf-2.0 (2.38.1+dfsg-1 Raspbian:stable [armhf])
Inst libpangoxft-1.0-0 (1.42.4-8~deb10u1 Raspbian:stable [armhf])
Inst gir1.2-pango-1.0 (1.42.4-8~deb10u1 Raspbian:stable [armhf])
Inst gir1.2-gtk-3.0 (3.24.5-1+rpt2 Raspberry Pi Foundation:testing [armhf])
Inst gir1.2-notify-0.7 (0.7.7-4 Raspbian:stable [armhf])
Inst python3-cairo (1.16.2-1+b1 Raspbian:stable [armhf])
Inst python3-gi-cairo (3.30.4-1 Raspbian:stable [armhf])
Inst libdbusmenu-glib4 (18.10.20180917~bzr490+repack1-1 Raspbian:stable [armhf])
Inst libdbusmenu-gtk3-4 (18.10.20180917~bzr490+repack1-1 Raspbian:stable [armhf])
Inst libindicator3-7 (0.5.0-4 Raspbian:stable [armhf])
Inst libappindicator3-1 (0.4.92-7 Raspbian:stable [armhf])
Inst gir1.2-appindicator3-0.1 (0.4.92-7 Raspbian:stable [armhf])
Inst blueman (2.0.8-1+deb10u1 Raspbian:stable [armhf])
Inst bluetooth (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [all])
Inst bluez-hcidump (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Inst libaom0 (1.0.0-3 Raspbian:stable [armhf])
Inst libva2 (2.4.0-1 Raspbian:stable [armhf])
Inst libva-drm2 (2.4.0-1 Raspbian:stable [armhf])
Inst libva-x11-2 (2.4.0-1 Raspbian:stable [armhf])
Inst libvdpau1 (1.1.1-10 Raspbian:stable [armhf])
Inst libavutil56 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Inst libcodec2-0.8.1 (0.8.1-2 Raspbian:stable [armhf])
Inst libgsm1 (1.0.18-2 Raspbian:stable [armhf])
Inst libmp3lame0 (3.100-2+b1 Raspbian:stable [armhf])
Inst libopenjp2-7 (2.3.0-2+deb10u1 Raspbian:stable [armhf])
Inst libopus0 (1.3-1 Raspbian:stable [armhf])
Inst libshine3 (3.1.1-2+b1 Raspbian:stable [armhf])
Inst libspeex1 (1.2~rc1.2-1+b2 Raspbian:stable [armhf])
Inst libsoxr0 (0.1.2-3 Raspbian:stable [armhf])
Inst libswresample3 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Inst libtheora0 (1.1.1+dfsg.1-15 Raspbian:stable [armhf])
Inst libtwolame0 (0.3.13-4 Raspbian:stable [armhf])
Inst libvpx5 (1.7.0-3+deb10u1 Raspbian:stable [armhf])
Inst libwavpack1 (5.1.0-6 Raspbian:stable [armhf])
Inst libx264-155 (2:0.155.2917+git0a84d98-2+rpi1 Raspbian:stable [armhf])
Inst libx265-165 (2.9-4 Raspbian:stable [armhf])
Inst libxvidcore4 (2:1.3.5-1 Raspbian:stable [armhf])
Inst libzvbi-common (0.2.35-16 Raspbian:stable [all])
Inst libzvbi0 (0.2.35-16 Raspbian:stable [armhf])
Inst libavcodec58 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Inst libavresample4 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Inst libjack-jackd2-0 (1.9.12~dfsg-2 Raspbian:stable [armhf])
Inst libasound2-plugins (1.1.8-1 Raspbian:stable [armhf])
Inst libltdl7 (2.4.6-9 Raspbian:stable [armhf])
Inst liborc-0.4-0 (1:0.4.28-3.1 Raspbian:stable [armhf])
Inst libpulsedsp (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst libspeexdsp1 (1.2~rc1.2-1+b2 Raspbian:stable [armhf])
Inst libtdb1 (1.3.16-2+b1 Raspbian:stable [armhf])
Inst libvdpau-va-gl1 (0.4.2-1+b1 Raspbian:stable [armhf])
Inst libwebrtc-audio-processing1 (0.3-1 Raspbian:stable [armhf])
Inst mesa-va-drivers (19.3.2-1~bpo10+1~rpt3 Raspberry Pi Foundation:testing [armhf])
Inst mesa-vdpau-drivers (19.3.2-1~bpo10+1~rpt3 Raspberry Pi Foundation:testing [armhf])
Inst pulseaudio-utils (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst pulseaudio (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst pulseaudio-module-bluetooth (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Inst rtkit (0.11-6 Raspbian:stable [armhf])
Inst va-driver-all (2.4.0-1 Raspbian:stable [armhf])
Inst vdpau-driver-all (1.1.1-10 Raspbian:stable [armhf])
Conf libical3 (3.0.4-3 Raspbian:stable [armhf])
Conf bluez-obexd (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Conf gnome-icon-theme (3.12.0-3 Raspbian:stable [all])
Conf libasyncns0 (0.8-6 Raspbian:stable [armhf])
Conf libogg0 (1.3.2-1+b2 Raspbian:stable [armhf])
Conf libflac8 (1.3.2-3 Raspbian:stable [armhf])
Conf libvorbis0a (1.3.6-2 Raspbian:stable [armhf])
Conf libvorbisenc2 (1.3.6-2 Raspbian:stable [armhf])
Conf libsndfile1 (1.0.28-6 Raspbian:stable [armhf])
Conf libpulse0 (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf libpulse-mainloop-glib0 (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf gir1.2-atk-1.0 (2.30.0-2 Raspbian:stable [armhf])
Conf gir1.2-freedesktop (1.58.3-2 Raspbian:stable [armhf])
Conf gir1.2-gdkpixbuf-2.0 (2.38.1+dfsg-1 Raspbian:stable [armhf])
Conf libpangoxft-1.0-0 (1.42.4-8~deb10u1 Raspbian:stable [armhf])
Conf gir1.2-pango-1.0 (1.42.4-8~deb10u1 Raspbian:stable [armhf])
Conf gir1.2-gtk-3.0 (3.24.5-1+rpt2 Raspberry Pi Foundation:testing [armhf])
Conf gir1.2-notify-0.7 (0.7.7-4 Raspbian:stable [armhf])
Conf python3-cairo (1.16.2-1+b1 Raspbian:stable [armhf])
Conf python3-gi-cairo (3.30.4-1 Raspbian:stable [armhf])
Conf libdbusmenu-glib4 (18.10.20180917~bzr490+repack1-1 Raspbian:stable [armhf])
Conf libdbusmenu-gtk3-4 (18.10.20180917~bzr490+repack1-1 Raspbian:stable [armhf])
Conf libindicator3-7 (0.5.0-4 Raspbian:stable [armhf])
Conf libappindicator3-1 (0.4.92-7 Raspbian:stable [armhf])
Conf gir1.2-appindicator3-0.1 (0.4.92-7 Raspbian:stable [armhf])
Conf blueman (2.0.8-1+deb10u1 Raspbian:stable [armhf])
Conf bluetooth (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [all])
Conf bluez-hcidump (5.50-1.2~deb10u1+rpt2 Raspberry Pi Foundation:testing [armhf])
Conf libaom0 (1.0.0-3 Raspbian:stable [armhf])
Conf libva2 (2.4.0-1 Raspbian:stable [armhf])
Conf libva-drm2 (2.4.0-1 Raspbian:stable [armhf])
Conf libva-x11-2 (2.4.0-1 Raspbian:stable [armhf])
Conf libvdpau1 (1.1.1-10 Raspbian:stable [armhf])
Conf libavutil56 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Conf libcodec2-0.8.1 (0.8.1-2 Raspbian:stable [armhf])
Conf libgsm1 (1.0.18-2 Raspbian:stable [armhf])
Conf libmp3lame0 (3.100-2+b1 Raspbian:stable [armhf])
Conf libopenjp2-7 (2.3.0-2+deb10u1 Raspbian:stable [armhf])
Conf libopus0 (1.3-1 Raspbian:stable [armhf])
Conf libshine3 (3.1.1-2+b1 Raspbian:stable [armhf])
Conf libspeex1 (1.2~rc1.2-1+b2 Raspbian:stable [armhf])
Conf libsoxr0 (0.1.2-3 Raspbian:stable [armhf])
Conf libswresample3 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Conf libtheora0 (1.1.1+dfsg.1-15 Raspbian:stable [armhf])
Conf libtwolame0 (0.3.13-4 Raspbian:stable [armhf])
Conf libvpx5 (1.7.0-3+deb10u1 Raspbian:stable [armhf])
Conf libwavpack1 (5.1.0-6 Raspbian:stable [armhf])
Conf libx264-155 (2:0.155.2917+git0a84d98-2+rpi1 Raspbian:stable [armhf])
Conf libx265-165 (2.9-4 Raspbian:stable [armhf])
Conf libxvidcore4 (2:1.3.5-1 Raspbian:stable [armhf])
Conf libzvbi-common (0.2.35-16 Raspbian:stable [all])
Conf libzvbi0 (0.2.35-16 Raspbian:stable [armhf])
Conf libavcodec58 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Conf libavresample4 (7:4.1.6-1~deb10u1+rpt1 Raspberry Pi Foundation:testing [armhf])
Conf libjack-jackd2-0 (1.9.12~dfsg-2 Raspbian:stable [armhf])
Conf libasound2-plugins (1.1.8-1 Raspbian:stable [armhf])
Conf libltdl7 (2.4.6-9 Raspbian:stable [armhf])
Conf liborc-0.4-0 (1:0.4.28-3.1 Raspbian:stable [armhf])
Conf libpulsedsp (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf libspeexdsp1 (1.2~rc1.2-1+b2 Raspbian:stable [armhf])
Conf libtdb1 (1.3.16-2+b1 Raspbian:stable [armhf])
Conf libvdpau-va-gl1 (0.4.2-1+b1 Raspbian:stable [armhf])
Conf libwebrtc-audio-processing1 (0.3-1 Raspbian:stable [armhf])
Conf mesa-va-drivers (19.3.2-1~bpo10+1~rpt3 Raspberry Pi Foundation:testing [armhf])
Conf mesa-vdpau-drivers (19.3.2-1~bpo10+1~rpt3 Raspberry Pi Foundation:testing [armhf])
Conf pulseaudio-utils (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf pulseaudio (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf pulseaudio-module-bluetooth (12.2-4+deb10u1+rpi3 Raspberry Pi Foundation:testing [armhf])
Conf rtkit (0.11-6 Raspbian:stable [armhf])
Conf va-driver-all (2.4.0-1 Raspbian:stable [armhf])
Conf vdpau-driver-all (1.1.1-10 Raspbian:stable [armhf])
borpin commented 3 years ago

sudo btmon

gives me lots of

> HCI Event: LE Meta Event (0x3e) plen 40                                                                                                                                    #232 [hci0] 9.823759
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Scannable undirected - ADV_SCAN_IND (0x02)
        Address type: Random (0x01)
        Address: 74:74:74:A6:EE:EE (Resolvable)
        Data length: 28
        16-bit Service UUIDs (complete): 1 entry
          Google (0xfe9f)
        Service Data (UUID 0xfe9f): 0000000000000000000000000000000000000000
        RSSI: -77 dBm (0xb3)
> HCI Event: LE Meta Event (0x3e) plen 22                                                                                                                                    #233 [hci0] 9.825763
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Scan response - SCAN_RSP (0x04)
        Address type: Random (0x01)
        Address: 74:74:74:A6:EE:EE (Resolvable)
        Data length: 10
        Company: Google (224)
          Data: 079aca59378b
        RSSI: -78 dBm (0xb2)
> HCI Event: LE Meta Event (0x3e) plen 40                                                                                                                                    #234 [hci0] 9.902769
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Scannable undirected - ADV_SCAN_IND (0x02)
        Address type: Random (0x01)
        Address: 6B:EF:0D:4D:62:7C (Resolvable)
        Data length: 28
        16-bit Service UUIDs (complete): 1 entry
          Google (0xfe9f)
        Service Data (UUID 0xfe9f): 0000000000000000000000000000000000000000
        RSSI: -84 dBm (0xac)
> HCI Event: LE Meta Event (0x3e) plen 22                                                                                                                                    #235 [hci0] 9.904768
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Scan response - SCAN_RSP (0x04)
        Address type: Random (0x01)
        Address: 6B:EF:0D:4D:62:7C (Resolvable)
        Data length: 10
        Company: Google (224)
          Data: 07cbca60c8c8
        RSSI: -82 dBm (0xae)
Ernst79 commented 3 years ago

I had the same, all this packages where gone after a apt-get update and upgrade. I have no idea why. They seem necessary to me. BTmon looks ok. No xiaomi messages, but they will probably show up. I would do a proper restart now. Lets see if this helped

borpin commented 3 years ago

Well that is the solution. How on earth the packages get deleted on upgrade!

It has been rock solid for 12 hours.

Thanks for your support and help @Ernst79 and keep up the good work 😄

vdemidov commented 3 years ago

I had similar problem. Component worked normally, but after some time and after errors: Bluetooth: hci0: Received unexpected HCI Event 00000000 dongle go down until physical restart or command sudo hciconfig hci0 up After install packages: sudo apt install bluetooth pi-bluetooth bluez blueman bluez-hcidump

It works well. No errors. No problem.