feat(ble_log): encode HCI direction in ble_log pipeline

Add ble_log_write_hci macro that encodes upstream/downstream direction
in MSB of HCI type byte. Update all 4 callsites (NimBLE + Bluedroid)
to use the new macro. Parser reads MSB to determine direction;
backward compatible (old firmware MSB=0 defaults to "sent").


(cherry picked from commit 8fd5dbb730)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
This commit is contained in:
Zhou Xiao
2026-03-10 14:59:48 +08:00
parent 7a93173401
commit 034342fd5e
4 changed files with 19 additions and 5 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -38,6 +38,20 @@ typedef enum {
BLE_LOG_SRC_MAX,
} ble_log_src_t;
/* HCI Log Direction */
#define BLE_LOG_HCI_DOWNSTREAM 0
#define BLE_LOG_HCI_UPSTREAM 1
/* HCI Log Write Macro
* Encodes direction in MSB of data[0] (HCI type byte) before writing.
* Safe because ble_log_write_hex -> ble_log_lbm_write_trans does synchronous memcpy.
* Parser reads MSB to determine direction; old firmware with MSB=0 defaults to "sent". */
#define ble_log_write_hci(direction, data, len) do { \
(data)[0] |= ((direction) << 7); \
ble_log_write_hex(BLE_LOG_SRC_HCI, (data), (len)); \
(data)[0] &= 0x7F; \
} while (0)
/* INTERFACE */
bool ble_log_init(void);
void ble_log_deinit(void);