Components:
- BLE client device (CL)
- ESP-WROOM-32 (ESP32): details below
- Linux computer: details below
- Used as Bluetooth co-processor: it only provides bluetooth functionality to the main computer
- Firmware is configured and built with esp-idf, with (almost) latest version (ESP-IDF v5.4-dev-3201-g46acfdce96)
- Firmware is controller_hci_uart_esp32, accessible from esp-idf's examples
- Connected to the Linux computer with a full-featured UART (RX, TX, CTS, RTS) with 921600bps baud
- OS: Debian booksworm (Debian GNU/Linux 12)
- Kernel: 6.1.21-v8+
- BlueZ: 5.66
Code: Select all
/usr/bin/btattach -S 921600 -B /dev/ttyS0
Code: Select all
# hciconfig
hci0: Type: Primary Bus: UART
BD Address: AA:BB:CC:DD:EE:FF ACL MTU: 1021:9 SCO MTU: 255:4
UP RUNNING
RX bytes:7652480 acl:647 sco:0 events:213150 errors:0
TX bytes:44545 acl:788 sco:0 commands:2064 errors:0
Before continuing, let's see some details of the BLE client device (CL)
- After successful connection, it wants to increase the MTU (from 23 to 247)
- It can work with the base (23) MTU too, but then it will split it's messages up
I have investigated the problem a bit further and to be easier to understand, let's define two phases:
- Phase1 (testing): constant scanning, and occasional successful GATT connection
- Phase2 (testing failed): constant scanning works, but GATT connection fails
To be more exact: we don't receive ANY message replies (indications) above a certain (23 - assumed) length, and we consider that CL times out.
BUT! I investigated this even further: in case we don't accept the MTU raise request (therefore MTU stays the default 23), CL answers! (Or more fair: we CAN receive CL's reply).
So the problem is that in long-term the configuration can work perfectly, but after a couple of hours, raising MTU causing problems. I don't know, but I feel that ESP32 always receives the CL's response, but it doesn't transfer to us over HCI.
Important! In case I reset the ESP32 (and only that, all other components stays online), we can immediately jump back to Phase1, because MTU raise won't cause problems again for a couple of hours.
I hate these kind of errors, but really curious if anyone has some advice here. What shall we do?