ble_monitor: Multiple Bluetooth and hci errors
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 28
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.
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 š
I donāt have any hold back packages.
I did a dist upgrade yesterday to see if it would fix my issues, but that didnāt help.
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__.pyin this part.Lets start with
__init__.py. In the code, I think we should look in this part.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 followingcoroutine object BaseEventLoop._create_connection_transport at 0xadb9e328Next, 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?
But that doesnāt mean that
ble_monitoris the cause of your problem.ble_monitoris ā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.