From 5045cb5eb885acb84d4ea86fbf9e5e0202cf0e84 Mon Sep 17 00:00:00 2001 From: Mayank Tyagi Date: Mon, 16 Mar 2026 12:56:31 +0530 Subject: [PATCH] feat(nimble): Add BLE HCI logging support for ESP Insights fix(nimble): Simplify esp insight ble logging --- nimble/host/src/ble_hs.c | 8 +++++++- nimble/host/src/ble_hs_hci.c | 6 ++++++ nimble/host/src/ble_hs_hci_cmd.c | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c index 35e0626b4..37be3793d 100644 --- a/nimble/host/src/ble_hs.c +++ b/nimble/host/src/ble_hs.c @@ -845,6 +845,9 @@ ble_hs_rx_data(struct os_mbuf *om, void *arg) data[0] = 0x02; os_mbuf_copydata(om, 0, len, &data[1]); bt_hci_log_record_hci_data(HCI_LOG_DATA_TYPE_C2H_ACL, &data[1], len); +#if BT_HCI_INSIGHTS_INCLUDED + bt_hci_log_record_insights(HCI_LOG_DATA_TYPE_C2H_ACL, &data[1], len); +#endif } #endif // (BT_HCI_LOG_INCLUDED == TRUE) @@ -881,7 +884,10 @@ ble_hs_tx_data(struct os_mbuf *om) uint8_t data[BLE_HS_HCI_LOG_BUF_SIZE]; data[0] = 0x02; os_mbuf_copydata(om, 0, pkt_len, &data[1]); - bt_hci_log_record_hci_data(data[0], &data[1], pkt_len); + bt_hci_log_record_hci_data(HCI_LOG_DATA_TYPE_H2C_ACL, &data[1], pkt_len); +#if BT_HCI_INSIGHTS_INCLUDED + bt_hci_log_record_insights(HCI_LOG_DATA_TYPE_H2C_ACL, &data[1], pkt_len); +#endif } #endif diff --git a/nimble/host/src/ble_hs_hci.c b/nimble/host/src/ble_hs_hci.c index ded79740b..746358ac8 100644 --- a/nimble/host/src/ble_hs_hci.c +++ b/nimble/host/src/ble_hs_hci.c @@ -706,8 +706,14 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg) uint16_t len = hci_ev[1] + 3; if (host_recv_adv_packet(hci_ev)) { bt_hci_log_record_hci_adv(HCI_LOG_DATA_TYPE_ADV, &hci_ev[1], len - 2); +#if BT_HCI_INSIGHTS_INCLUDED + bt_hci_log_record_insights(HCI_LOG_DATA_TYPE_ADV, &hci_ev[1], len - 2); +#endif } else { bt_hci_log_record_hci_data(0x04, &hci_ev[0], len - 1); +#if BT_HCI_INSIGHTS_INCLUDED + bt_hci_log_record_insights(0x04, &hci_ev[0], len - 1); +#endif } #endif // #if (BT_HCI_LOG_INCLUDED == TRUE) diff --git a/nimble/host/src/ble_hs_hci_cmd.c b/nimble/host/src/ble_hs_hci_cmd.c index 08afe2eeb..8278931b0 100644 --- a/nimble/host/src/ble_hs_hci_cmd.c +++ b/nimble/host/src/ble_hs_hci_cmd.c @@ -28,8 +28,6 @@ #if (BT_HCI_LOG_INCLUDED == TRUE) #include "hci_log/bt_hci_log.h" #endif // (BT_HCI_LOG_INCLUDED == TRUE) - - /* * HCI Command Header * @@ -102,6 +100,9 @@ ble_hs_hci_cmd_send(uint16_t opcode, uint8_t len, const void *cmddata) #if ((BT_HCI_LOG_INCLUDED == TRUE) && SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED) bt_hci_log_record_hci_data(0x01, (uint8_t *)buf, len + BLE_HCI_CMD_HDR_LEN); +#if BT_HCI_INSIGHTS_INCLUDED + bt_hci_log_record_insights(0x01, (uint8_t *)buf, len + BLE_HCI_CMD_HDR_LEN); +#endif #endif rc = ble_hs_hci_cmd_transport((void *) buf);