Skip to content

Commit 4c7a13b

Browse files
author
Zhou Xiao
committed
feat(ble): support controller raw log print out
(cherry picked from commit ed09e97) Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
1 parent 5be9ac3 commit 4c7a13b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

components/bt/common/ble_log/ble_log_spi_out.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
231231
// Initialization
232232
(*trans_cb)->buf_size = buf_size;
233233
(*trans_cb)->trans.tx_buffer = buf;
234+
(*trans_cb)->trans.user = (void *)(*trans_cb);
234235
return 0;
235236
}
236237

@@ -252,7 +253,7 @@ static void spi_out_deinit_trans(spi_out_trans_cb_t **trans_cb)
252253
IRAM_ATTR static void spi_out_tx_done_cb(spi_transaction_t *ret_trans)
253254
{
254255
last_tx_done_ts = esp_timer_get_time();
255-
spi_out_trans_cb_t *trans_cb = __containerof(ret_trans, spi_out_trans_cb_t, trans);
256+
spi_out_trans_cb_t *trans_cb = (spi_out_trans_cb_t *)ret_trans->user;
256257
trans_cb->length = 0;
257258
trans_cb->flag = TRANS_CB_FLAG_AVAILABLE;
258259
}
@@ -989,6 +990,17 @@ void ble_log_spi_out_ts_sync_stop(void)
989990
IRAM_ATTR void ble_log_spi_out_ll_write(uint32_t len, const uint8_t *addr, uint32_t len_append,
990991
const uint8_t *addr_append, uint32_t flag)
991992
{
993+
// Raw logs will come in case of assert, shall be printed to console directly
994+
if (flag & BIT(LL_LOG_FLAG_RAW)) {
995+
if (len && addr) {
996+
for (uint32_t i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); }
997+
}
998+
if (len_append && addr_append) {
999+
for (uint32_t i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); }
1000+
}
1001+
if (flag & BIT(LL_LOG_FLAG_END)) { esp_rom_printf("\n"); }
1002+
}
1003+
9921004
if (!ll_log_inited) {
9931005
return;
9941006
}

0 commit comments

Comments
 (0)