From da6cb6c741ba4297b3112b2d3b871e8c7f0c2e11 Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Wed, 25 Apr 2018 07:41:06 +0530 Subject: [PATCH] components/bt: Improve the Bluetooth debug messaging scheme As of now, when Bluetooth debugs are enabled, all the messages are mapped to BT_PRINTF which is mapped to ESP_LOGE. Hence, make monitor shows all logs in red color which might lead to missing the actual errors This patch maps the Bluetooth messages to appropriate ESP_LOG* messages and improves readability. Also, make the BT trace level be configurable in menuconfig, so that each layer of bt trace can be enabled/disabled. Finally, add debug log control for BTC, OSI, BLUFI and clear up Bluetooth debug logs. So, with this the method of enabling Bluetooth logs is as follows: 1. make menuconfig -> Component config -> Bluetooth -> Bluedroid Enable -> BT DEBUG LOG LEVEL -> set trace level for every layer of BT Signed-off-by: Hrishikesh Dhayagude --- components/bt/Kconfig | 743 +++++++++++++++++- components/bt/bluedroid/bta/dm/bta_dm_act.c | 2 +- components/bt/bluedroid/bta/dm/bta_dm_pm.c | 2 +- .../bt/bluedroid/bta/gatt/bta_gattc_act.c | 2 +- .../bt/bluedroid/bta/gatt/bta_gattc_cache.c | 5 +- .../bt/bluedroid/bta/gatt/bta_gattc_utils.c | 3 +- components/bt/bluedroid/bta/hh/bta_hh_api.c | 3 +- components/bt/bluedroid/bta/hh/bta_hh_le.c | 4 +- .../bt/bluedroid/bta/sys/bta_sys_main.c | 10 +- components/bt/bluedroid/btc/core/btc_alarm.c | 2 +- .../bt/bluedroid/btc/core/btc_ble_storage.c | 10 +- components/bt/bluedroid/btc/core/btc_config.c | 6 +- components/bt/bluedroid/btc/core/btc_dev.c | 2 +- components/bt/bluedroid/btc/core/btc_dm.c | 66 +- components/bt/bluedroid/btc/core/btc_main.c | 4 +- .../bt/bluedroid/btc/core/btc_profile_queue.c | 2 +- components/bt/bluedroid/btc/core/btc_sm.c | 10 +- .../bt/bluedroid/btc/core/btc_storage.c | 14 +- components/bt/bluedroid/btc/core/btc_task.c | 6 +- .../btc/profile/esp/ble_button/button_pro.c | 32 +- .../btc/profile/esp/blufi/blufi_prf.c | 90 +-- .../btc/profile/esp/blufi/blufi_protocol.c | 4 +- .../esp/wechat_AirSync/wx_airsync_prf.c | 8 +- .../btc/profile/std/a2dp/btc_a2dp_source.c | 6 +- .../bluedroid/btc/profile/std/a2dp/btc_av.c | 82 +- .../bluedroid/btc/profile/std/avrc/btc_avrc.c | 62 +- .../btc/profile/std/battery/battery_prf.c | 40 +- .../btc/profile/std/gap/btc_gap_ble.c | 90 +-- .../btc/profile/std/gap/btc_gap_bt.c | 10 +- .../btc/profile/std/gatt/btc_gatt_common.c | 4 +- .../btc/profile/std/gatt/btc_gatt_util.c | 8 +- .../btc/profile/std/gatt/btc_gattc.c | 24 +- .../btc/profile/std/gatt/btc_gatts.c | 50 +- .../btc/profile/std/hid_le/hid_le_prf.c | 40 +- .../bluedroid/btc/profile/std/spp/btc_spp.c | 62 +- .../common/include/common/bt_trace.h | 405 ++++++---- components/bt/bluedroid/hci/hci_hal_h4.c | 16 +- components/bt/bluedroid/hci/hci_layer.c | 28 +- .../bt/bluedroid/hci/hci_packet_parser.c | 2 +- .../bt/bluedroid/hci/packet_fragmenter.c | 10 +- components/bt/bluedroid/main/bte_main.c | 6 +- components/bt/bluedroid/osi/alarm.c | 38 +- components/bt/bluedroid/osi/allocator.c | 12 +- components/bt/bluedroid/osi/buffer.c | 4 +- components/bt/bluedroid/osi/config.c | 42 +- components/bt/bluedroid/osi/future.c | 6 +- .../bt/bluedroid/stack/btm/btm_ble_gap.c | 12 +- components/bt/bluedroid/stack/btm/btm_pm.c | 4 +- components/bt/bluedroid/stack/btm/btm_sec.c | 8 +- components/bt/bluedroid/stack/btu/btu_hcif.c | 2 +- components/bt/bluedroid/stack/btu/btu_task.c | 20 +- components/bt/bluedroid/stack/gatt/gatt_sr.c | 6 +- .../bt/bluedroid/stack/hcic/hciblecmds.c | 2 +- components/bt/bluedroid/stack/l2cap/l2c_api.c | 4 +- .../bt/bluedroid/stack/l2cap/l2c_main.c | 2 +- .../bt/bluedroid/stack/l2cap/l2cap_client.c | 36 +- .../bt/bluedroid/stack/rfcomm/port_api.c | 2 +- components/bt/bluedroid/stack/sdp/sdp_api.c | 2 +- 58 files changed, 1519 insertions(+), 658 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index b46f872317..37d660cf98 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -169,12 +169,753 @@ config BLE_SMP_ENABLE This option can be close when the app not used the ble security connect. config BT_STACK_NO_LOG - bool "Close the bluedroid bt stack log print" + bool "Disable BT debug logs (minimize bin size)" depends on BLUEDROID_ENABLED default n help This select can save the rodata code size +menu "BT DEBUG LOG LEVEL" + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + +choice HCI_INITIAL_TRACE_LEVEL + prompt "HCI layer" + default HCI_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for HCI layer + +config HCI_TRACE_LEVEL_NONE + bool "NONE" +config HCI_TRACE_LEVEL_ERROR + bool "ERROR" +config HCI_TRACE_LEVEL_WARNING + bool "WARNING" +config HCI_TRACE_LEVEL_API + bool "API" +config HCI_TRACE_LEVEL_EVENT + bool "EVENT" +config HCI_TRACE_LEVEL_DEBUG + bool "DEBUG" +config HCI_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config HCI_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if HCI_TRACE_LEVEL_NONE + default 1 if HCI_TRACE_LEVEL_ERROR + default 2 if HCI_TRACE_LEVEL_WARNING + default 3 if HCI_TRACE_LEVEL_API + default 4 if HCI_TRACE_LEVEL_EVENT + default 5 if HCI_TRACE_LEVEL_DEBUG + default 6 if HCI_TRACE_LEVEL_VERBOSE + default 2 + +choice BTM_INITIAL_TRACE_LEVEL + prompt "BTM layer" + default BTM_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for BTM layer + +config BTM_TRACE_LEVEL_NONE + bool "NONE" +config BTM_TRACE_LEVEL_ERROR + bool "ERROR" +config BTM_TRACE_LEVEL_WARNING + bool "WARNING" +config BTM_TRACE_LEVEL_API + bool "API" +config BTM_TRACE_LEVEL_EVENT + bool "EVENT" +config BTM_TRACE_LEVEL_DEBUG + bool "DEBUG" +config BTM_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config BTM_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if BTM_TRACE_LEVEL_NONE + default 1 if BTM_TRACE_LEVEL_ERROR + default 2 if BTM_TRACE_LEVEL_WARNING + default 3 if BTM_TRACE_LEVEL_API + default 4 if BTM_TRACE_LEVEL_EVENT + default 5 if BTM_TRACE_LEVEL_DEBUG + default 6 if BTM_TRACE_LEVEL_VERBOSE + default 2 + +choice L2CAP_INITIAL_TRACE_LEVEL + prompt "L2CAP layer" + default L2CAP_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for L2CAP layer + +config L2CAP_TRACE_LEVEL_NONE + bool "NONE" +config L2CAP_TRACE_LEVEL_ERROR + bool "ERROR" +config L2CAP_TRACE_LEVEL_WARNING + bool "WARNING" +config L2CAP_TRACE_LEVEL_API + bool "API" +config L2CAP_TRACE_LEVEL_EVENT + bool "EVENT" +config L2CAP_TRACE_LEVEL_DEBUG + bool "DEBUG" +config L2CAP_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config L2CAP_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if L2CAP_TRACE_LEVEL_NONE + default 1 if L2CAP_TRACE_LEVEL_ERROR + default 2 if L2CAP_TRACE_LEVEL_WARNING + default 3 if L2CAP_TRACE_LEVEL_API + default 4 if L2CAP_TRACE_LEVEL_EVENT + default 5 if L2CAP_TRACE_LEVEL_DEBUG + default 6 if L2CAP_TRACE_LEVEL_VERBOSE + default 2 + +choice RFCOMM_INITIAL_TRACE_LEVEL + prompt "RFCOMM layer" + default RFCOMM_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for RFCOMM layer + +config RFCOMM_TRACE_LEVEL_NONE + bool "NONE" +config RFCOMM_TRACE_LEVEL_ERROR + bool "ERROR" +config RFCOMM_TRACE_LEVEL_WARNING + bool "WARNING" +config RFCOMM_TRACE_LEVEL_API + bool "API" +config RFCOMM_TRACE_LEVEL_EVENT + bool "EVENT" +config RFCOMM_TRACE_LEVEL_DEBUG + bool "DEBUG" +config RFCOMM_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config RFCOMM_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if RFCOMM_TRACE_LEVEL_NONE + default 1 if RFCOMM_TRACE_LEVEL_ERROR + default 2 if RFCOMM_TRACE_LEVEL_WARNING + default 3 if RFCOMM_TRACE_LEVEL_API + default 4 if RFCOMM_TRACE_LEVEL_EVENT + default 5 if RFCOMM_TRACE_LEVEL_DEBUG + default 6 if RFCOMM_TRACE_LEVEL_VERBOSE + default 2 + +choice SDP_INITIAL_TRACE_LEVEL + prompt "SDP layer" + default SDP_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for SDP layer + +config SDP_TRACE_LEVEL_NONE + bool "NONE" +config SDP_TRACE_LEVEL_ERROR + bool "ERROR" +config SDP_TRACE_LEVEL_WARNING + bool "WARNING" +config SDP_TRACE_LEVEL_API + bool "API" +config SDP_TRACE_LEVEL_EVENT + bool "EVENT" +config SDP_TRACE_LEVEL_DEBUG + bool "DEBUG" +config SDP_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config SDP_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if SDP_TRACE_LEVEL_NONE + default 1 if SDP_TRACE_LEVEL_ERROR + default 2 if SDP_TRACE_LEVEL_WARNING + default 3 if SDP_TRACE_LEVEL_API + default 4 if SDP_TRACE_LEVEL_EVENT + default 5 if SDP_TRACE_LEVEL_DEBUG + default 6 if SDP_TRACE_LEVEL_VERBOSE + default 2 + +choice GAP_INITIAL_TRACE_LEVEL + prompt "GAP layer" + default GAP_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for GAP layer + +config GAP_TRACE_LEVEL_NONE + bool "NONE" +config GAP_TRACE_LEVEL_ERROR + bool "ERROR" +config GAP_TRACE_LEVEL_WARNING + bool "WARNING" +config GAP_TRACE_LEVEL_API + bool "API" +config GAP_TRACE_LEVEL_EVENT + bool "EVENT" +config GAP_TRACE_LEVEL_DEBUG + bool "DEBUG" +config GAP_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config GAP_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if GAP_TRACE_LEVEL_NONE + default 1 if GAP_TRACE_LEVEL_ERROR + default 2 if GAP_TRACE_LEVEL_WARNING + default 3 if GAP_TRACE_LEVEL_API + default 4 if GAP_TRACE_LEVEL_EVENT + default 5 if GAP_TRACE_LEVEL_DEBUG + default 6 if GAP_TRACE_LEVEL_VERBOSE + default 2 + +choice BNEP_INITIAL_TRACE_LEVEL + prompt "BNEP layer" + default BNEP_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for BNEP layer + +config BNEP_TRACE_LEVEL_NONE + bool "NONE" +config BNEP_TRACE_LEVEL_ERROR + bool "ERROR" +config BNEP_TRACE_LEVEL_WARNING + bool "WARNING" +config BNEP_TRACE_LEVEL_API + bool "API" +config BNEP_TRACE_LEVEL_EVENT + bool "EVENT" +config BNEP_TRACE_LEVEL_DEBUG + bool "DEBUG" +config BNEP_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config BNEP_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if BNEP_TRACE_LEVEL_NONE + default 1 if BNEP_TRACE_LEVEL_ERROR + default 2 if BNEP_TRACE_LEVEL_WARNING + default 3 if BNEP_TRACE_LEVEL_API + default 4 if BNEP_TRACE_LEVEL_EVENT + default 5 if BNEP_TRACE_LEVEL_DEBUG + default 6 if BNEP_TRACE_LEVEL_VERBOSE + default 2 + +choice PAN_INITIAL_TRACE_LEVEL + prompt "PAN layer" + default PAN_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for PAN layer + +config PAN_TRACE_LEVEL_NONE + bool "NONE" +config PAN_TRACE_LEVEL_ERROR + bool "ERROR" +config PAN_TRACE_LEVEL_WARNING + bool "WARNING" +config PAN_TRACE_LEVEL_API + bool "API" +config PAN_TRACE_LEVEL_EVENT + bool "EVENT" +config PAN_TRACE_LEVEL_DEBUG + bool "DEBUG" +config PAN_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config PAN_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if PAN_TRACE_LEVEL_NONE + default 1 if PAN_TRACE_LEVEL_ERROR + default 2 if PAN_TRACE_LEVEL_WARNING + default 3 if PAN_TRACE_LEVEL_API + default 4 if PAN_TRACE_LEVEL_EVENT + default 5 if PAN_TRACE_LEVEL_DEBUG + default 6 if PAN_TRACE_LEVEL_VERBOSE + default 2 + +choice A2D_INITIAL_TRACE_LEVEL + prompt "A2D layer" + default A2D_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for A2D layer + +config A2D_TRACE_LEVEL_NONE + bool "NONE" +config A2D_TRACE_LEVEL_ERROR + bool "ERROR" +config A2D_TRACE_LEVEL_WARNING + bool "WARNING" +config A2D_TRACE_LEVEL_API + bool "API" +config A2D_TRACE_LEVEL_EVENT + bool "EVENT" +config A2D_TRACE_LEVEL_DEBUG + bool "DEBUG" +config A2D_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config A2D_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if A2D_TRACE_LEVEL_NONE + default 1 if A2D_TRACE_LEVEL_ERROR + default 2 if A2D_TRACE_LEVEL_WARNING + default 3 if A2D_TRACE_LEVEL_API + default 4 if A2D_TRACE_LEVEL_EVENT + default 5 if A2D_TRACE_LEVEL_DEBUG + default 6 if A2D_TRACE_LEVEL_VERBOSE + default 2 + +choice AVDT_INITIAL_TRACE_LEVEL + prompt "AVDT layer" + default AVDT_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for AVDT layer + +config AVDT_TRACE_LEVEL_NONE + bool "NONE" +config AVDT_TRACE_LEVEL_ERROR + bool "ERROR" +config AVDT_TRACE_LEVEL_WARNING + bool "WARNING" +config AVDT_TRACE_LEVEL_API + bool "API" +config AVDT_TRACE_LEVEL_EVENT + bool "EVENT" +config AVDT_TRACE_LEVEL_DEBUG + bool "DEBUG" +config AVDT_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config AVDT_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if AVDT_TRACE_LEVEL_NONE + default 1 if AVDT_TRACE_LEVEL_ERROR + default 2 if AVDT_TRACE_LEVEL_WARNING + default 3 if AVDT_TRACE_LEVEL_API + default 4 if AVDT_TRACE_LEVEL_EVENT + default 5 if AVDT_TRACE_LEVEL_DEBUG + default 6 if AVDT_TRACE_LEVEL_VERBOSE + default 2 + +choice AVCT_INITIAL_TRACE_LEVEL + prompt "AVCT layer" + default AVCT_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for AVCT layer + +config AVCT_TRACE_LEVEL_NONE + bool "NONE" +config AVCT_TRACE_LEVEL_ERROR + bool "ERROR" +config AVCT_TRACE_LEVEL_WARNING + bool "WARNING" +config AVCT_TRACE_LEVEL_API + bool "API" +config AVCT_TRACE_LEVEL_EVENT + bool "EVENT" +config AVCT_TRACE_LEVEL_DEBUG + bool "DEBUG" +config AVCT_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config AVCT_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if AVCT_TRACE_LEVEL_NONE + default 1 if AVCT_TRACE_LEVEL_ERROR + default 2 if AVCT_TRACE_LEVEL_WARNING + default 3 if AVCT_TRACE_LEVEL_API + default 4 if AVCT_TRACE_LEVEL_EVENT + default 5 if AVCT_TRACE_LEVEL_DEBUG + default 6 if AVCT_TRACE_LEVEL_VERBOSE + default 2 + +choice AVRC_INITIAL_TRACE_LEVEL + prompt "AVRC layer" + default AVRC_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for AVRC layer + +config AVRC_TRACE_LEVEL_NONE + bool "NONE" +config AVRC_TRACE_LEVEL_ERROR + bool "ERROR" +config AVRC_TRACE_LEVEL_WARNING + bool "WARNING" +config AVRC_TRACE_LEVEL_API + bool "API" +config AVRC_TRACE_LEVEL_EVENT + bool "EVENT" +config AVRC_TRACE_LEVEL_DEBUG + bool "DEBUG" +config AVRC_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config AVRC_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if AVRC_TRACE_LEVEL_NONE + default 1 if AVRC_TRACE_LEVEL_ERROR + default 2 if AVRC_TRACE_LEVEL_WARNING + default 3 if AVRC_TRACE_LEVEL_API + default 4 if AVRC_TRACE_LEVEL_EVENT + default 5 if AVRC_TRACE_LEVEL_DEBUG + default 6 if AVRC_TRACE_LEVEL_VERBOSE + default 2 + +choice MCA_INITIAL_TRACE_LEVEL + prompt "MCA layer" + default MCA_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for MCA layer + +config MCA_TRACE_LEVEL_NONE + bool "NONE" +config MCA_TRACE_LEVEL_ERROR + bool "ERROR" +config MCA_TRACE_LEVEL_WARNING + bool "WARNING" +config MCA_TRACE_LEVEL_API + bool "API" +config MCA_TRACE_LEVEL_EVENT + bool "EVENT" +config MCA_TRACE_LEVEL_DEBUG + bool "DEBUG" +config MCA_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config MCA_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if MCA_TRACE_LEVEL_NONE + default 1 if MCA_TRACE_LEVEL_ERROR + default 2 if MCA_TRACE_LEVEL_WARNING + default 3 if MCA_TRACE_LEVEL_API + default 4 if MCA_TRACE_LEVEL_EVENT + default 5 if MCA_TRACE_LEVEL_DEBUG + default 6 if MCA_TRACE_LEVEL_VERBOSE + default 2 + +choice HID_INITIAL_TRACE_LEVEL + prompt "HID layer" + default HID_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for HID layer + +config HID_TRACE_LEVEL_NONE + bool "NONE" +config HID_TRACE_LEVEL_ERROR + bool "ERROR" +config HID_TRACE_LEVEL_WARNING + bool "WARNING" +config HID_TRACE_LEVEL_API + bool "API" +config HID_TRACE_LEVEL_EVENT + bool "EVENT" +config HID_TRACE_LEVEL_DEBUG + bool "DEBUG" +config HID_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config HID_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if HID_TRACE_LEVEL_NONE + default 1 if HID_TRACE_LEVEL_ERROR + default 2 if HID_TRACE_LEVEL_WARNING + default 3 if HID_TRACE_LEVEL_API + default 4 if HID_TRACE_LEVEL_EVENT + default 5 if HID_TRACE_LEVEL_DEBUG + default 6 if HID_TRACE_LEVEL_VERBOSE + default 2 + +choice APPL_INITIAL_TRACE_LEVEL + prompt "APPL layer" + default APPL_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for APPL layer + +config APPL_TRACE_LEVEL_NONE + bool "NONE" +config APPL_TRACE_LEVEL_ERROR + bool "ERROR" +config APPL_TRACE_LEVEL_WARNING + bool "WARNING" +config APPL_TRACE_LEVEL_API + bool "API" +config APPL_TRACE_LEVEL_EVENT + bool "EVENT" +config APPL_TRACE_LEVEL_DEBUG + bool "DEBUG" +config APPL_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config APPL_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if APPL_TRACE_LEVEL_NONE + default 1 if APPL_TRACE_LEVEL_ERROR + default 2 if APPL_TRACE_LEVEL_WARNING + default 3 if APPL_TRACE_LEVEL_API + default 4 if APPL_TRACE_LEVEL_EVENT + default 5 if APPL_TRACE_LEVEL_DEBUG + default 6 if APPL_TRACE_LEVEL_VERBOSE + default 2 + +choice GATT_INITIAL_TRACE_LEVEL + prompt "GATT layer" + default GATT_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for GATT layer + +config GATT_TRACE_LEVEL_NONE + bool "NONE" +config GATT_TRACE_LEVEL_ERROR + bool "ERROR" +config GATT_TRACE_LEVEL_WARNING + bool "WARNING" +config GATT_TRACE_LEVEL_API + bool "API" +config GATT_TRACE_LEVEL_EVENT + bool "EVENT" +config GATT_TRACE_LEVEL_DEBUG + bool "DEBUG" +config GATT_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config GATT_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if GATT_TRACE_LEVEL_NONE + default 1 if GATT_TRACE_LEVEL_ERROR + default 2 if GATT_TRACE_LEVEL_WARNING + default 3 if GATT_TRACE_LEVEL_API + default 4 if GATT_TRACE_LEVEL_EVENT + default 5 if GATT_TRACE_LEVEL_DEBUG + default 6 if GATT_TRACE_LEVEL_VERBOSE + default 2 + +choice SMP_INITIAL_TRACE_LEVEL + prompt "SMP layer" + default SMP_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for SMP layer + +config SMP_TRACE_LEVEL_NONE + bool "NONE" +config SMP_TRACE_LEVEL_ERROR + bool "ERROR" +config SMP_TRACE_LEVEL_WARNING + bool "WARNING" +config SMP_TRACE_LEVEL_API + bool "API" +config SMP_TRACE_LEVEL_EVENT + bool "EVENT" +config SMP_TRACE_LEVEL_DEBUG + bool "DEBUG" +config SMP_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config SMP_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if SMP_TRACE_LEVEL_NONE + default 1 if SMP_TRACE_LEVEL_ERROR + default 2 if SMP_TRACE_LEVEL_WARNING + default 3 if SMP_TRACE_LEVEL_API + default 4 if SMP_TRACE_LEVEL_EVENT + default 5 if SMP_TRACE_LEVEL_DEBUG + default 6 if SMP_TRACE_LEVEL_VERBOSE + default 2 + +choice BTIF_INITIAL_TRACE_LEVEL + prompt "BTIF layer" + default BTIF_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for BTIF layer + +config BTIF_TRACE_LEVEL_NONE + bool "NONE" +config BTIF_TRACE_LEVEL_ERROR + bool "ERROR" +config BTIF_TRACE_LEVEL_WARNING + bool "WARNING" +config BTIF_TRACE_LEVEL_API + bool "API" +config BTIF_TRACE_LEVEL_EVENT + bool "EVENT" +config BTIF_TRACE_LEVEL_DEBUG + bool "DEBUG" +config BTIF_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config BTIF_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if BTIF_TRACE_LEVEL_NONE + default 1 if BTIF_TRACE_LEVEL_ERROR + default 2 if BTIF_TRACE_LEVEL_WARNING + default 3 if BTIF_TRACE_LEVEL_API + default 4 if BTIF_TRACE_LEVEL_EVENT + default 5 if BTIF_TRACE_LEVEL_DEBUG + default 6 if BTIF_TRACE_LEVEL_VERBOSE + default 2 + +choice BTC_INITIAL_TRACE_LEVEL + prompt "BTC layer" + default BTC_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for BTC layer + +config BTC_TRACE_LEVEL_NONE + bool "NONE" +config BTC_TRACE_LEVEL_ERROR + bool "ERROR" +config BTC_TRACE_LEVEL_WARNING + bool "WARNING" +config BTC_TRACE_LEVEL_API + bool "API" +config BTC_TRACE_LEVEL_EVENT + bool "EVENT" +config BTC_TRACE_LEVEL_DEBUG + bool "DEBUG" +config BTC_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config BTC_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if BTC_TRACE_LEVEL_NONE + default 1 if BTC_TRACE_LEVEL_ERROR + default 2 if BTC_TRACE_LEVEL_WARNING + default 3 if BTC_TRACE_LEVEL_API + default 4 if BTC_TRACE_LEVEL_EVENT + default 5 if BTC_TRACE_LEVEL_DEBUG + default 6 if BTC_TRACE_LEVEL_VERBOSE + default 2 + +choice OSI_INITIAL_TRACE_LEVEL + prompt "OSI layer" + default OSI_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for OSI layer + +config OSI_TRACE_LEVEL_NONE + bool "NONE" +config OSI_TRACE_LEVEL_ERROR + bool "ERROR" +config OSI_TRACE_LEVEL_WARNING + bool "WARNING" +config OSI_TRACE_LEVEL_API + bool "API" +config OSI_TRACE_LEVEL_EVENT + bool "EVENT" +config OSI_TRACE_LEVEL_DEBUG + bool "DEBUG" +config OSI_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config OSI_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if OSI_TRACE_LEVEL_NONE + default 1 if OSI_TRACE_LEVEL_ERROR + default 2 if OSI_TRACE_LEVEL_WARNING + default 3 if OSI_TRACE_LEVEL_API + default 4 if OSI_TRACE_LEVEL_EVENT + default 5 if OSI_TRACE_LEVEL_DEBUG + default 6 if OSI_TRACE_LEVEL_VERBOSE + default 2 + +choice BLUFI_INITIAL_TRACE_LEVEL + prompt "BLUFI layer" + default BLUFI_TRACE_LEVEL_WARNING + depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG + help + Define BT trace level for BLUFI layer + +config BLUFI_TRACE_LEVEL_NONE + bool "NONE" +config BLUFI_TRACE_LEVEL_ERROR + bool "ERROR" +config BLUFI_TRACE_LEVEL_WARNING + bool "WARNING" +config BLUFI_TRACE_LEVEL_API + bool "API" +config BLUFI_TRACE_LEVEL_EVENT + bool "EVENT" +config BLUFI_TRACE_LEVEL_DEBUG + bool "DEBUG" +config BLUFI_TRACE_LEVEL_VERBOSE + bool "VERBOSE" +endchoice + +config BLUFI_INITIAL_TRACE_LEVEL + int + depends on BLUEDROID_ENABLED + default 0 if BLUFI_TRACE_LEVEL_NONE + default 1 if BLUFI_TRACE_LEVEL_ERROR + default 2 if BLUFI_TRACE_LEVEL_WARNING + default 3 if BLUFI_TRACE_LEVEL_API + default 4 if BLUFI_TRACE_LEVEL_EVENT + default 5 if BLUFI_TRACE_LEVEL_DEBUG + default 6 if BLUFI_TRACE_LEVEL_VERBOSE + default 2 + +endmenu #BT DEBUG LOG LEVEL + + config BT_ACL_CONNECTIONS int "BT/BLE MAX ACL CONNECTIONS(1~7)" depends on BLUEDROID_ENABLED diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 3bf5487731..3985dc839d 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -5529,7 +5529,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id) APPL_TRACE_ERROR("%s out of room to accomodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used ); } - LOG_INFO("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len); + APPL_TRACE_API("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len); if ( bta_dm_search_cb.state != BTA_DM_SEARCH_IDLE) { /* send result back to app now, one by one */ diff --git a/components/bt/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/bluedroid/bta/dm/bta_dm_pm.c index 3354a33b2a..a876ec36a9 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_pm.c @@ -595,7 +595,7 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request, if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX) { remaining_ticks = bta_dm_pm_get_remaining_ticks(&bta_dm_cb.pm_timer[i].timer[timer_idx]); if (remaining_ticks < timeout) { - LOG_DEBUG("%s remain 0\n", __func__); + APPL_TRACE_DEBUG("%s remain 0\n", __func__); /* Cancel and restart the timer */ /* * TODO: The value of pm_action[timer_idx] is diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c index 8eace1a0a1..e836003dd4 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c @@ -2198,7 +2198,7 @@ void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) } /* if listen to all */ else { - LOG_DEBUG("Listen For All now"); + APPL_TRACE_DEBUG("Listen For All now"); /* go through all connected device and send callback for all connected slave connection */ bta_gattc_process_listen_all(p_msg->api_listen.client_if); diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c index b17dc9ec0e..8a5625356c 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c @@ -40,7 +40,6 @@ #include "btm_int.h" #include "errno.h" -#define LOG_TAG "bt_bta_gattc" // #include "osi/include/log.h" static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb); @@ -106,7 +105,7 @@ bool display_cache_attribute(void *data, void *context) bool display_cache_service(void *data, void *context) { tBTA_GATTC_SERVICE *p_cur_srvc = data; - LOG_INFO("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]", + APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]", p_cur_srvc->s_handle, p_cur_srvc->e_handle, ((p_cur_srvc->uuid.len == 2) ? "uuid16" : "uuid128"), p_cur_srvc->uuid.uu.uuid16, @@ -611,7 +610,7 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb) p_srvc_cb->update_sec_sev = false; } /* no service found at all, the end of server discovery*/ - LOG_DEBUG("%s no more services found", __func__); + APPL_TRACE_DEBUG("%s no more services found", __func__); #if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE) bta_gattc_display_cache_server(p_srvc_cb->p_srvc_cache); diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c index 9b3e5c0308..774134478b 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c @@ -36,7 +36,6 @@ #include "stack/l2c_api.h" #include "osi/allocator.h" -#define LOG_TAG "bt_bta_gattc" /***************************************************************************** ** Constants *****************************************************************************/ @@ -963,7 +962,7 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src) break; default: - LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len); + APPL_TRACE_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len); break; } } diff --git a/components/bt/bluedroid/bta/hh/bta_hh_api.c b/components/bt/bluedroid/bta/hh/bta_hh_api.c index ed96d8ee72..43f7542872 100644 --- a/components/bt/bluedroid/bta/hh/bta_hh_api.c +++ b/components/bt/bluedroid/bta/hh/bta_hh_api.c @@ -35,7 +35,6 @@ #include "stack/l2c_api.h" #include "bta/utl.h" -#define LOG_TAG "bt_bta_hh" #include "osi/include/log.h" /***************************************************************************** @@ -67,7 +66,7 @@ void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback) /* register with BTA system manager */ bta_sys_register(BTA_ID_HH, &bta_hh_reg); - LOG_INFO("%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback); + APPL_TRACE_API("%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback); p_buf = (tBTA_HH_API_ENABLE *)osi_malloc((UINT16)sizeof(tBTA_HH_API_ENABLE)); if (p_buf != NULL) { diff --git a/components/bt/bluedroid/bta/hh/bta_hh_le.c b/components/bt/bluedroid/bta/hh/bta_hh_le.c index 78eca9c2b8..9f61be4158 100644 --- a/components/bt/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/bluedroid/bta/hh/bta_hh_le.c @@ -613,7 +613,7 @@ tBTA_HH_STATUS bta_hh_le_read_char_dscrpt(tBTA_HH_DEV_CB *p_cb, UINT16 srvc_uuid status = BTA_HH_OK; } else { #if BTA_HH_DEBUG == TRUE - LOG_WARN("%s No descriptor exists: %s(0x%04x)", __func__, + APPL_TRACE_WARNING("%s No descriptor exists: %s(0x%04x)", __func__, bta_hh_uuid_to_str(char_descp_uuid), char_descp_uuid); #endif } @@ -1092,7 +1092,7 @@ void bta_hh_le_expl_rpt(tBTA_HH_DEV_CB *p_dev_cb, p_char_id = &char_result; } while (1); - LOG_INFO("%s all BLE reports searched", __func__); + APPL_TRACE_API("%s all BLE reports searched", __func__); bta_hh_le_read_rpt_ref_descr(p_dev_cb, &p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].report[0]); diff --git a/components/bt/bluedroid/bta/sys/bta_sys_main.c b/components/bt/bluedroid/bta/sys/bta_sys_main.c index 3efd2a39d8..e3b8c77fa9 100644 --- a/components/bt/bluedroid/bta/sys/bta_sys_main.c +++ b/components/bt/bluedroid/bta/sys/bta_sys_main.c @@ -59,8 +59,8 @@ static osi_mutex_t bta_alarm_lock; /* trace level */ /* TODO Bluedroid - Hard-coded trace levels - Needs to be configurable */ -UINT8 appl_trace_level = BT_TRACE_LEVEL_WARNING; //APPL_INITIAL_TRACE_LEVEL; -UINT8 btif_trace_level = BT_TRACE_LEVEL_WARNING; +UINT8 appl_trace_level = APPL_INITIAL_TRACE_LEVEL; +UINT8 btif_trace_level = BTIF_INITIAL_TRACE_LEVEL; void btu_bta_alarm_ready(fixed_queue_t *queue); @@ -607,7 +607,7 @@ void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms) osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_ERROR("%s unable to create alarm.", __func__); + APPL_TRACE_ERROR("%s unable to create alarm.", __func__); return; } @@ -651,7 +651,7 @@ void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle) osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__); + APPL_TRACE_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__); return; } osi_alarm_cancel(alarm); @@ -672,7 +672,7 @@ void bta_sys_free_timer(TIMER_LIST_ENT *p_tle) osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__); + APPL_TRACE_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__); return; } osi_alarm_cancel(alarm); diff --git a/components/bt/bluedroid/btc/core/btc_alarm.c b/components/bt/bluedroid/btc/core/btc_alarm.c index 9d8d52bcac..ade9f093ac 100644 --- a/components/bt/bluedroid/btc/core/btc_alarm.c +++ b/components/bt/bluedroid/btc/core/btc_alarm.c @@ -19,7 +19,7 @@ void btc_alarm_handler(btc_msg_t *msg) { btc_alarm_args_t *arg = (btc_alarm_args_t *)msg->arg; - LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act); if (arg->cb) { arg->cb(arg->cb_data); diff --git a/components/bt/bluedroid/btc/core/btc_ble_storage.c b/components/bt/bluedroid/btc/core/btc_ble_storage.c index b0dbf2f9e5..bb42810fc4 100644 --- a/components/bt/bluedroid/btc/core/btc_ble_storage.c +++ b/components/bt/bluedroid/btc/core/btc_ble_storage.c @@ -645,7 +645,7 @@ static void _btc_read_le_key(const uint8_t key_type, const size_t key_len, bt_bd } char bd_str[20] = {0}; - LOG_DEBUG("%s() Adding key type %d for %s", __func__, + BTC_TRACE_DEBUG("%s() Adding key type %d for %s", __func__, key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str))); BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type); } @@ -663,7 +663,7 @@ static bt_status_t _btc_storage_in_fetch_bonded_ble_device(const char *remote_bd bool key_found = false; if (!btc_config_get_int(remote_bd_addr, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type)) { - LOG_ERROR("%s, device_type = %x", __func__, device_type); + BTC_TRACE_ERROR("%s, device_type = %x", __func__, device_type); return BT_STATUS_FAIL; } @@ -715,9 +715,9 @@ static bt_status_t btc_storage_in_fetch_bonded_ble_devices(int add) ((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) { continue; } - LOG_DEBUG("%s, name = %s", __func__, name); + BTC_TRACE_DEBUG("%s, name = %s", __func__, name); if (_btc_storage_in_fetch_bonded_ble_device(name, add) != BT_STATUS_SUCCESS) { - LOG_DEBUG("Remote device:%s, no link key or ble key found", name); + BTC_TRACE_DEBUG("Remote device:%s, no link key or ble key found", name); } else { status = BT_STATUS_SUCCESS; } @@ -743,7 +743,7 @@ bt_status_t btc_storage_load_bonded_ble_devices(void) { bt_status_t status; status = btc_storage_in_fetch_bonded_ble_devices(1); - LOG_DEBUG("Storage load rslt %d\n", status); + BTC_TRACE_DEBUG("Storage load rslt %d\n", status); return status; } diff --git a/components/bt/bluedroid/btc/core/btc_config.c b/components/bt/bluedroid/btc/core/btc_config.c index 4a859340b2..b987a32e0c 100644 --- a/components/bt/bluedroid/btc/core/btc_config.c +++ b/components/bt/bluedroid/btc/core/btc_config.c @@ -73,10 +73,10 @@ bool btc_config_init(void) osi_mutex_new(&lock); config = config_new(CONFIG_FILE_PATH); if (!config) { - LOG_WARN("%s unable to load config file; starting unconfigured.\n", __func__); + BTC_TRACE_WARNING("%s unable to load config file; starting unconfigured.\n", __func__); config = config_new_empty(); if (!config) { - LOG_ERROR("%s unable to allocate a config object.\n", __func__); + BTC_TRACE_ERROR("%s unable to allocate a config object.\n", __func__); goto error; } } @@ -90,7 +90,7 @@ error:; config_free(config); osi_mutex_free(&lock); config = NULL; - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return false; } diff --git a/components/bt/bluedroid/btc/core/btc_dev.c b/components/bt/bluedroid/btc/core/btc_dev.c index 976e5a16c6..b5c85b9651 100644 --- a/components/bt/bluedroid/btc/core/btc_dev.c +++ b/components/bt/bluedroid/btc/core/btc_dev.c @@ -22,7 +22,7 @@ void btc_dev_call_handler(btc_msg_t *msg) { btc_dev_args_t *arg = (btc_dev_args_t *)msg->arg; - LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act); switch (msg->act) { case BTC_DEV_ACT_SET_DEVICE_NAME: diff --git a/components/bt/bluedroid/btc/core/btc_dm.c b/components/bt/bluedroid/btc/core/btc_dm.c index 8bc2370ad4..89ca9e0be0 100644 --- a/components/bt/bluedroid/btc/core/btc_dm.c +++ b/components/bt/bluedroid/btc/core/btc_dm.c @@ -128,7 +128,7 @@ static void btc_enable_bluetooth_evt(tBTA_STATUS status) static void btc_disable_bluetooth_evt(void) { - LOG_DEBUG("%s", __FUNCTION__); + BTC_TRACE_DEBUG("%s", __FUNCTION__); future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_SUCCESS); } @@ -141,7 +141,7 @@ void btc_dm_load_ble_local_keys(void) if (btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_ER,(char*)&ble_local_key_cb.er[0], BT_OCTET16_LEN)== BT_STATUS_SUCCESS) { ble_local_key_cb.is_er_rcvd = TRUE; - LOG_DEBUG("%s BLE ER key loaded",__func__ ); + BTC_TRACE_DEBUG("%s BLE ER key loaded",__func__ ); } if ((btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_IR,(char*)&ble_local_key_cb.id_keys.ir[0], @@ -151,7 +151,7 @@ void btc_dm_load_ble_local_keys(void) (btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_DHK,(char*)&ble_local_key_cb.id_keys.dhk[0], BT_OCTET16_LEN)== BT_STATUS_SUCCESS)) { ble_local_key_cb.is_id_keys_rcvd = TRUE; - LOG_DEBUG("%s BLE ID keys loaded", __func__); + BTC_TRACE_DEBUG("%s BLE ID keys loaded", __func__); } } @@ -169,14 +169,14 @@ void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET1 memcpy(&p_id_keys->dhk[0], &ble_local_key_cb.id_keys.dhk[0], sizeof(BT_OCTET16)); *p_key_mask |= BTA_BLE_LOCAL_KEY_TYPE_ID; } - LOG_DEBUG("%s *p_key_mask=0x%02x",__func__, *p_key_mask); + BTC_TRACE_DEBUG("%s *p_key_mask=0x%02x",__func__, *p_key_mask); } static void btc_dm_remove_ble_bonding_keys(void) { bt_bdaddr_t bd_addr; - LOG_DEBUG("%s\n",__func__); + BTC_TRACE_DEBUG("%s\n",__func__); bdcpy(bd_addr.address, pairing_cb.bd_addr); @@ -192,7 +192,7 @@ static void btc_dm_save_ble_bonding_keys(void) bdcpy(bd_addr.address, pairing_cb.bd_addr); btc_storage_set_ble_dev_type(&bd_addr, false); - LOG_DEBUG("%s, penc = %d, pid = %d", __func__, pairing_cb.ble.is_penc_key_rcvd, pairing_cb.ble.is_pid_key_rcvd); + BTC_TRACE_DEBUG("%s, penc = %d, pid = %d", __func__, pairing_cb.ble.is_penc_key_rcvd, pairing_cb.ble.is_pid_key_rcvd); if (pairing_cb.ble.is_penc_key_rcvd) { btc_storage_add_ble_bonding_key(&bd_addr, (char *) &pairing_cb.ble.penc_key, @@ -241,7 +241,7 @@ static void btc_dm_save_ble_bonding_keys(void) static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { /* Save link key, if not temporary */ - LOG_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success); + BTC_TRACE_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success); bt_status_t status = BT_STATUS_FAIL; int addr_type; bt_bdaddr_t bdaddr; @@ -250,10 +250,10 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) if (p_auth_cmpl->success) { status = BT_STATUS_SUCCESS; - LOG_DEBUG ("%s, - p_auth_cmpl->bd_addr: %08x%04x", __func__, + BTC_TRACE_DEBUG ("%s, - p_auth_cmpl->bd_addr: %08x%04x", __func__, (p_auth_cmpl->bd_addr[0] << 24) + (p_auth_cmpl->bd_addr[1] << 16) + (p_auth_cmpl->bd_addr[2] << 8) + p_auth_cmpl->bd_addr[3], (p_auth_cmpl->bd_addr[4] << 8) + p_auth_cmpl->bd_addr[5]); - LOG_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__, + BTC_TRACE_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__, (pairing_cb.bd_addr[0] << 24) + (pairing_cb.bd_addr[1] << 16) + (pairing_cb.bd_addr[2] << 8) + pairing_cb.bd_addr[3], (pairing_cb.bd_addr[4] << 8) + pairing_cb.bd_addr[5]); if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) { @@ -279,7 +279,7 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) } - LOG_DEBUG("%s, authentication status = %x", __func__, status); + BTC_TRACE_DEBUG("%s, authentication status = %x", __func__, status); return; } @@ -290,7 +290,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) /* Save link key, if not temporary */ bt_bdaddr_t bd_addr; bt_status_t status; - LOG_DEBUG("%s: bond state success %d, present %d, type%d\n", __func__, p_auth_cmpl->success, + BTC_TRACE_DEBUG("%s: bond state success %d, present %d, type%d\n", __func__, p_auth_cmpl->success, p_auth_cmpl->key_present, p_auth_cmpl->key_type); bdcpy(bd_addr.address, p_auth_cmpl->bd_addr); @@ -304,14 +304,14 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) #endif if (1) { bt_status_t ret; - LOG_DEBUG("%s: Storing link key. key_type=0x%x", + BTC_TRACE_DEBUG("%s: Storing link key. key_type=0x%x", __FUNCTION__, p_auth_cmpl->key_type); ret = btc_storage_add_bonded_device(&bd_addr, p_auth_cmpl->key, p_auth_cmpl->key_type, 16); BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret); } else { - LOG_DEBUG("%s: Temporary key. Not storing. key_type=0x%x", + BTC_TRACE_DEBUG("%s: Temporary key. Not storing. key_type=0x%x", __FUNCTION__, p_auth_cmpl->key_type); } } @@ -323,7 +323,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) // Map the HCI fail reason to bt status switch (p_auth_cmpl->fail_reason) { case HCI_ERR_PAGE_TIMEOUT: - LOG_WARN("%s() - Pairing timeout; retrying () ...", __FUNCTION__); + BTC_TRACE_WARNING("%s() - Pairing timeout; retrying () ...", __FUNCTION__); return; /* Fall-through */ case HCI_ERR_CONNECTION_TOUT: @@ -349,7 +349,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) case HCI_ERR_INSUFFCIENT_SECURITY: case HCI_ERR_PEER_USER: case HCI_ERR_UNSPECIFIED: - LOG_DEBUG(" %s() Authentication fail reason %d", + BTC_TRACE_DEBUG(" %s() Authentication fail reason %d", __FUNCTION__, p_auth_cmpl->fail_reason); /* if autopair attempts are more than 1, or not attempted */ status = BT_STATUS_AUTH_FAILURE; @@ -381,7 +381,7 @@ void btc_clear_services_mask(void) static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id, BOOLEAN b_enable) { - LOG_DEBUG("%s service_id: %d\n", __FUNCTION__, service_id); + BTC_TRACE_DEBUG("%s service_id: %d\n", __FUNCTION__, service_id); /* Check the service_ID and invoke the profile's BT state changed API */ switch (service_id) { #if BTC_AV_INCLUDED @@ -393,7 +393,7 @@ static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id, break; #endif default: - LOG_ERROR("%s: Unknown service being enabled\n", __FUNCTION__); + BTC_TRACE_ERROR("%s: Unknown service being enabled\n", __FUNCTION__); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; @@ -410,7 +410,7 @@ bt_status_t btc_dm_enable_service(tBTA_SERVICE_ID service_id) btc_enabled_services |= (1 << service_id); - LOG_DEBUG("%s: current services:0x%x", __FUNCTION__, btc_enabled_services); + BTC_TRACE_DEBUG("%s: current services:0x%x", __FUNCTION__, btc_enabled_services); btc_dm_execute_service_request(TRUE, (char *)p_id); @@ -423,7 +423,7 @@ bt_status_t btc_dm_disable_service(tBTA_SERVICE_ID service_id) btc_enabled_services &= (tBTA_SERVICE_MASK)(~(1 << service_id)); - LOG_DEBUG("%s: Current Services:0x%x", __FUNCTION__, btc_enabled_services); + BTC_TRACE_DEBUG("%s: Current Services:0x%x", __FUNCTION__, btc_enabled_services); btc_dm_execute_service_request(FALSE, (char *)p_id); @@ -441,7 +441,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) ble_msg.sig = BTC_SIG_API_CB; ble_msg.pid = BTC_PID_GAP_BLE; // tBTA_SERVICE_MASK service_mask; - LOG_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act); + BTC_TRACE_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act); switch (msg->act) { case BTA_DM_ENABLE_EVT: { @@ -484,7 +484,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) #if (SMP_INCLUDED == TRUE) bt_bdaddr_t bd_addr; rsp_app = true; - LOG_DEBUG("BTA_DM_DEV_UNPAIRED_EVT"); + BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT"); memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR)); btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN); param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL; @@ -512,7 +512,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) case BTA_DM_LINK_UP_EVT: case BTA_DM_LINK_DOWN_EVT: case BTA_DM_HW_ERROR_EVT: - LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); + BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); break; #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE)) case BTA_DM_BLE_AUTH_CMPL_EVT: { @@ -536,7 +536,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) memcpy(param.ble_security.ble_key.bd_addr, p_data->ble_key.bd_addr, BD_ADDR_LEN); switch (p_data->ble_key.key_type) { case BTM_LE_KEY_PENC: { - LOG_DEBUG("Rcv BTA_LE_KEY_PENC"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PENC"); pairing_cb.ble.is_penc_key_rcvd = TRUE; pairing_cb.ble.penc_key = p_data->ble_key.p_key_value->penc_key; memcpy(&pairing_cb.ble.penc_key, &p_data->ble_key.p_key_value->penc_key, @@ -546,7 +546,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } case BTM_LE_KEY_PID: { - LOG_DEBUG("Rcv BTA_LE_KEY_PID"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PID"); pairing_cb.ble.is_pid_key_rcvd = TRUE; memcpy(&pairing_cb.ble.pid_key, &p_data->ble_key.p_key_value->pid_key, sizeof(tBTM_LE_PID_KEYS)); @@ -555,7 +555,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } case BTM_LE_KEY_PCSRK: { - LOG_DEBUG("Rcv BTA_LE_KEY_PCSRK"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PCSRK"); pairing_cb.ble.is_pcsrk_key_rcvd = TRUE; memcpy(&pairing_cb.ble.pcsrk_key, &p_data->ble_key.p_key_value->pcsrk_key, sizeof(tBTM_LE_PCSRK_KEYS)); @@ -564,7 +564,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } case BTM_LE_KEY_LENC: { - LOG_DEBUG("Rcv BTA_LE_KEY_LENC"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LENC"); pairing_cb.ble.is_lenc_key_rcvd = TRUE; memcpy(&pairing_cb.ble.lenc_key, &p_data->ble_key.p_key_value->lenc_key, sizeof(tBTM_LE_LENC_KEYS)); @@ -573,7 +573,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } case BTM_LE_KEY_LCSRK: { - LOG_DEBUG("Rcv BTA_LE_KEY_LCSRK"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LCSRK"); pairing_cb.ble.is_lcsrk_key_rcvd = TRUE; memcpy(&pairing_cb.ble.lcsrk_key, &p_data->ble_key.p_key_value->lcsrk_key, sizeof(tBTM_LE_LCSRK_KEYS)); @@ -582,7 +582,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } case BTM_LE_KEY_LID: { - LOG_DEBUG("Rcv BTA_LE_KEY_LID"); + BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LID"); pairing_cb.ble.is_lidk_key_rcvd = TRUE; break; } @@ -621,7 +621,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) rsp_app = true; ble_msg.act = ESP_GAP_BLE_LOCAL_IR_EVT; memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS)); - LOG_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. "); + BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. "); ble_local_key_cb.is_id_keys_rcvd = TRUE; memcpy(&ble_local_key_cb.id_keys.irk[0], &p_data->ble_id_keys.irk[0], sizeof(BT_OCTET16)); @@ -644,7 +644,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) rsp_app = true; ble_msg.act = ESP_GAP_BLE_LOCAL_ER_EVT; memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS)); - LOG_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. "); + BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. "); ble_local_key_cb.is_er_rcvd = TRUE; memcpy(&ble_local_key_cb.er[0], &p_data->ble_er[0], sizeof(BT_OCTET16)); btc_storage_add_ble_local_key( (char *)&ble_local_key_cb.er[0], @@ -666,10 +666,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) case BTA_DM_SP_RMT_OOB_EVT: case BTA_DM_SP_KEYPRESS_EVT: case BTA_DM_ROLE_CHG_EVT: - LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); + BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); break; default: - LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); + BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); break; } @@ -678,7 +678,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } btc_dm_sec_arg_deep_free(msg); diff --git a/components/bt/bluedroid/btc/core/btc_main.c b/components/bt/bluedroid/btc/core/btc_main.c index b6c9606be6..fb90abb997 100644 --- a/components/bt/bluedroid/btc/core/btc_main.c +++ b/components/bt/bluedroid/btc/core/btc_main.c @@ -89,7 +89,7 @@ static void btc_deinit_bluetooth(void) void btc_main_call_handler(btc_msg_t *msg) { - LOG_DEBUG("%s act %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act); switch (msg->act) { case BTC_MAIN_ACT_INIT: @@ -105,7 +105,7 @@ void btc_main_call_handler(btc_msg_t *msg) btc_disable_bluetooth(); break; default: - LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act); + BTC_TRACE_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act); break; } } diff --git a/components/bt/bluedroid/btc/core/btc_profile_queue.c b/components/bt/bluedroid/btc/core/btc_profile_queue.c index cd495f0e5f..6d01b0d19f 100644 --- a/components/bt/bluedroid/btc/core/btc_profile_queue.c +++ b/components/bt/bluedroid/btc/core/btc_profile_queue.c @@ -49,7 +49,7 @@ static void queue_int_add(connect_node_t *p_param) for (const list_node_t *node = list_begin(connect_queue); node != list_end(connect_queue); node = list_next(node)) { if (((connect_node_t *)list_node(node))->uuid == p_param->uuid) { - LOG_DEBUG("%s dropping duplicate connect request for uuid: %04x", __func__, p_param->uuid); + BTC_TRACE_DEBUG("%s dropping duplicate connect request for uuid: %04x", __func__, p_param->uuid); return; } } diff --git a/components/bt/bluedroid/btc/core/btc_sm.c b/components/bt/bluedroid/btc/core/btc_sm.c index cdf75548f7..6e96ae5940 100644 --- a/components/bt/bluedroid/btc/core/btc_sm.c +++ b/components/bt/bluedroid/btc/core/btc_sm.c @@ -72,7 +72,7 @@ btc_sm_handle_t btc_sm_init(const btc_sm_handler_t *p_handlers, btc_sm_state_t i btc_sm_cb_t *p_cb; if (p_handlers == NULL) { - LOG_ERROR("%s : p_handlers is NULL", __FUNCTION__); + BTC_TRACE_ERROR("%s : p_handlers is NULL", __FUNCTION__); return NULL; } @@ -100,7 +100,7 @@ void btc_sm_shutdown(btc_sm_handle_t handle) btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle; if (p_cb == NULL) { - LOG_ERROR("%s : Invalid handle", __FUNCTION__); + BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__); return; } osi_free(p_cb); @@ -120,7 +120,7 @@ btc_sm_state_t btc_sm_get_state(btc_sm_handle_t handle) btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle; if (p_cb == NULL) { - LOG_ERROR("%s : Invalid handle", __FUNCTION__); + BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__); return 0; } @@ -146,7 +146,7 @@ bt_status_t btc_sm_dispatch(btc_sm_handle_t handle, btc_sm_event_t event, btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle; if (p_cb == NULL) { - LOG_ERROR("%s : Invalid handle", __FUNCTION__); + BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__); return BT_STATUS_FAIL; } @@ -176,7 +176,7 @@ bt_status_t btc_sm_change_state(btc_sm_handle_t handle, btc_sm_state_t state) btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle; if (p_cb == NULL) { - LOG_ERROR("%s : Invalid handle", __FUNCTION__); + BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__); return BT_STATUS_FAIL; } diff --git a/components/bt/bluedroid/btc/core/btc_storage.c b/components/bt/bluedroid/btc/core/btc_storage.c index 5114a6befd..654a1bf288 100644 --- a/components/bt/bluedroid/btc/core/btc_storage.c +++ b/components/bt/bluedroid/btc/core/btc_storage.c @@ -42,7 +42,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, bdstr_t bdstr; bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); - LOG_DEBUG("add to storage: Remote device:%s\n", bdstr); + BTC_TRACE_DEBUG("add to storage: Remote device:%s\n", bdstr); btc_config_lock(); int ret = btc_config_set_int(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR, (int)key_type); @@ -52,7 +52,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, btc_config_flush(); btc_config_unlock(); - LOG_DEBUG("Storage add rslt %d\n", ret); + BTC_TRACE_DEBUG("Storage add rslt %d\n", ret); return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; } @@ -77,7 +77,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add) continue; } - LOG_DEBUG("Remote device:%s\n", name); + BTC_TRACE_DEBUG("Remote device:%s\n", name); LINK_KEY link_key; size_t size = sizeof(link_key); if (btc_config_get_bin(name, BTC_STORAGE_LINK_KEY_STR, link_key, &size)) { @@ -100,11 +100,11 @@ static bt_status_t btc_in_fetch_bonded_devices(int add) } bt_linkkey_file_found = TRUE; } else { - LOG_ERROR("bounded device:%s, LinkKeyType or PinLength is invalid\n", name); + BTC_TRACE_ERROR("bounded device:%s, LinkKeyType or PinLength is invalid\n", name); } } if (!bt_linkkey_file_found) { - LOG_DEBUG("Remote device:%s, no link key\n", name); + BTC_TRACE_DEBUG("Remote device:%s, no link key\n", name); } } btc_config_unlock(); @@ -129,7 +129,7 @@ bt_status_t btc_storage_load_bonded_devices(void) { bt_status_t status; status = btc_in_fetch_bonded_devices(1); - LOG_DEBUG("Storage load rslt %d\n", status); + BTC_TRACE_DEBUG("Storage load rslt %d\n", status); return status; } @@ -148,7 +148,7 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr) bdstr_t bdstr; bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); int ret = 1; - LOG_DEBUG("Add to storage: Remote device:%s\n", bdstr); + BTC_TRACE_DEBUG("Add to storage: Remote device:%s\n", bdstr); btc_config_lock(); if (btc_config_exist(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR)) { diff --git a/components/bt/bluedroid/btc/core/btc_task.c b/components/bt/bluedroid/btc/core/btc_task.c index d98e6b4c33..1d14d7ecf0 100644 --- a/components/bt/bluedroid/btc/core/btc_task.c +++ b/components/bt/bluedroid/btc/core/btc_task.c @@ -95,7 +95,7 @@ static void btc_task(void *arg) for (;;) { if (pdTRUE == xQueueReceive(xBtcQueue, &msg, (portTickType)portMAX_DELAY)) { - LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg.sig, msg.pid, msg.act, msg.arg); + BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg.sig, msg.pid, msg.act, msg.arg); switch (msg.sig) { case BTC_SIG_API_CALL: profile_tab[msg.pid].btc_call(&msg); @@ -120,7 +120,7 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout) } if (xQueueSend(xBtcQueue, msg, timeout) != pdTRUE) { - LOG_ERROR("Btc Post failed\n"); + BTC_TRACE_ERROR("Btc Post failed\n"); return BT_STATUS_BUSY; } @@ -135,7 +135,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg return BT_STATUS_PARM_INVALID; } - LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg); + BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg); memcpy(&lmsg, msg, sizeof(btc_msg_t)); if (arg) { diff --git a/components/bt/bluedroid/btc/profile/esp/ble_button/button_pro.c b/components/bt/bluedroid/btc/profile/esp/ble_button/button_pro.c index 506356b33c..d7233ae564 100644 --- a/components/bt/bluedroid/btc/profile/esp/ble_button/button_pro.c +++ b/components/bt/bluedroid/btc/profile/esp/ble_button/button_pro.c @@ -63,19 +63,19 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) uint8_t net_event = 0xff; uint8_t len = 0; uint8_t *p_rec_data = NULL; - //LOG_ERROR("p_data->status = %x\n",p_data->status); + //BTC_TRACE_ERROR("p_data->status = %x\n",p_data->status); //if(p_data->status != BTA_GATT_OK){ - // LOG_ERROR("button profile register failed\n"); + // BTC_TRACE_ERROR("button profile register failed\n"); // return; //} - LOG_ERROR("button profile cb event = %x\n", event); + BTC_TRACE_ERROR("button profile cb event = %x\n", event); switch (event) { case ESP_GATTS_REG_EVT: - LOG_ERROR("p_data->reg_oper.status = %x\n", p_data->reg_oper.status); - LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16); + BTC_TRACE_ERROR("p_data->reg_oper.status = %x\n", p_data->reg_oper.status); + BTC_TRACE_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16); if (p_data->reg_oper.status != BTA_GATT_OK) { - LOG_ERROR("button profile register failed\n"); + BTC_TRACE_ERROR("button profile register failed\n"); } button_cb_env.gatt_if = p_data->reg_oper.server_if; button_cb_env.enabled = true; @@ -96,11 +96,11 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) case ESP_GATTS_WRITE_EVT: esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.status, NULL); - LOG_ERROR("Received button data:"); + BTC_TRACE_ERROR("Received button data:"); for (int i = 0; i < p_data->req_data.p_data->write_req.len; i++) { - LOG_ERROR("%x", p_data->req_data.p_data->write_req.value[i]); + BTC_TRACE_ERROR("%x", p_data->req_data.p_data->write_req.value[i]); } - LOG_ERROR("\n"); + BTC_TRACE_ERROR("\n"); if (p_data->req_data.p_data->write_req.handle == button_cb_env.button_inst.but_wirt_hdl) { p_rec_data = &p_data->req_data.p_data->write_req.value[0]; @@ -154,12 +154,12 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id; } ///Start advertising - LOG_ERROR("\n*******Start sent the ADV.*************\n"); + BTC_TRACE_ERROR("\n*******Start sent the ADV.*************\n"); //esp_ble_start_advertising (&adv_params); //BTA_GATTS_Listen(button_cb_env.gatt_if, true, NULL); break; case ESP_GATTS_CONNECT_EVT: - LOG_ERROR("############BUTTON CONNCET EVT################\n"); + BTC_TRACE_ERROR("############BUTTON CONNCET EVT################\n"); //esp_ble_stop_advertising(); //set the connection flag to true button_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda); @@ -205,7 +205,7 @@ void Button_CreateService(void) button_cb_env.inst_id = inst; //if(!button_cb_env.enabled) //{ - // LOG_ERROR("button service added error."); + // BTC_TRACE_ERROR("button service added error."); //} esp_ble_gatts_create_srvc(server_if, &uuid, inst, num_handle, true); @@ -228,7 +228,7 @@ but_clcb_t *button_env_clcb_alloc (uint16_t conn_id, BD_ADDR remote_bda) if (!p_clcb->in_use) { p_clcb->in_use = TRUE; p_clcb->conn_id = conn_id; - LOG_ERROR("p_clcb->conn_id = %x\n", conn_id); + BTC_TRACE_ERROR("p_clcb->conn_id = %x\n", conn_id); p_clcb->connected = TRUE; memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN); } @@ -295,9 +295,9 @@ esp_gatt_status_t button_init (but_prf_cb_t call_back) { tBT_UUID app_uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; - LOG_ERROR("\n=============================button_init==============================================\n"); + BTC_TRACE_ERROR("\n=============================button_init==============================================\n"); if (button_cb_env.enabled) { - LOG_ERROR("button svc already initaliezd\n"); + BTC_TRACE_ERROR("button svc already initaliezd\n"); return ESP_GATT_ERROR; } else { memset(&button_cb_env, 0, sizeof(button_env_cb_t)); @@ -331,7 +331,7 @@ void button_msg_notify(uint16_t len, uint8_t *button_msg) //notify rsp==false; indicate rsp==true. BOOLEAN rsp = false; if (!conn_status && button_cb_env.clcb.congest) { - LOG_ERROR("the conneciton for button profile has been loss\n"); + BTC_TRACE_ERROR("the conneciton for button profile has been loss\n"); return; } diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c index de58b0201e..3bfa6afbc8 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.c @@ -79,7 +79,7 @@ static inline void btc_blufi_cb_to_app(esp_blufi_cb_event_t event, esp_blufi_cb_ static void blufi_create_service(void) { if (!blufi_env.enabled) { - LOG_ERROR("blufi service added error."); + BTC_TRACE_ERROR("blufi service added error."); return; } @@ -91,14 +91,14 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) { tBTA_GATTS_RSP rsp; - LOG_DEBUG("blufi profile cb event = %x\n", event); + BLUFI_TRACE_DEBUG("blufi profile cb event = %x\n", event); switch (event) { case BTA_GATTS_REG_EVT: - LOG_DEBUG("REG: status %d, app_uuid %04x, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.uuid.uu.uuid16, p_data->reg_oper.server_if); + BLUFI_TRACE_DEBUG("REG: status %d, app_uuid %04x, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.uuid.uu.uuid16, p_data->reg_oper.server_if); if (p_data->reg_oper.status != BTA_GATT_OK) { - LOG_ERROR("BLUFI profile register failed\n"); + BLUFI_TRACE_ERROR("BLUFI profile register failed\n"); return; } @@ -107,7 +107,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) //create the blufi service to the service data base. if (p_data->reg_oper.uuid.uu.uuid16 == BLUFI_APP_UUID) { - LOG_DEBUG("%s %d\n", __func__, __LINE__); + BLUFI_TRACE_DEBUG("%s %d\n", __func__, __LINE__); blufi_create_service(); } break; @@ -115,10 +115,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) esp_blufi_cb_param_t param; btc_msg_t msg; - LOG_DEBUG("DEREG: status %d, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.server_if); + BLUFI_TRACE_DEBUG("DEREG: status %d, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.server_if); if (p_data->reg_oper.status != BTA_GATT_OK) { - LOG_ERROR("BLUFI profile unregister failed\n"); + BLUFI_TRACE_ERROR("BLUFI profile unregister failed\n"); return; } @@ -148,7 +148,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) if (blufi_env.prepare_buf == NULL) { blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE); if (blufi_env.prepare_buf == NULL) { - LOG_ERROR("Blufi prep no mem\n"); + BLUFI_TRACE_ERROR("Blufi prep no mem\n"); status = GATT_NO_RESOURCES; } } else { @@ -165,7 +165,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) rsp.attr_value.offset = p_data->req_data.p_data->write_req.offset; memcpy(rsp.attr_value.value, p_data->req_data.p_data->write_req.value, p_data->req_data.p_data->write_req.len); - LOG_DEBUG("prep write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset); + BLUFI_TRACE_DEBUG("prep write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset); BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id, status, &rsp); @@ -177,7 +177,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) return; } else { - LOG_DEBUG("norm write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset); + BLUFI_TRACE_DEBUG("norm write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset); BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.status, NULL); } @@ -189,7 +189,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) break; } case BTA_GATTS_EXEC_WRITE_EVT: - LOG_DEBUG("exec write exec %d\n", p_data->req_data.p_data->exec_write); + BLUFI_TRACE_DEBUG("exec write exec %d\n", p_data->req_data.p_data->exec_write); BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id, GATT_SUCCESS, NULL); @@ -205,11 +205,11 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) break; case BTA_GATTS_MTU_EVT: - LOG_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu); + BLUFI_TRACE_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu); blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE; break; case BTA_GATTS_CONF_EVT: - LOG_DEBUG("CONIRM EVT\n"); + BLUFI_TRACE_DEBUG("CONIRM EVT\n"); if (p_data && p_data->req_data.value){ osi_free(p_data->req_data.value); } @@ -268,7 +268,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) esp_blufi_cb_param_t param; //set the connection flag to true - LOG_INFO("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", + BLUFI_TRACE_API("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if, p_data->conn.reason, p_data->conn.conn_id); @@ -291,7 +291,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) blufi_env.is_connected = false; //set the connection flag to true - LOG_INFO("\ndevice is disconnected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", + BLUFI_TRACE_API("\ndevice is disconnected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if, p_data->conn.reason, p_data->conn.conn_id); @@ -324,7 +324,7 @@ static tGATT_STATUS btc_blufi_profile_init(void) esp_blufi_callbacks_t *store_p = blufi_env.cbs; if (blufi_env.enabled) { - LOG_ERROR("BLUFI already initialized"); + BLUFI_TRACE_ERROR("BLUFI already initialized"); return GATT_ERROR; } @@ -341,7 +341,7 @@ static tGATT_STATUS btc_blufi_profile_init(void) static tGATT_STATUS btc_blufi_profile_deinit(void) { if (!blufi_env.enabled) { - LOG_ERROR("BLUFI already de-initialized"); + BTC_TRACE_ERROR("BLUFI already de-initialized"); return GATT_ERROR; } @@ -381,7 +381,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len) int ret; if (hdr->seq != blufi_env.recv_seq) { - LOG_ERROR("%s seq %d is not expect %d\n", __func__, hdr->seq, blufi_env.recv_seq + 1); + BTC_TRACE_ERROR("%s seq %d is not expect %d\n", __func__, hdr->seq, blufi_env.recv_seq + 1); btc_blufi_report_error(ESP_BLUFI_SEQUENCE_ERROR); return; } @@ -393,7 +393,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len) && (blufi_env.cbs && blufi_env.cbs->decrypt_func)) { ret = blufi_env.cbs->decrypt_func(hdr->seq, hdr->data, hdr->data_len); if (ret != hdr->data_len) { /* enc must be success and enc len must equal to plain len */ - LOG_ERROR("%s decrypt error %d\n", __func__, ret); + BTC_TRACE_ERROR("%s decrypt error %d\n", __func__, ret); btc_blufi_report_error(ESP_BLUFI_DECRYPT_ERROR); return; } @@ -405,7 +405,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len) checksum = blufi_env.cbs->checksum_func(hdr->seq, &hdr->seq, hdr->data_len + 2); checksum_pkt = hdr->data[hdr->data_len] | (((uint16_t) hdr->data[hdr->data_len + 1]) << 8); if (checksum != checksum_pkt) { - LOG_ERROR("%s checksum error %04x, pkt %04x\n", __func__, checksum, checksum_pkt); + BTC_TRACE_ERROR("%s checksum error %04x, pkt %04x\n", __func__, checksum, checksum_pkt); btc_blufi_report_error(ESP_BLUFI_CHECKSUM_ERROR); return; } @@ -420,7 +420,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len) blufi_env.total_len = hdr->data[0] | (((uint16_t) hdr->data[1]) << 8); blufi_env.aggr_buf = osi_malloc(blufi_env.total_len); if (blufi_env.aggr_buf == NULL) { - LOG_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len); + BTC_TRACE_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len); return; } } @@ -451,7 +451,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len) if (remain_len > blufi_env.frag_size) { hdr = osi_malloc(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2); if (hdr == NULL) { - LOG_ERROR("%s no mem\n", __func__); + BTC_TRACE_ERROR("%s no mem\n", __func__); return; } hdr->fc = 0x0; @@ -463,7 +463,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len) } else { hdr = osi_malloc(sizeof(struct blufi_hdr) + remain_len + 2); if (hdr == NULL) { - LOG_ERROR("%s no mem\n", __func__); + BTC_TRACE_ERROR("%s no mem\n", __func__); return; } hdr->fc = 0x0; @@ -496,7 +496,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len) if (ret == hdr->data_len) { /* enc must be success and enc len must equal to plain len */ hdr->fc |= BLUFI_FC_ENC; } else { - LOG_ERROR("%s encrypt error %d\n", __func__, ret); + BTC_TRACE_ERROR("%s encrypt error %d\n", __func__, ret); btc_blufi_report_error(ESP_BLUFI_ENCRYPT_ERROR); osi_free(hdr); return; @@ -586,7 +586,7 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u } } if (p - data > data_len) { - LOG_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len); + BTC_TRACE_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len); } btc_blufi_send_encap(type, data, data_len); @@ -603,7 +603,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list) uint malloc_size = (1 + 1 + sizeof(list->ssid)) * apCount; p = data = osi_malloc(malloc_size); if (data == NULL) { - LOG_ERROR("malloc error\n"); + BTC_TRACE_ERROR("malloc error\n"); return; } type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST); @@ -613,7 +613,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list) data_len = (p - data); //current_len + ssid + rssi + total_len_value if((data_len + len + 1 + 1) > malloc_size) { - LOG_ERROR("%s len error", __func__); + BTC_TRACE_ERROR("%s len error", __func__); osi_free(data); return; } @@ -653,7 +653,7 @@ static void btc_blufi_send_error_info(uint8_t state) type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_ERROR_INFO); *p++ = state; if (p - data > data_len) { - LOG_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len); + BTC_TRACE_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len); } btc_blufi_send_encap(type, data, data_len); @@ -663,12 +663,12 @@ static void btc_blufi_send_error_info(uint8_t state) static void btc_blufi_send_custom_data(uint8_t *value, uint32_t value_len) { if(value == NULL || value_len == 0) { - LOG_ERROR("%s value or value len error", __func__); + BTC_TRACE_ERROR("%s value or value len error", __func__); return; } uint8_t *data = osi_malloc(value_len); if (data == NULL) { - LOG_ERROR("%s mem malloc error", __func__); + BTC_TRACE_ERROR("%s mem malloc error", __func__); return; } uint8_t type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_CUSTOM_DATA); @@ -686,77 +686,77 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) case ESP_BLUFI_EVENT_RECV_STA_SSID: dst->sta_ssid.ssid = osi_malloc(src->sta_ssid.ssid_len); if (dst->sta_ssid.ssid == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->sta_ssid.ssid, src->sta_ssid.ssid, src->sta_ssid.ssid_len); break; case ESP_BLUFI_EVENT_RECV_STA_PASSWD: dst->sta_passwd.passwd = osi_malloc(src->sta_passwd.passwd_len); if (dst->sta_passwd.passwd == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->sta_passwd.passwd, src->sta_passwd.passwd, src->sta_passwd.passwd_len); break; case ESP_BLUFI_EVENT_RECV_SOFTAP_SSID: dst->softap_ssid.ssid = osi_malloc(src->softap_ssid.ssid_len); if (dst->softap_ssid.ssid == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->softap_ssid.ssid, src->softap_ssid.ssid, src->softap_ssid.ssid_len); break; case ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD: dst->softap_passwd.passwd = osi_malloc(src->softap_passwd.passwd_len); if (dst->softap_passwd.passwd == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->softap_passwd.passwd, src->softap_passwd.passwd, src->softap_passwd.passwd_len); break; case ESP_BLUFI_EVENT_RECV_USERNAME: dst->username.name = osi_malloc(src->username.name_len); if (dst->username.name == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->username.name, src->username.name, src->username.name_len); break; case ESP_BLUFI_EVENT_RECV_CA_CERT: dst->ca.cert = osi_malloc(src->ca.cert_len); if (dst->ca.cert == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->ca.cert, src->ca.cert, src->ca.cert_len); break; case ESP_BLUFI_EVENT_RECV_CLIENT_CERT: dst->client_cert.cert = osi_malloc(src->client_cert.cert_len); if (dst->client_cert.cert == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->client_cert.cert, src->client_cert.cert, src->client_cert.cert_len); break; case ESP_BLUFI_EVENT_RECV_SERVER_CERT: dst->server_cert.cert = osi_malloc(src->server_cert.cert_len); if (dst->server_cert.cert == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->server_cert.cert, src->server_cert.cert, src->server_cert.cert_len); break; case ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY: dst->client_pkey.pkey = osi_malloc(src->client_pkey.pkey_len); if (dst->client_pkey.pkey == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->client_pkey.pkey, src->client_pkey.pkey, src->client_pkey.pkey_len); break; case ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY: dst->server_pkey.pkey = osi_malloc(src->server_pkey.pkey_len); if (dst->server_pkey.pkey == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } memcpy(dst->server_pkey.pkey, src->server_pkey.pkey, src->server_pkey.pkey_len); break; case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA: dst->custom_data.data = osi_malloc(src->custom_data.data_len); if (dst->custom_data.data == NULL) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); break; } memcpy(dst->custom_data.data, src->custom_data.data, src->custom_data.data_len); @@ -898,7 +898,7 @@ void btc_blufi_cb_handler(btc_msg_t *msg) btc_blufi_cb_to_app(ESP_BLUFI_EVENT_RECV_CUSTOM_DATA, param); break; default: - LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act); + BTC_TRACE_ERROR("%s UNKNOWN %d\n", __func__, msg->act); break; } @@ -995,12 +995,12 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) case BTC_BLUFI_ACT_SEND_CUSTOM_DATA:{ uint8_t *data = src->custom_data.data; if(data == NULL) { - LOG_ERROR("custom data is NULL\n"); + BTC_TRACE_ERROR("custom data is NULL\n"); break; } dst->custom_data.data = osi_malloc(src->custom_data.data_len); if(dst->custom_data.data == NULL) { - LOG_ERROR("custom data malloc error\n"); + BTC_TRACE_ERROR("custom data malloc error\n"); break; } memcpy(dst->custom_data.data, src->custom_data.data, src->custom_data.data_len); @@ -1085,7 +1085,7 @@ void btc_blufi_call_handler(btc_msg_t *msg) btc_blufi_send_custom_data(arg->custom_data.data, arg->custom_data.data_len); break; default: - LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act); + BTC_TRACE_ERROR("%s UNKNOWN %d\n", __func__, msg->act); break; } btc_blufi_call_deep_free(msg); diff --git a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c index 19ab994ba6..b962d10051 100644 --- a/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c +++ b/components/bt/bluedroid/btc/profile/esp/blufi/blufi_protocol.c @@ -113,7 +113,7 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len) btc_transfer_context(&msg, NULL, 0, NULL); break; default: - LOG_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type); + BTC_TRACE_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type); break; } break; @@ -260,7 +260,7 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len) btc_transfer_context(&msg, ¶m, sizeof(esp_blufi_cb_param_t), btc_blufi_cb_deep_copy); break; default: - LOG_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type); + BTC_TRACE_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type); break; } break; diff --git a/components/bt/bluedroid/btc/profile/esp/wechat_AirSync/wx_airsync_prf.c b/components/bt/bluedroid/btc/profile/esp/wechat_AirSync/wx_airsync_prf.c index 2620b60d82..b4b349ead3 100644 --- a/components/bt/bluedroid/btc/profile/esp/wechat_AirSync/wx_airsync_prf.c +++ b/components/bt/bluedroid/btc/profile/esp/wechat_AirSync/wx_airsync_prf.c @@ -57,12 +57,12 @@ static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst; - LOG_ERROR("airsync profile cb event = %x\n", event); + BTC_TRACE_ERROR("airsync profile cb event = %x\n", event); switch (event) { case ESP_GATTS_REG_EVT: if (p_data->reg_oper.status != BTA_GATT_OK) { - LOG_ERROR("button profile register failed\n"); + BTC_TRACE_ERROR("button profile register failed\n"); } airsync_cb_env.gatt_if = p_data->reg_oper.server_if; airsync_cb_env.enabled = true; @@ -203,7 +203,7 @@ tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda) if (!p_clcb->in_use) { p_clcb->in_use = TRUE; p_clcb->conn_id = conn_id; - LOG_ERROR("p_clcb->conn_id = %x\n", conn_id); + BTC_TRACE_ERROR("p_clcb->conn_id = %x\n", conn_id); p_clcb->connected = TRUE; memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN); } @@ -248,7 +248,7 @@ tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back) if (airsync_cb_env.enabled) { - LOG_ERROR("airsync svc already initaliezd\n"); + BTC_TRACE_ERROR("airsync svc already initaliezd\n"); return ESP_GATT_ERROR; } else { memset(&airsync_cb_env, 0, sizeof(tAIRSYNC_CB_ENV)); diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c index 827542dc18..da5ff32b96 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c @@ -1136,7 +1136,7 @@ static UINT8 btc_get_num_aa_frame(void) } btc_aa_src_cb.media_feeding_state.pcm.counter -= result * pcm_bytes_per_frame; - LOG_VERBOSE("WRITE %d FRAMES", result); + BTC_TRACE_VERBOSE("WRITE %d FRAMES", result); } break; @@ -1461,7 +1461,7 @@ static void btc_a2dp_source_send_aa_frame(void) } /* send it */ - LOG_VERBOSE("%s: send %d frames", __FUNCTION__, nb_frame_2_send); + BTC_TRACE_VERBOSE("%s: send %d frames", __FUNCTION__, nb_frame_2_send); bta_av_ci_src_data_ready(BTA_AV_CHNL_AUDIO); } @@ -1540,7 +1540,7 @@ static void btc_a2dp_source_aa_start_tx(void) btc_aa_src_cb.media_alarm = osi_alarm_new("aaTx", btc_a2dp_source_alarm_cb, NULL, BTC_MEDIA_TIME_TICK_MS); if (!btc_aa_src_cb.media_alarm) { - LOG_ERROR("%s unable to allocate media alarm.", __func__); + BTC_TRACE_ERROR("%s unable to allocate media alarm.", __func__); return; } diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c index 3256293755..0541111886 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_av.c @@ -227,13 +227,13 @@ static void btc_initiate_av_open_tmr_hdlr(void *arg) btc_av_connect_req_t connect_req; /* is there at least one RC connection - There should be */ if (btc_rc_get_connected_peer(peer_addr)) { - LOG_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__); + BTC_TRACE_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__); /* In case of AVRCP connection request, we will initiate SRC connection */ memcpy(connect_req.target_bda.address, peer_addr, sizeof(bt_bdaddr_t)); connect_req.uuid = UUID_SERVCLASS_AUDIO_SOURCE; btc_dispatch_sm_event(BTC_AV_CONNECT_REQ_EVT, &connect_req, sizeof(btc_av_connect_req_t)); } else { - LOG_ERROR("%s No connected RC peers", __FUNCTION__); + BTC_TRACE_ERROR("%s No connected RC peers", __FUNCTION__); } } #endif /* BTC_AV_SRC_INCLUDED */ @@ -283,7 +283,7 @@ static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data) { - LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__, + BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__, dump_av_sm_event_name(event), btc_av_cb.flags); switch (event) { @@ -332,7 +332,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data) */ #if BTC_AV_SRC_INCLUDED - LOG_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV"); + BTC_TRACE_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV"); tle_av_open_on_rc = osi_alarm_new("AVconn", btc_initiate_av_open_tmr_hdlr, NULL, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000); osi_alarm_set(tle_av_open_on_rc, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000); #endif /* BTC_AV_SRC_INCLUDED */ @@ -358,7 +358,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data) break; default: - LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__, + BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event)); return FALSE; @@ -379,7 +379,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data) static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) { - LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__, + BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__, dump_av_sm_event_name(event), btc_av_cb.flags); switch (event) { @@ -392,7 +392,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) break; case BTA_AV_REJECT_EVT: - LOG_DEBUG(" Received BTA_AV_REJECT_EVT \n"); + BTC_TRACE_DEBUG(" Received BTA_AV_REJECT_EVT \n"); btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), 0); btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE); break; @@ -401,7 +401,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) tBTA_AV *p_bta_data = (tBTA_AV *)p_data; esp_a2d_connection_state_t state; btc_sm_state_t av_state; - LOG_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status, + BTC_TRACE_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status, p_bta_data->open.edr); if (p_bta_data->open.status == BTA_AV_SUCCESS) { @@ -411,7 +411,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) btc_av_cb.peer_sep = p_bta_data->open.sep; } else { - LOG_WARN("BTA_AV_OPEN_EVT::FAILED status: %d\n", + BTC_TRACE_WARNING("BTA_AV_OPEN_EVT::FAILED status: %d\n", p_bta_data->open.status ); state = ESP_A2D_CONNECTION_STATE_DISCONNECTED; av_state = BTC_AV_STATE_IDLE; @@ -447,11 +447,11 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) // Check for device, if same device which moved to opening then ignore callback if (memcmp ((bt_bdaddr_t *)p_data, &(btc_av_cb.peer_bda), sizeof(btc_av_cb.peer_bda)) == 0) { - LOG_DEBUG("%s: Same device moved to Opening state,ignore Connect Req\n", __func__); + BTC_TRACE_DEBUG("%s: Same device moved to Opening state,ignore Connect Req\n", __func__); btc_queue_advance(); break; } else { - LOG_DEBUG("%s: Moved from idle by Incoming Connection request\n", __func__); + BTC_TRACE_DEBUG("%s: Moved from idle by Incoming Connection request\n", __func__); btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, (bt_bdaddr_t *)p_data, 0); btc_queue_advance(); break; @@ -461,10 +461,10 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) // Check for device, if same device which moved to opening then ignore callback if (memcmp (((tBTA_AV *)p_data)->pend.bd_addr, &(btc_av_cb.peer_bda), sizeof(btc_av_cb.peer_bda)) == 0) { - LOG_DEBUG("%s: Same device moved to Opening state,ignore Pending Req\n", __func__); + BTC_TRACE_DEBUG("%s: Same device moved to Opening state,ignore Pending Req\n", __func__); break; } else { - LOG_DEBUG("%s: Moved from idle by outgoing Connection request\n", __func__); + BTC_TRACE_DEBUG("%s: Moved from idle by outgoing Connection request\n", __func__); BTA_AvDisconnect(((tBTA_AV *)p_data)->pend.bd_addr); break; } @@ -472,7 +472,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) CHECK_RC_EVENT(event, p_data); default: - LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__, + BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event)); return FALSE; @@ -494,7 +494,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data) { - LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__, + BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__, dump_av_sm_event_name(event), btc_av_cb.flags); switch (event) { @@ -548,7 +548,7 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data) break; default: - LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__, + BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event)); return FALSE; } @@ -570,12 +570,12 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) { tBTA_AV *p_av = (tBTA_AV *)p_data; - LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__, + BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__, dump_av_sm_event_name(event), btc_av_cb.flags); if ( (event == BTA_AV_REMOTE_CMD_EVT) && (btc_av_cb.flags & BTC_AV_FLAG_REMOTE_SUSPEND) && (p_av->remote_cmd.rc_id == BTA_AV_RC_PLAY) ) { - LOG_INFO("%s: Resetting remote suspend flag on RC PLAY\n", __FUNCTION__); + BTC_TRACE_DEBUG("%s: Resetting remote suspend flag on RC PLAY\n", __FUNCTION__); btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND; } @@ -600,7 +600,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) break; case BTA_AV_START_EVT: { - LOG_INFO("BTA_AV_START_EVT status %d, suspending %d, init %d\n", + BTC_TRACE_DEBUG("BTA_AV_START_EVT status %d, suspending %d, init %d\n", p_av->start.status, p_av->start.suspending, p_av->start.initiator); if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE)) { @@ -613,7 +613,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) */ if (!(btc_av_cb.flags & BTC_AV_FLAG_PENDING_START)) { if (btc_av_cb.peer_sep == AVDT_TSEP_SNK) { - LOG_INFO("%s: trigger suspend as remote initiated!!", __FUNCTION__); + BTC_TRACE_DEBUG("%s: trigger suspend as remote initiated!!", __FUNCTION__); btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0); } } @@ -679,7 +679,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) case BTA_AV_RECONFIG_EVT: if ((btc_av_cb.flags & BTC_AV_FLAG_PENDING_START) && (p_av->reconfig.status == BTA_AV_SUCCESS)) { - LOG_WARN("reconfig done BTA_AVstart()\n"); + BTC_TRACE_WARNING("reconfig done BTA_AVstart()\n"); BTA_AvStart(); } else if (btc_av_cb.flags & BTC_AV_FLAG_PENDING_START) { btc_av_cb.flags &= ~BTC_AV_FLAG_PENDING_START; @@ -690,9 +690,9 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) case BTC_AV_CONNECT_REQ_EVT: if (memcmp (&((btc_av_connect_req_t *)p_data)->target_bda, &(btc_av_cb.peer_bda), sizeof(btc_av_cb.peer_bda)) == 0) { - LOG_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__); + BTC_TRACE_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__); } else { - LOG_DEBUG("%s: Moved to opened by Other Incoming Conn req\n", __func__); + BTC_TRACE_DEBUG("%s: Moved to opened by Other Incoming Conn req\n", __func__); btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, (bt_bdaddr_t *)p_data, ESP_A2D_DISC_RSN_NORMAL); } @@ -702,7 +702,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) CHECK_RC_EVENT(event, p_data); default: - LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__, + BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event)); return FALSE; @@ -724,7 +724,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data) { tBTA_AV *p_av = (tBTA_AV *)p_data; - LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__, + BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__, dump_av_sm_event_name(event), btc_av_cb.flags); switch (event) { @@ -799,7 +799,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data) case BTA_AV_SUSPEND_EVT: - LOG_INFO("BTA_AV_SUSPEND_EVT status %d, init %d\n", + BTC_TRACE_DEBUG("BTA_AV_SUSPEND_EVT status %d, init %d\n", p_av->suspend.status, p_av->suspend.initiator); /* a2dp suspended, stop media task until resumed */ @@ -871,7 +871,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data) CHECK_RC_EVENT(event, p_data); default: - LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__, + BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event)); return FALSE; @@ -1005,7 +1005,7 @@ static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid) btc_av_connect_req_t connect_req; memcpy(&connect_req.target_bda, bd_addr, sizeof(bt_bdaddr_t)); connect_req.uuid = uuid; - LOG_DEBUG("%s\n", __FUNCTION__); + BTC_TRACE_DEBUG("%s\n", __FUNCTION__); btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_CONNECT_REQ_EVT, (char *)&connect_req); @@ -1023,7 +1023,7 @@ static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid) *******************************************************************************/ static void clean_up(int service_id) { - LOG_DEBUG("%s\n", __FUNCTION__); + BTC_TRACE_DEBUG("%s\n", __FUNCTION__); if (service_id == BTA_A2DP_SOURCE_SERVICE_ID) { #if BTC_AV_SRC_INCLUDED @@ -1081,7 +1081,7 @@ BOOLEAN btc_av_stream_ready(void) { btc_sm_state_t state = btc_sm_get_state(btc_av_cb.sm_handle); - LOG_DEBUG("btc_av_stream_ready : sm hdl %d, state %d, flags %x\n", + BTC_TRACE_DEBUG("btc_av_stream_ready : sm hdl %d, state %d, flags %x\n", (int)btc_av_cb.sm_handle, state, btc_av_cb.flags); /* check if we are remotely suspended or stop is pending */ @@ -1106,7 +1106,7 @@ BOOLEAN btc_av_stream_started_ready(void) { btc_sm_state_t state = btc_sm_get_state(btc_av_cb.sm_handle); - LOG_DEBUG("btc_av_stream_started : sm hdl %d, state %d, flags %x\n", + BTC_TRACE_DEBUG("btc_av_stream_started : sm hdl %d, state %d, flags %x\n", (int)btc_av_cb.sm_handle, state, btc_av_cb.flags); /* disallow media task to start if we have pending actions */ @@ -1149,7 +1149,7 @@ static void bte_av_callback(tBTA_AV_EVT event, tBTA_AV *p_data) stat = btc_transfer_context(&msg, p_data, sizeof(tBTA_AV), btc_av_event_deep_copy); if (stat) { - LOG_ERROR("%s transfer failed\n", __func__); + BTC_TRACE_ERROR("%s transfer failed\n", __func__); } } @@ -1166,7 +1166,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data) if ( (state == BTC_AV_STATE_STARTED) || /* send SBC packets only in Started State */ (state == BTC_AV_STATE_OPENED) ) { que_len = btc_a2dp_sink_enque_buf((BT_HDR *)p_data); - LOG_DEBUG(" Packets in Que %d\n", que_len); + BTC_TRACE_DEBUG(" Packets in Que %d\n", que_len); } else { return; } @@ -1191,14 +1191,14 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data) memcpy(arg.mcc.cie.sbc, (uint8_t *)p_data + 3, ESP_A2D_CIE_LEN_SBC); btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL); } else { - LOG_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status); + BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status); } } } #else static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data) { - LOG_WARN("%s : event %u\n", __func__, event); + BTC_TRACE_WARNING("%s : event %u\n", __func__, event); } #endif @@ -1313,7 +1313,7 @@ BOOLEAN btc_av_is_peer_edr(void) ******************************************************************************/ void btc_av_clear_remote_suspend_flag(void) { - LOG_DEBUG("%s: flag :%x\n", __func__, btc_av_cb.flags); + BTC_TRACE_DEBUG("%s: flag :%x\n", __func__, btc_av_cb.flags); btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND; } @@ -1393,7 +1393,7 @@ void btc_a2dp_call_handler(btc_msg_t *msg) break; } default: - LOG_WARN("%s : unhandled event: %d\n", __FUNCTION__, msg->act); + BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act); } } @@ -1416,14 +1416,14 @@ void btc_a2dp_cb_handler(btc_msg_t *msg) *******************************************************************************/ static bt_status_t btc_a2d_sink_init(void) { - LOG_DEBUG("%s()\n", __func__); + BTC_TRACE_DEBUG("%s()\n", __func__); return btc_av_init(BTA_A2DP_SINK_SERVICE_ID); } static bt_status_t btc_a2d_sink_connect(bt_bdaddr_t *remote_bda) { - LOG_DEBUG("%s\n", __FUNCTION__); + BTC_TRACE_DEBUG("%s\n", __FUNCTION__); CHECK_BTAV_INIT(); return btc_queue_connect(UUID_SERVCLASS_AUDIO_SINK, remote_bda, connect_int); @@ -1449,7 +1449,7 @@ static void btc_a2d_sink_deinit(void) *******************************************************************************/ static bt_status_t btc_a2d_src_init(void) { - LOG_DEBUG("%s()\n", __func__); + BTC_TRACE_DEBUG("%s()\n", __func__); return btc_av_init(BTA_A2DP_SOURCE_SERVICE_ID); } @@ -1461,7 +1461,7 @@ static void btc_a2d_src_deinit(void) static bt_status_t btc_a2d_src_connect(bt_bdaddr_t *remote_bda) { - LOG_DEBUG("%s\n", __FUNCTION__); + BTC_TRACE_DEBUG("%s\n", __FUNCTION__); CHECK_BTAV_INIT(); return btc_queue_connect(UUID_SERVCLASS_AUDIO_SOURCE, remote_bda, connect_int); diff --git a/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c b/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c index 4d061aed90..a2e21e163b 100644 --- a/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c +++ b/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c @@ -47,9 +47,9 @@ #define MAX_CMD_QUEUE_LEN 8 #define CHECK_ESP_RC_CONNECTED do { \ - LOG_DEBUG("## %s ##", __FUNCTION__); \ + BTC_TRACE_DEBUG("## %s ##", __FUNCTION__); \ if (btc_rc_vb.rc_connected == FALSE) { \ - LOG_WARN("Function %s() called when RC is not connected", __FUNCTION__); \ + BTC_TRACE_WARNING("Function %s() called when RC is not connected", __FUNCTION__); \ return ESP_ERR_INVALID_STATE; \ } \ } while (0) @@ -138,17 +138,17 @@ static void handle_rc_features(void) ***************************************************************************/ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) { - LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle); + BTC_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle); bt_bdaddr_t rc_addr; if (p_rc_open->status == BTA_AV_SUCCESS) { //check if already some RC is connected if (btc_rc_vb.rc_connected) { - LOG_ERROR("Got RC OPEN in connected state, Connected RC: %d \ + BTC_TRACE_ERROR("Got RC OPEN in connected state, Connected RC: %d \ and Current RC: %d", btc_rc_vb.rc_handle, p_rc_open->rc_handle ); if ((btc_rc_vb.rc_handle != p_rc_open->rc_handle) && (bdcmp(btc_rc_vb.rc_addr, p_rc_open->peer_addr))) { - LOG_DEBUG("Got RC connected for some other handle"); + BTC_TRACE_DEBUG("Got RC connected for some other handle"); BTA_AvCloseRc(p_rc_open->rc_handle); return; } @@ -174,7 +174,7 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) handle_rc_features(); } } else { - LOG_ERROR("%s Connect failed with error code: %d", + BTC_TRACE_ERROR("%s Connect failed with error code: %d", __FUNCTION__, p_rc_open->status); btc_rc_vb.rc_connected = FALSE; } @@ -192,10 +192,10 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) { bt_bdaddr_t rc_addr; - LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); + BTC_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); if ((p_rc_close->rc_handle != btc_rc_vb.rc_handle) && (bdcmp(btc_rc_vb.rc_addr, p_rc_close->peer_addr))) { - LOG_ERROR("Got disconnect of unknown device"); + BTC_TRACE_ERROR("Got disconnect of unknown device"); return; } @@ -296,7 +296,7 @@ static void handle_rc_metadata_rsp ( tBTA_AV_META_MSG *p_remote_rsp) break; } #else - LOG_ERROR("%s AVRCP metadata is not enabled", __FUNCTION__); + BTC_TRACE_ERROR("%s AVRCP metadata is not enabled", __FUNCTION__); #endif } @@ -322,7 +322,7 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) key_state = 0; } - LOG_DEBUG("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status); + BTC_TRACE_DEBUG("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status); do { esp_avrc_ct_cb_param_t param; @@ -333,10 +333,10 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) btc_avrc_ct_cb_to_app(ESP_AVRC_CT_PASSTHROUGH_RSP_EVT, ¶m); } while (0); } else { - LOG_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__); + BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__); } #else - LOG_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__); + BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__); #endif } @@ -350,10 +350,10 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) ***************************************************************************/ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) { - LOG_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event)); + BTC_TRACE_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event)); switch (event) { case BTA_AV_RC_OPEN_EVT: { - LOG_DEBUG("Peer_features:%x", p_data->rc_open.peer_features); + BTC_TRACE_DEBUG("Peer_features:%x", p_data->rc_open.peer_features); handle_rc_connect( &(p_data->rc_open) ); } break; @@ -363,14 +363,14 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) #if (AVRC_CTLR_INCLUDED == TRUE) case BTA_AV_REMOTE_RSP_EVT: { - LOG_DEBUG("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id, + BTC_TRACE_DEBUG("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id, p_data->remote_rsp.key_state); handle_rc_passthrough_rsp( (&p_data->remote_rsp) ); } break; #endif case BTA_AV_RC_FEAT_EVT: { - LOG_DEBUG("Peer_features:%x", p_data->rc_feat.peer_features); + BTC_TRACE_DEBUG("Peer_features:%x", p_data->rc_feat.peer_features); btc_rc_vb.rc_features = p_data->rc_feat.peer_features; handle_rc_features(); } @@ -384,7 +384,7 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) // below events are not handled for now case BTA_AV_REMOTE_CMD_EVT: default: - LOG_DEBUG("Unhandled RC event : 0x%x", event); + BTC_TRACE_DEBUG("Unhandled RC event : 0x%x", event); } } @@ -419,7 +419,7 @@ BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr) *******************************************************************************/ static void btc_avrc_ct_init(void) { - LOG_DEBUG("## %s ##", __FUNCTION__); + BTC_TRACE_DEBUG("## %s ##", __FUNCTION__); memset (&btc_rc_vb, 0, sizeof(btc_rc_vb)); btc_rc_vb.rc_vol_label = MAX_LABEL; @@ -438,10 +438,10 @@ static void btc_avrc_ct_init(void) ***************************************************************************/ static void btc_avrc_ct_deinit(void) { - LOG_INFO("## %s ##", __FUNCTION__); + BTC_TRACE_API("## %s ##", __FUNCTION__); memset(&btc_rc_vb, 0, sizeof(btc_rc_cb_t)); - LOG_INFO("## %s ## completed", __FUNCTION__); + BTC_TRACE_API("## %s ## completed", __FUNCTION__); } static bt_status_t btc_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id) @@ -471,12 +471,12 @@ static bt_status_t btc_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t att status = BT_STATUS_SUCCESS; } else { status = BT_STATUS_FAIL; - LOG_DEBUG("%s: feature not supported", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); } } #else - LOG_DEBUG("%s: feature not enabled", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); #endif return status; @@ -505,12 +505,12 @@ static bt_status_t btc_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_ status = BT_STATUS_SUCCESS; } else { status = BT_STATUS_FAIL; - LOG_DEBUG("%s: feature not supported", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); } } #else - LOG_DEBUG("%s: feature not enabled", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); #endif return status; @@ -547,12 +547,12 @@ static bt_status_t btc_avrc_ct_send_metadata_cmd (uint8_t tl, uint8_t attr_mask) status = BT_STATUS_SUCCESS; } else { status = BT_STATUS_FAIL; - LOG_DEBUG("%s: feature not supported", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); } } #else - LOG_DEBUG("%s: feature not enabled", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); #endif return status; @@ -564,19 +564,19 @@ static bt_status_t btc_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code #if (AVRC_CTLR_INCLUDED == TRUE) CHECK_ESP_RC_CONNECTED; - LOG_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__, + BTC_TRACE_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__, key_code, key_state); if (btc_rc_vb.rc_features & BTA_AV_FEAT_RCTG) { BTA_AvRemoteCmd(btc_rc_vb.rc_handle, tl, (tBTA_AV_RC)key_code, (tBTA_AV_STATE)key_state); status = BT_STATUS_SUCCESS; - LOG_INFO("%s: succesfully sent passthrough command to BTA", __FUNCTION__); + BTC_TRACE_API("%s: succesfully sent passthrough command to BTA", __FUNCTION__); } else { status = BT_STATUS_FAIL; - LOG_DEBUG("%s: feature not supported", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); } #else - LOG_DEBUG("%s: feature not enabled", __FUNCTION__); + BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); #endif return status; @@ -614,7 +614,7 @@ void btc_avrc_call_handler(btc_msg_t *msg) break; } default: - LOG_WARN("%s : unhandled event: %d\n", __FUNCTION__, msg->act); + BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act); } } diff --git a/components/bt/bluedroid/btc/profile/std/battery/battery_prf.c b/components/bt/bluedroid/btc/profile/std/battery/battery_prf.c index d11a09f1bb..5a03aab553 100644 --- a/components/bt/bluedroid/btc/profile/std/battery/battery_prf.c +++ b/components/bt/bluedroid/btc/profile/std/battery/battery_prf.c @@ -64,7 +64,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) case ESP_GATTS_REG_EVT: { esp_gatt_status_t status = p_data->reg_oper.status; server_if = p_data->reg_oper.server_if; - LOG_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n", + BTC_TRACE_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n", event, status, server_if); UINT8 app_id = 0xff; @@ -77,18 +77,18 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) /*connect callback*/ case ESP_GATTS_CONNECT_EVT: { - LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", + BTC_TRACE_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n", BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if, p_data->conn.reason, p_data->conn.conn_id); /*return whether the remote device is currently connected*/ int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda); - LOG_ERROR("is_connected=%d\n", is_connected); + BTC_TRACE_ERROR("is_connected=%d\n", is_connected); } break; /*create service callback*/ case ESP_GATTS_CREATE_EVT: { - LOG_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n", + BTC_TRACE_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n", p_data->create.server_if, p_data->create.service_id, p_data->create.uuid.uu.uuid16); UINT16 service_uuid = p_data->create.uuid.uu.uuid16; @@ -107,7 +107,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) break; case ESP_GATTS_ADD_CHAR_EVT: { - LOG_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n", + BTC_TRACE_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n", p_data->add_result.server_if, p_data->add_result.service_id, p_data->add_result.char_uuid.uu.uuid16); UINT16 char_uuid = p_data->add_result.char_uuid.uu.uuid16; @@ -144,7 +144,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) case ESP_GATTS_ADD_CHAR_DESCR_EVT: { - LOG_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n", + BTC_TRACE_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n", p_data->add_result.server_if, p_data->add_result.service_id, p_data->add_result.attr_id, p_data->add_result.char_uuid.uu.uuid16); bas_AddCharDescr(p_data->add_result.service_id, p_data->add_result.attr_id); @@ -152,7 +152,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) break; case ESP_GATTS_START_EVT: { - LOG_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if, + BTC_TRACE_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if, p_data->srvc_oper.service_id); bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status); @@ -168,7 +168,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) UINT16 conn_id = p_data->req_data.conn_id; UINT16 handle = p_data->req_data.p_data->read_req.handle; bool is_long = p_data->req_data.p_data->read_req.is_long; - LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", event, handle, trans_id, conn_id); if (dis_valid_handle_range(handle)) { @@ -188,7 +188,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) UINT32 trans_id = p_data->req_data.trans_id; UINT16 conn_id = p_data->req_data.conn_id; UINT16 handle = p_data->req_data.p_data->write_req.handle; - LOG_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", event, handle, trans_id, conn_id); bas_s_write_attr_value(p_data->req_data.p_data, trans_id, conn_id, p_data->req_data.remote_bda); @@ -199,7 +199,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) UINT32 trans_id = p_data->req_data.trans_id; UINT16 conn_id = p_data->req_data.conn_id; UINT8 exec_write = p_data->req_data.p_data->exec_write; - LOG_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n", event, exec_write, trans_id, conn_id); } break; @@ -208,7 +208,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) UINT32 trans_id = p_data->req_data.trans_id; UINT16 conn_id = p_data->req_data.conn_id; UINT16 mtu = p_data->req_data.p_data->mtu; - LOG_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n", event, mtu, trans_id, conn_id); } break; @@ -217,13 +217,13 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data) UINT32 trans_id = p_data->req_data.trans_id; UINT16 conn_id = p_data->req_data.conn_id; - LOG_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n", trans_id, conn_id); } break; default: - LOG_ERROR("unsettled event: %d\n", event); + BTC_TRACE_ERROR("unsettled event: %d\n", event); break; } @@ -240,32 +240,32 @@ static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id, tGATT_STATUS st = ESP_GATT_OK; switch (event) { case BA_READ_LEVEL_REQ : { - LOG_ERROR("read battery level\n"); + BTC_TRACE_ERROR("read battery level\n"); p_rsp.ba_level = 60; //battery level Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp); } break; case BA_READ_PRE_FMT_REQ : { - LOG_ERROR("read presentation format\n"); + BTC_TRACE_ERROR("read presentation format\n"); } break; case BA_READ_CLT_CFG_REQ : { - LOG_ERROR("read client characteristic configuration request\n"); + BTC_TRACE_ERROR("read client characteristic configuration request\n"); p_rsp.clt_cfg = 0x0001; //notification Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp); } break; case BA_READ_RPT_REF_REQ : { - LOG_ERROR("read report reference descriptor\n"); + BTC_TRACE_ERROR("read report reference descriptor\n"); } break; /*battery level notify*/ case BA_WRITE_CLT_CFG_REQ : { - LOG_ERROR("write client characteristic configuration request\n"); + BTC_TRACE_ERROR("write client characteristic configuration request\n"); Battery_Rsp(trans_id, conn_id, app_id, st, event, NULL); int battery_level = 50; @@ -398,8 +398,8 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id) p_inst = &battery_cb.battery_inst[battery_cb.inst_id]; - LOG_ERROR("create battery service\n"); - LOG_ERROR("inst_id=%d\n", battery_cb.inst_id); + BTC_TRACE_ERROR("create battery service\n"); + BTC_TRACE_ERROR("inst_id=%d\n", battery_cb.inst_id); esp_ble_gatts_create_srvc (gatt_if, &bas_uuid, battery_cb.inst_id , BA_MAX_ATTR_NUM, ba_reg_info.is_pri); diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index e0654e6f5e..fd88148155 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -211,7 +211,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT } if (NULL != bta_adv_data->p_services->p_uuid) { - LOG_DEBUG("%s - In 16-UUID_data", __FUNCTION__); + BTC_TRACE_DEBUG("%s - In 16-UUID_data", __FUNCTION__); mask |= BTM_BLE_AD_BIT_SERVICE; ++bta_adv_data->p_services->num_service; *p_uuid_out16++ = bt_uuid.uu.uuid16; @@ -231,7 +231,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT } if (NULL != bta_adv_data->p_service_32b->p_uuid) { - LOG_DEBUG("%s - In 32-UUID_data", __FUNCTION__); + BTC_TRACE_DEBUG("%s - In 32-UUID_data", __FUNCTION__); mask |= BTM_BLE_AD_BIT_SERVICE_32; ++bta_adv_data->p_service_32b->num_service; *p_uuid_out32++ = bt_uuid.uu.uuid32; @@ -245,11 +245,11 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT bta_adv_data->p_services_128b = osi_malloc(sizeof(tBTA_BLE_128SERVICE)); if (NULL != bta_adv_data->p_services_128b) { - LOG_DEBUG("%s - In 128-UUID_data", __FUNCTION__); + BTC_TRACE_DEBUG("%s - In 128-UUID_data", __FUNCTION__); mask |= BTM_BLE_AD_BIT_SERVICE_128; memcpy(bta_adv_data->p_services_128b->uuid128, bt_uuid.uu.uuid128, LEN_UUID_128); - LOG_DEBUG("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x", bt_uuid.uu.uuid128[0], + BTC_TRACE_DEBUG("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x", bt_uuid.uu.uuid128[0], bt_uuid.uu.uuid128[1], bt_uuid.uu.uuid128[2], bt_uuid.uu.uuid128[3], bt_uuid.uu.uuid128[4], bt_uuid.uu.uuid128[5], bt_uuid.uu.uuid128[6], bt_uuid.uu.uuid128[7], bt_uuid.uu.uuid128[8], bt_uuid.uu.uuid128[9], @@ -285,7 +285,7 @@ static void btc_adv_data_callback(tBTA_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -304,7 +304,7 @@ static void btc_scan_rsp_data_callback(tBTA_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -323,7 +323,7 @@ static void btc_adv_data_raw_callback(tBTA_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -342,7 +342,7 @@ static void btc_scan_rsp_data_raw_callback(tBTA_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -387,7 +387,7 @@ static void btc_start_adv_callback(uint8_t status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -406,7 +406,7 @@ static void btc_stop_adv_callback(uint8_t status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -417,24 +417,24 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT if (!BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || !BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) { status = ESP_BT_STATUS_PARM_INVALID; - LOG_ERROR("Invalid advertisting interval parameters.\n"); + BTC_TRACE_ERROR("Invalid advertisting interval parameters.\n"); } if ((ble_adv_params->adv_type < ADV_TYPE_IND) || (ble_adv_params->adv_type > ADV_TYPE_DIRECT_IND_LOW) ) { status = ESP_BT_STATUS_PARM_INVALID; - LOG_ERROR("Invalid advertisting type parameters.\n"); + BTC_TRACE_ERROR("Invalid advertisting type parameters.\n"); } if ((ble_adv_params->adv_filter_policy < ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY) || (ble_adv_params->adv_filter_policy > ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST) ) { status = ESP_BT_STATUS_PARM_INVALID; - LOG_ERROR("Invalid advertisting type parameters.\n"); + BTC_TRACE_ERROR("Invalid advertisting type parameters.\n"); } if((ble_adv_params->channel_map | ADV_CHNL_ALL) != ADV_CHNL_ALL || ble_adv_params->channel_map == 0) { status = ESP_BT_STATUS_PARM_INVALID; - LOG_ERROR("Invalid advertisting channel map parameters.\n"); + BTC_TRACE_ERROR("Invalid advertisting channel map parameters.\n"); } if(status != ESP_BT_STATUS_SUCCESS) { if(start_adv_cback) { @@ -443,7 +443,7 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT return; } - LOG_DEBUG("API_Ble_AppStartAdvertising\n"); + BTC_TRACE_DEBUG("API_Ble_AppStartAdvertising\n"); memcpy(peer_addr.bda, ble_adv_params->peer_addr, ESP_BD_ADDR_LEN); peer_addr.type = ble_adv_params->peer_addr_type; @@ -473,7 +473,7 @@ static void btc_scan_params_callback(tGATT_IF gatt_if, tBTM_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -522,26 +522,26 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data } case BTA_DM_INQ_CMPL_EVT: { param.scan_rst.num_resps = p_data->inq_cmpl.num_resps; - LOG_DEBUG("%s BLE observe complete. Num Resp %d\n", __FUNCTION__, p_data->inq_cmpl.num_resps); + BTC_TRACE_DEBUG("%s BLE observe complete. Num Resp %d\n", __FUNCTION__, p_data->inq_cmpl.num_resps); break; } case BTA_DM_DISC_RES_EVT: - LOG_DEBUG("BTA_DM_DISC_RES_EVT\n"); + BTC_TRACE_DEBUG("BTA_DM_DISC_RES_EVT\n"); break; case BTA_DM_DISC_BLE_RES_EVT: - LOG_DEBUG("BTA_DM_DISC_BLE_RES_EVT\n"); + BTC_TRACE_DEBUG("BTA_DM_DISC_BLE_RES_EVT\n"); break; case BTA_DM_DISC_CMPL_EVT: - LOG_DEBUG("BTA_DM_DISC_CMPL_EVT\n"); + BTC_TRACE_DEBUG("BTA_DM_DISC_CMPL_EVT\n"); break; case BTA_DM_DI_DISC_CMPL_EVT: - LOG_DEBUG("BTA_DM_DI_DISC_CMPL_EVT\n"); + BTC_TRACE_DEBUG("BTA_DM_DI_DISC_CMPL_EVT\n"); break; case BTA_DM_SEARCH_CANCEL_CMPL_EVT: - LOG_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n"); + BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n"); break; default: - LOG_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event); + BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event); return; } btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL); @@ -562,7 +562,7 @@ static void btc_start_scan_callback(uint8_t status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -581,7 +581,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -604,7 +604,7 @@ void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDA sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -623,7 +623,7 @@ static void btc_set_pkt_length_callback(UINT8 status, tBTM_LE_SET_PKT_DATA_LENGT sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -641,7 +641,7 @@ static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -658,7 +658,7 @@ static void btc_set_rand_addr_callback(UINT8 status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -676,7 +676,7 @@ static void btc_set_local_privacy_callback(UINT8 status) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -686,7 +686,7 @@ static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transpor { UNUSED(bd_addr); UNUSED(transport); - LOG_DEBUG("enc_status = %x\n", enc_status); + BTC_TRACE_DEBUG("enc_status = %x\n", enc_status); return; } #endif ///SMP_INCLUDED == TRUE @@ -708,7 +708,7 @@ static void btc_read_ble_rssi_cmpl_callback(void *p_data) sizeof(esp_ble_gap_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } @@ -726,7 +726,7 @@ static void btc_ble_start_scanning(uint32_t duration, //Start scan the device BTA_DmBleScan(true, duration, results_cb, start_scan_cb); } else { - LOG_ERROR("The start_scan_cb or results_cb invalid\n"); + BTC_TRACE_ERROR("The start_scan_cb or results_cb invalid\n"); } } @@ -752,7 +752,7 @@ static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int, } if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX) { - LOG_ERROR("Invalid interval value.\n"); + BTC_TRACE_ERROR("Invalid interval value.\n"); } BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int, @@ -794,11 +794,11 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK * BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback); } else { btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR); - LOG_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0"); + BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0"); } } else { btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR); - LOG_ERROR("Invalid random addressm, the address value is NULL"); + BTC_TRACE_ERROR("Invalid random addressm, the address value is NULL"); } } @@ -819,7 +819,7 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg) if (msg->act < ESP_GAP_BLE_EVT_MAX) { btc_gap_ble_cb_to_app(msg->act, param); } else { - LOG_ERROR("%s, unknow msg->act = %d", __func__, msg->act); + BTC_TRACE_ERROR("%s, unknow msg->act = %d", __func__, msg->act); } btc_gap_ble_cb_deep_free(msg); @@ -884,13 +884,13 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->set_security_param.value != NULL) { memcpy(dst->set_security_param.value, src->set_security_param.value, length); } else { - LOG_ERROR("%s %d no mem\n",__func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); } } break; } default: - LOG_ERROR("Unhandled deep copy %d\n", msg->act); + BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act); break; } } @@ -899,14 +899,14 @@ void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) { switch (msg->act) { default: - LOG_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act); + BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act); break; } } void btc_gap_ble_arg_deep_free(btc_msg_t *msg) { - LOG_DEBUG("%s \n", __func__); + BTC_TRACE_DEBUG("%s \n", __func__); switch (msg->act) { case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { esp_ble_adv_data_t *adv = &((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data.adv_data; @@ -938,17 +938,17 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) break; } default: - LOG_DEBUG("Unhandled deep free %d\n", msg->act); + BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act); break; } } void btc_gap_ble_cb_deep_free(btc_msg_t *msg) { - LOG_DEBUG("%s", __func__); + BTC_TRACE_DEBUG("%s", __func__); switch (msg->act) { default: - LOG_DEBUG("Unhandled deep free %d", msg->act); + BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act); break; } } @@ -957,7 +957,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) { btc_ble_gap_args_t *arg = (btc_ble_gap_args_t *)msg->arg; - LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act); switch (msg->act) { case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c index c612009c18..6c2a6d5f14 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -69,7 +69,7 @@ static void btc_bt_set_scan_mode(esp_bt_scan_mode_t mode) break; default: - LOG_WARN("invalid scan mode (0x%x)", mode); + BTC_TRACE_WARNING("invalid scan mode (0x%x)", mode); return; } @@ -318,7 +318,7 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR uint32_t cod = devclass2uint (p_data->inq_res.dev_class); if (cod == 0) { - LOG_DEBUG("%s cod is 0, set as unclassified", __func__); + BTC_TRACE_DEBUG("%s cod is 0, set as unclassified", __func__); cod = COD_UNCLASSIFIED; } @@ -577,7 +577,7 @@ static void btc_gap_bt_set_cod(btc_gap_bt_args_t *arg) p_cod.service = cod->service << 5; bool ret = utl_set_device_class(&p_cod, arg->set_cod.mode); if (!ret){ - LOG_ERROR("%s set class of device failed!",__func__); + BTC_TRACE_ERROR("%s set class of device failed!",__func__); } } @@ -586,7 +586,7 @@ esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod) tBTA_UTL_COD p_cod; bool ret = utl_get_device_class(&p_cod); if (!ret){ - LOG_ERROR("%s get class of device failed!",__func__); + BTC_TRACE_ERROR("%s get class of device failed!",__func__); return ESP_BT_STATUS_FAIL; } cod->minor = p_cod.minor >> 2; @@ -635,7 +635,7 @@ esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg) void btc_gap_bt_call_handler(btc_msg_t *msg) { btc_gap_bt_args_t *arg = (btc_gap_bt_args_t *)msg->arg; - LOG_DEBUG("%s act %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act); switch (msg->act) { case BTC_GAP_BT_ACT_SET_SCAN_MODE: { btc_bt_set_scan_mode(arg->set_scan_mode.mode); diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_common.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_common.c index c78ddedbf4..e688f77753 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_common.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_common.c @@ -31,7 +31,7 @@ static void btc_set_local_mtu(uint16_t mtu) void btc_gatt_com_call_handler(btc_msg_t *msg) { - LOG_DEBUG("%s act %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act); switch (msg->act) { case BTC_GATT_ACT_SET_LOCAL_MTU: { @@ -40,7 +40,7 @@ void btc_gatt_com_call_handler(btc_msg_t *msg) break; } default: - LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act); + BTC_TRACE_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act); break; } } diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c index 8cb0080ee1..8653f60561 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatt_util.c @@ -82,7 +82,7 @@ void btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src) break; default: - LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len); + BTC_TRACE_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len); break; } } @@ -103,7 +103,7 @@ void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src) } else if (p_src->len == 0) { /* do nothing for now, there's some scenario will input 0 */ } else { - LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); + BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); } } @@ -136,7 +136,7 @@ void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src) /* do nothing for now, there's some scenario will input 0 such as, receive notify, the descriptor may be 0 */ } else { - LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); + BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); } } @@ -187,7 +187,7 @@ uint16_t set_read_value(uint8_t *gattc_if, esp_ble_gattc_cb_param_t *p_dest, tBT if (( p_src->status == BTA_GATT_OK ) && (p_src->p_value != NULL)) { - LOG_DEBUG("%s len = %d ", __func__, p_src->p_value->len); + BTC_TRACE_DEBUG("%s len = %d ", __func__, p_src->p_value->len); p_dest->read.value_len = p_src->p_value->len; if ( p_src->p_value->len > 0 && p_src->p_value->p_value != NULL ) { p_dest->read.value = p_src->p_value->p_value; diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c index ea86459fc3..0694b990f0 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -43,7 +43,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->write_char.value) { memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } break; } @@ -52,7 +52,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->write_descr.value) { memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } break; } @@ -61,7 +61,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->prep_write.value) { memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } break; } @@ -70,12 +70,12 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->prep_write_descr.value) { memcpy(dst->prep_write_descr.value, src->prep_write_descr.value, src->prep_write_descr.value_len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } break; } default: - LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act); break; } } @@ -110,7 +110,7 @@ void btc_gattc_arg_deep_free(btc_msg_t *msg) break; } default: - LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act); break; } @@ -137,7 +137,7 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) p_dest_data->read.p_value->len = p_src_data->read.p_value->len; memcpy(p_dest_data->read.p_value->p_value, p_src_data->read.p_value->p_value, p_src_data->read.p_value->len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } } break; @@ -149,7 +149,7 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) if (p_dest_data->get_addr_list.bda_list) { memcpy(p_dest_data->get_addr_list.bda_list, p_src_data->get_addr_list.bda_list, sizeof(BD_ADDR) * num_addr); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } } break; @@ -194,7 +194,7 @@ static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) ret = btc_transfer_context(&msg, p_data, sizeof(tBTA_GATTC), btc_gattc_copy_req_data); if (ret) { - LOG_ERROR("%s transfer failed\n", __func__); + BTC_TRACE_ERROR("%s transfer failed\n", __func__); } } @@ -292,7 +292,7 @@ static void btc_gattc_fill_gatt_db_conversion(uint16_t count, uint16_t num, esp_ break; } default: - LOG_WARN("%s(), Not support type(%d)", __func__, type); + BTC_TRACE_WARNING("%s(), Not support type(%d)", __func__, type); break; } } @@ -750,7 +750,7 @@ void btc_gattc_call_handler(btc_msg_t *msg) BTA_GATTC_CacheGetAddrList(arg->get_addr_list.gattc_if); break; default: - LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); + BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); break; } @@ -972,7 +972,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg) break; } default: - LOG_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act); + BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act); break; } diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c index a265057d5b..74ae46a6ed 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -68,7 +68,7 @@ static inline void btc_gatts_uuid_format_convert(esp_bt_uuid_t* dest_uuid, uint1 memcpy(dest_uuid->uuid.uuid128, src_uuid_p, src_uuid_len); } else{ - LOG_ERROR("%s wrong uuid length %d\n", __func__, src_uuid_len); + BTC_TRACE_ERROR("%s wrong uuid length %d\n", __func__, src_uuid_len); } } @@ -85,7 +85,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->send_ind.value) { memcpy(dst->send_ind.value, src->send_ind.value, src->send_ind.value_len); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } break; } @@ -95,7 +95,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->send_rsp.rsp) { memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t)); } else { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } } break; @@ -108,7 +108,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) memcpy(dst->add_char.char_val.attr_value, src->add_char.char_val.attr_value, src->add_char.char_val.attr_len); }else{ - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } } break; @@ -120,7 +120,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) memcpy(dst->add_descr.descr_val.attr_value, src->add_descr.descr_val.attr_value, src->add_descr.descr_val.attr_len); }else{ - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } } break; @@ -133,7 +133,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) memcpy(dst->create_attr_tab.gatts_attr_db, src->create_attr_tab.gatts_attr_db, sizeof(esp_gatts_attr_db_t)*num_attr); }else{ - LOG_ERROR("%s %d no mem\n",__func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); } } break; @@ -145,13 +145,13 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if(dst->set_attr_val.value != NULL){ memcpy(dst->set_attr_val.value, src->set_attr_val.value, len); }else{ - LOG_ERROR("%s %d no mem\n",__func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); } } break; } default: - LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act); break; } @@ -200,7 +200,7 @@ void btc_gatts_arg_deep_free(btc_msg_t *msg) break; default: - LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act); break; } @@ -244,7 +244,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, } future_p = future_new(); if (future_p == NULL) { - LOG_ERROR("%s failed:no mem\n", __func__); + BTC_TRACE_ERROR("%s failed:no mem\n", __func__); return ; } btc_creat_tab_env.complete_future = future_p; @@ -265,7 +265,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, srvc_inst_id, max_nb_attr, true); btc_creat_tab_env.is_use_svc = true; } else { - LOG_ERROR("Each service table can only created one primary service."); + BTC_TRACE_ERROR("Each service table can only created one primary service."); param.add_attr_tab.status = ESP_GATT_ERROR; btc_gatts_cb_to_app(ESP_GATTS_CREAT_ATTR_TAB_EVT, gatts_if, ¶m); //reset the env after sent the data to app @@ -274,7 +274,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, } if (future_await(future_p) == FUTURE_FAIL) { - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return; } break; @@ -292,7 +292,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, srvc_inst_id, max_nb_attr, false); btc_creat_tab_env.is_use_svc = true; } else { - LOG_ERROR("Each service table can only created one secondary service."); + BTC_TRACE_ERROR("Each service table can only created one secondary service."); param.add_attr_tab.status = ESP_GATT_ERROR; btc_gatts_cb_to_app(ESP_GATTS_CREAT_ATTR_TAB_EVT, gatts_if, ¶m); //reset the env after sent the data to app @@ -300,7 +300,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, return; } if (future_await(future_p) == FUTURE_FAIL) { - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return; } break; @@ -314,7 +314,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, incl_svc_desc->start_hdl); if (future_await(future_p) == FUTURE_FAIL) { - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return; } } @@ -333,7 +333,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, if(btc_creat_tab_env.svc_start_hdl != 0){ svc_hal = btc_creat_tab_env.svc_start_hdl; if((gatts_attr_db[i].att_desc.value) == NULL){ - LOG_ERROR("%s Characteristic declaration should not be NULL\n", __func__); + BTC_TRACE_ERROR("%s Characteristic declaration should not be NULL\n", __func__); } else{ char_property = (uint8_t)(*(uint8_t*)(gatts_attr_db[i].att_desc.value)); @@ -348,7 +348,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, perm, char_property, &attr_val, &control); if (future_await(future_p) == FUTURE_FAIL) { - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return; } } @@ -383,7 +383,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, BTA_GATTS_AddCharDescriptor(svc_hal, perm, &bta_char_uuid, &attr_val, &control); if (future_await(future_p) == FUTURE_FAIL) { - LOG_ERROR("%s failed\n", __func__); + BTC_TRACE_ERROR("%s failed\n", __func__); return; } } @@ -424,18 +424,18 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat case ESP_GATT_UUID_PRI_SERVICE: case ESP_GATT_UUID_SEC_SERVICE: if (++svc_num > 1) { - LOG_ERROR("Each service table can only created one primary service or secondly service."); + BTC_TRACE_ERROR("Each service table can only created one primary service or secondly service."); return ESP_GATT_ERROR; } break; case ESP_GATT_UUID_INCLUDE_SERVICE: { esp_gatts_incl_svc_desc_t *svc_desc = (esp_gatts_incl_svc_desc_t *)gatts_attr_db[i].att_desc.value; if(svc_desc == NULL) { - LOG_ERROR("%s, The include service attribute should not be NULL.", __func__); + BTC_TRACE_ERROR("%s, The include service attribute should not be NULL.", __func__); return ESP_GATT_INVALID_PDU; } else if((svc_desc->start_hdl == 0) || (svc_desc->end_hdl == 0) || (svc_desc->start_hdl == svc_desc->end_hdl)) { - LOG_ERROR("%s, The include service attribute handle is invalid, start_hanlde = %d, end_handle = %d",\ + BTC_TRACE_ERROR("%s, The include service attribute handle is invalid, start_hanlde = %d, end_handle = %d",\ __func__, svc_desc->start_hdl, svc_desc->end_hdl); return ESP_GATT_INVALID_HANDLE; } @@ -443,14 +443,14 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat } case ESP_GATT_UUID_CHAR_DECLARE: if((gatts_attr_db[i].att_desc.value) == NULL) { - LOG_ERROR("%s, Characteristic declaration should not be NULL.", __func__); + BTC_TRACE_ERROR("%s, Characteristic declaration should not be NULL.", __func__); return ESP_GATT_INVALID_PDU; } if(gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_16 && gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_32 && gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_128) { - LOG_ERROR("%s, The Charateristic uuid length = %d is invalid", __func__,\ + BTC_TRACE_ERROR("%s, The Charateristic uuid length = %d is invalid", __func__,\ gatts_attr_db[i+1].att_desc.uuid_length); return ESP_GATT_INVALID_ATTR_LEN; } @@ -462,7 +462,7 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat uuid == ESP_GATT_UUID_CHAR_SRVR_CONFIG || uuid == ESP_GATT_UUID_CHAR_PRESENT_FORMAT || uuid == ESP_GATT_UUID_CHAR_AGG_FORMAT || uuid == ESP_GATT_UUID_CHAR_VALID_RANGE || uuid == ESP_GATT_UUID_EXT_RPT_REF_DESCR || uuid == ESP_GATT_UUID_RPT_REF_DESCR) { - LOG_ERROR("%s, The charateristic value uuid = %d is invalid", __func__, uuid); + BTC_TRACE_ERROR("%s, The charateristic value uuid = %d is invalid", __func__, uuid); return ESP_GATT_INVALID_PDU; } } @@ -584,7 +584,7 @@ static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) sizeof(tBTA_GATTS), btc_gatts_cb_param_copy_req); if (status != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } diff --git a/components/bt/bluedroid/btc/profile/std/hid_le/hid_le_prf.c b/components/bt/bluedroid/btc/profile/std/hid_le/hid_le_prf.c index 06a882a739..6f54bd4caf 100644 --- a/components/bt/bluedroid/btc/profile/std/hid_le/hid_le_prf.c +++ b/components/bt/bluedroid/btc/profile/std/hid_le/hid_le_prf.c @@ -265,12 +265,12 @@ static void hidd_add_characterisitc(const char_desc_t *char_desc) { uint16_t service_id; if (char_desc == NULL) { - LOG_ERROR("Invalid hid characteristic\n"); + BTC_TRACE_ERROR("Invalid hid characteristic\n"); return; } //check the hid device serivce has been register to the data base or not if (!hidd_le_env.enabled) { - LOG_ERROR("The hid device didn't register yet\n"); + BTC_TRACE_ERROR("The hid device didn't register yet\n"); return; } //get the service id from the env whitch has been register @@ -306,7 +306,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) case ESP_GATTS_REG_EVT: //check the register of the hid device profile has been succeess or not if (p_data->reg_oper.status != ESP_GATT_OK) { - LOG_ERROR("hidd profile register failed\n"); + BTC_TRACE_ERROR("hidd profile register failed\n"); } hidd_le_env.hidd_inst.app_id = app_id; //save the gatt interface in the hid device ENV @@ -337,9 +337,9 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) case ESP_GATTS_ADD_CHAR_EVT: //save the charateristic handle to the env hidd_le_env.hidd_inst.att_tbl[hid_char_idx - 1] = p_data->add_result.attr_id; - LOG_ERROR("hanlder = %x, p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.attr_id, + BTC_TRACE_ERROR("hanlder = %x, p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.attr_id, p_data->add_result.char_uuid.uu.uuid16); - LOG_ERROR("hid_char_idx=%x\n", hid_char_idx); + BTC_TRACE_ERROR("hid_char_idx=%x\n", hid_char_idx); if (hid_char_idx <= HIDD_LE_CHAR_MAX) { //added the characteristic until the index overflow if ((p_data->add_result.char_uuid.uu.uuid16 == CHAR_BOOT_KB_IN_REPORT_UUID) || @@ -347,7 +347,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) // add the gattc config descriptor to the notify charateristic //tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE); uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG; - LOG_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n", + BTC_TRACE_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.char_uuid.uu.uuid16); esp_ble_gatts_add_char_descr (hidd_le_env.hidd_clcb.cur_srvc_id, GATT_PERM_WRITE, @@ -366,7 +366,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) BTA_GATTS_AddCharDescriptor (hidd_le_env.hidd_clcb.cur_srvc_id, GATT_PERM_READ, &uuid); - LOG_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n", + BTC_TRACE_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.char_uuid.uu.uuid16); } if (p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_RPT_REF_DESCR) { @@ -377,12 +377,12 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) } break; case ESP_GATTS_READ_EVT: { - LOG_ERROR("Hidd profile BTA_GATTS_READ_EVT\n"); + BTC_TRACE_ERROR("Hidd profile BTA_GATTS_READ_EVT\n"); UINT32 trans_id = p_data->req_data.trans_id; UINT16 conn_id = p_data->req_data.conn_id; UINT16 handle = p_data->req_data.p_data->read_req.handle; bool is_long = p_data->req_data.p_data->read_req.is_long; - LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", + BTC_TRACE_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n", event, handle, trans_id, conn_id); hidd_read_attr_value(p_data->req_data.p_data, trans_id); @@ -398,7 +398,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) if (!p_clcb->in_use) { p_clcb->in_use = TRUE; p_clcb->conn_id = p_data->conn.conn_id;; - LOG_ERROR("hidd->conn_id = %x\n", p_data->conn.conn_id); + BTC_TRACE_ERROR("hidd->conn_id = %x\n", p_data->conn.conn_id); p_clcb->connected = TRUE; memcpy(p_clcb->remote_bda, p_data->conn.remote_bda, BD_ADDR_LEN); } @@ -510,7 +510,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, hidd_inst_t *p_inst = &hidd_le_env.hidd_inst; tGATTS_RSP rsp; uint8_t *pp; - LOG_ERROR("conn_id = %x, trans_id = %x, event = %x\n", + BTC_TRACE_ERROR("conn_id = %x, trans_id = %x, event = %x\n", conn_id, trans_id, event); if (p_inst->app_id == app_id) { @@ -522,7 +522,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, if (p_inst->pending_evt == event) { switch (event) { case HIDD_LE_READ_INFO_EVT: - LOG_ERROR(" p_inst->att_tbl[HIDD_LE_INFO_CHAR] = %x\n", + BTC_TRACE_ERROR(" p_inst->att_tbl[HIDD_LE_INFO_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_INFO_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_INFO_CHAR]; rsp.attr_value.len = HID_INFORMATION_LEN; @@ -533,7 +533,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, break; case HIDD_LE_READ_CTNL_PT_EVT: - LOG_ERROR(" p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR] = %x\n", + BTC_TRACE_ERROR(" p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR]; rsp.attr_value.len = 0; @@ -542,7 +542,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, break; case HIDD_LE_READ_REPORT_MAP_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR]; rsp.attr_value.len = hidReportMapLen; @@ -552,7 +552,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp); break; case HIDD_LE_READ_REPORT_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]; rsp.attr_value.len = 0; @@ -560,7 +560,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp); break; case HIDD_LE_READ_PROTO_MODE_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR]; rsp.attr_value.len = 1; @@ -570,7 +570,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp); break; case HIDD_LE_BOOT_KB_IN_REPORT_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]; rsp.attr_value.len = 0; @@ -578,7 +578,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp); break; case HIDD_LE_BOOT_KB_OUT_REPORT_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]; rsp.attr_value.len = 0; @@ -586,7 +586,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id, esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp); break; case HIDD_LE_BOOT_MOUSE_IN_REPORT_EVT: - LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", + BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n", p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]); rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]; rsp.attr_value.len = 0; @@ -616,7 +616,7 @@ esp_gatt_status_t hidd_le_init (void) tBT_UUID app_uuid = {LEN_UUID_16, {ATT_SVC_HID}}; if (hidd_le_env.enabled) { - LOG_ERROR("hid device svc already initaliezd\n"); + BTC_TRACE_ERROR("hid device svc already initaliezd\n"); return ESP_GATT_ERROR; } else { memset(&hidd_le_env, 0, sizeof(hidd_le_env_t)); diff --git a/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c index c8b58d4d4b..ef3287ce89 100644 --- a/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c @@ -204,12 +204,12 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u case BTA_JV_RFCOMM_SRV_OPEN_EVT: slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } slot_new = malloc_spp_slot(); if (!slot_new) { - LOG_ERROR("%s unable to malloc RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__); break; } new_user_data = (void *)(uintptr_t)slot_new->id; @@ -230,7 +230,7 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u case BTA_JV_RFCOMM_OPEN_EVT: slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } slot->connected = TRUE; @@ -240,7 +240,7 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u case BTA_JV_RFCOMM_CLOSE_EVT: slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } if (slot->connected) { @@ -264,7 +264,7 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u sizeof(tBTA_JV), NULL); if (status != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed", __func__); } return new_user_data; } @@ -281,12 +281,12 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } if (p_data->scn == 0) { - LOG_ERROR("%s unable to get scn, start server fail!", __func__); + BTC_TRACE_ERROR("%s unable to get scn, start server fail!", __func__); btc_create_server_fail_cb(); free_spp_slot(slot); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); @@ -301,7 +301,7 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } @@ -310,7 +310,7 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d BTA_JvRfcommStartServer(slot->security, slot->role, slot->scn, slot->max_session, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id); } else { - LOG_ERROR("%s unable to create record, start server fail!", __func__); + BTC_TRACE_ERROR("%s unable to create record, start server fail!", __func__); btc_create_server_fail_cb(); BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM); free_spp_slot(slot); @@ -325,7 +325,7 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d status = btc_transfer_context(&msg, p_data, sizeof(tBTA_JV), NULL); if (status != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } break; } @@ -334,7 +334,7 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d static void btc_spp_init(btc_spp_args_t *arg) { if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) { - LOG_ERROR("%s osi_mutex_new failed\n", __func__); + BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__); } spp_local_param.spp_mode = arg->init.mode; spp_local_param.spp_slot_id = 0; @@ -376,7 +376,7 @@ static void btc_spp_connect(btc_spp_args_t *arg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = malloc_spp_slot(); if (!slot) { - LOG_ERROR("%s unable to malloc RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } @@ -394,7 +394,7 @@ static void btc_spp_disconnect(btc_spp_args_t *arg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_handle(arg->disconnect.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot! disconnect fail!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot! disconnect fail!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } @@ -409,7 +409,7 @@ static void btc_spp_start_srv(btc_spp_args_t *arg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = malloc_spp_slot(); if (!slot) { - LOG_ERROR("%s unable to malloc RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } @@ -428,7 +428,7 @@ static void btc_spp_write(btc_spp_args_t *arg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_handle(arg->write.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } @@ -462,9 +462,9 @@ void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->start_discovery.p_uuid_list) { memcpy(dst->start_discovery.p_uuid_list, src->start_discovery.p_uuid_list, src->start_discovery.num_uuid * sizeof(tSDP_UUID)); } else if (src->start_discovery.num_uuid == 0) { - LOG_ERROR("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act); } else { - LOG_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); } break; case BTC_SPP_ACT_WRITE: @@ -472,9 +472,9 @@ void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) if (dst->write.p_data) { memcpy(dst->write.p_data, src->write.p_data, src->write.len); } else if (src->write.len == 0) { - LOG_DEBUG("%s %d no mem\n", __func__, msg->act); + BTC_TRACE_DEBUG("%s %d no mem\n", __func__, msg->act); } else { - LOG_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); + BTC_TRACE_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); } break; default: @@ -523,7 +523,7 @@ void btc_spp_call_handler(btc_msg_t *msg) btc_spp_write(arg); break; default: - LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); + BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); break; } btc_spp_arg_deep_free(msg); @@ -557,7 +557,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_handle(p_data->rfc_open.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } @@ -581,7 +581,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_handle(p_data->rfc_srv_open.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } @@ -598,7 +598,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_handle(p_data->rfc_write.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } @@ -650,7 +650,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); slot = find_slot_by_handle(p_data->rfc_cong.handle); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; } @@ -684,7 +684,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) osi_free (p_data->data_ind.p_buf); break; default: - LOG_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act); + BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act); break; } @@ -707,7 +707,7 @@ static void spp_delay_append(list_t *list, BT_HDR *p_buf){ vTaskDelay(100 / portTICK_PERIOD_MS); } osi_free(p_buf); - LOG_WARN("%s There is too much data not accepted, discard it!", __func__); + BTC_TRACE_WARNING("%s There is too much data not accepted, discard it!", __func__); } int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf) @@ -723,7 +723,7 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_id(id); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return 0; } @@ -734,7 +734,7 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf) status = btc_transfer_context(&msg, &p_data, sizeof(tBTA_JV), NULL); if (status != BT_STATUS_SUCCESS) { - LOG_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } else { if (list_is_empty(slot->incoming_list)) { @@ -769,7 +769,7 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_fd(fd); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return -1; } @@ -788,7 +788,7 @@ static int spp_vfs_close(int fd) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_fd(fd); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return -1; } @@ -816,7 +816,7 @@ static ssize_t spp_vfs_read(int fd, void * dst, size_t size) osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = find_slot_by_fd(fd); if (!slot) { - LOG_ERROR("%s unable to find RFCOMM slot!", __func__); + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return -1; } diff --git a/components/bt/bluedroid/common/include/common/bt_trace.h b/components/bt/bluedroid/common/include/common/bt_trace.h index b95dd3a8b7..7583479b2b 100644 --- a/components/bt/bluedroid/common/include/common/bt_trace.h +++ b/components/bt/bluedroid/common/include/common/bt_trace.h @@ -18,19 +18,42 @@ #ifndef _BT_TRACE_H_ #define _BT_TRACE_H_ + #include "sdkconfig.h" #include #include "stack/bt_types.h" +#ifndef LOG_LOCAL_LEVEL +#ifndef BOOTLOADER_BUILD +#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL +#else +#define LOG_LOCAL_LEVEL CONFIG_LOG_BOOTLOADER_LEVEL +#endif +#endif + #include "esp_log.h" -#define TAG "BT" +// Mapping between ESP_LOG_LEVEL and BT_TRACE_LEVEL +#if (LOG_LOCAL_LEVEL >= 4) +#define LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL+1) +#else +#define LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL +#endif -#define BT_PRINTF(fmt, ...) ESP_LOGE(TAG, fmt, ##__VA_ARGS__) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define BT_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_INITIAL_TRACE_LEVEL, LOG_LOCAL_LEVEL_MAPPING) >= BT_TRACE_LEVEL_##LEVEL) + +//#define TAG "BT" + +#define BT_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BT_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BT_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BT_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BT_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } #ifndef assert -#define assert(x) do { if (!(x)) BT_PRINTF("bt host error %s %u\n", __FILE__, __LINE__); } while (0) +#define assert(x) do { if (!(x)) BT_PRINT_E("bt host error %s %u\n", __FILE__, __LINE__); } while (0) #endif inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) @@ -42,15 +65,15 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) } if (prefix) { - BT_PRINTF("%s: len %d\n", prefix, len); + printf("%s: len %d\r\n", prefix, len); } for (i = 0; i < len; i+=16) { - BT_PRINTF("%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x\n", + printf("%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x\r\n", *(data + i), *(data + i + 1), *(data + i + 2), *(data + i + 3), *(data + i + 4), *(data + i + 5), *(data + i + 6), *(data + i + 7), *(data + i + 8), *(data + i + 9), *(data + i + 10), *(data + i + 11), *(data + i + 12), *(data + i + 13), *(data + i + 14), *(data + i + 15)); } - BT_PRINTF("\n"); + printf("\r\n"); } #ifdef BTTRC_DUMP_BUFFER @@ -174,6 +197,10 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) #define BT_USE_TRACES FALSE #endif +#ifndef BT_TRACE_APPL +#define BT_TRACE_APPL BT_USE_TRACES +#endif + /****************************************************************************** ** ** Trace Levels @@ -189,238 +216,310 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len) // btla-specific ++ /* Core Stack default trace levels */ -#ifndef HCI_INITIAL_TRACE_LEVEL +#ifdef CONFIG_HCI_INITIAL_TRACE_LEVEL +#define HCI_INITIAL_TRACE_LEVEL CONFIG_HCI_INITIAL_TRACE_LEVEL +#else #define HCI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef BTM_INITIAL_TRACE_LEVEL +#ifdef CONFIG_BTM_INITIAL_TRACE_LEVEL +#define BTM_INITIAL_TRACE_LEVEL CONFIG_BTM_INITIAL_TRACE_LEVEL +#else #define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef L2CAP_INITIAL_TRACE_LEVEL +#ifdef CONFIG_L2CAP_INITIAL_TRACE_LEVEL +#define L2CAP_INITIAL_TRACE_LEVEL CONFIG_L2CAP_INITIAL_TRACE_LEVEL +#else #define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef RFCOMM_INITIAL_TRACE_LEVEL +#ifdef CONFIG_RFCOMM_INITIAL_TRACE_LEVEL +#define RFCOMM_INITIAL_TRACE_LEVEL CONFIG_RFCOMM_INITIAL_TRACE_LEVEL +#else #define RFCOMM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef SDP_INITIAL_TRACE_LEVEL +#ifdef CONFIG_SDP_INITIAL_TRACE_LEVEL +#define SDP_INITIAL_TRACE_LEVEL CONFIG_SDP_INITIAL_TRACE_LEVEL +#else #define SDP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef GAP_INITIAL_TRACE_LEVEL +#ifdef CONFIG_GAP_INITIAL_TRACE_LEVEL +#define GAP_INITIAL_TRACE_LEVEL CONFIG_GAP_INITIAL_TRACE_LEVEL +#else #define GAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef BNEP_INITIAL_TRACE_LEVEL +#ifdef CONFIG_BNEP_INITIAL_TRACE_LEVEL +#define BNEP_INITIAL_TRACE_LEVEL CONFIG_BNEP_INITIAL_TRACE_LEVEL +#else #define BNEP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef PAN_INITIAL_TRACE_LEVEL +#ifdef CONFIG_PAN_INITIAL_TRACE_LEVEL +#define PAN_INITIAL_TRACE_LEVEL CONFIG_PAN_INITIAL_TRACE_LEVEL +#else #define PAN_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef A2D_INITIAL_TRACE_LEVEL +#ifdef CONFIG_A2D_INITIAL_TRACE_LEVEL +#define A2D_INITIAL_TRACE_LEVEL CONFIG_A2D_INITIAL_TRACE_LEVEL +#else #define A2D_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef AVDT_INITIAL_TRACE_LEVEL +#ifdef CONFIG_AVDT_INITIAL_TRACE_LEVEL +#define AVDT_INITIAL_TRACE_LEVEL CONFIG_AVDT_INITIAL_TRACE_LEVEL +#else #define AVDT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef AVCT_INITIAL_TRACE_LEVEL +#ifdef CONFIG_AVCT_INITIAL_TRACE_LEVEL +#define AVCT_INITIAL_TRACE_LEVEL CONFIG_AVCT_INITIAL_TRACE_LEVEL +#else #define AVCT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef AVRC_INITIAL_TRACE_LEVEL +#ifdef CONFIG_AVRC_INITIAL_TRACE_LEVEL +#define AVRC_INITIAL_TRACE_LEVEL CONFIG_AVRC_INITIAL_TRACE_LEVEL +#else #define AVRC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef MCA_INITIAL_TRACE_LEVEL +#ifdef CONFIG_MCA_INITIAL_TRACE_LEVEL +#define MCA_INITIAL_TRACE_LEVEL CONFIG_MCA_INITIAL_TRACE_LEVEL +#else #define MCA_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef HID_INITIAL_TRACE_LEVEL +#ifdef CONFIG_HID_INITIAL_TRACE_LEVEL +#define HID_INITIAL_TRACE_LEVEL CONFIG_HID_INITIAL_TRACE_LEVEL +#else #define HID_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef APPL_INITIAL_TRACE_LEVEL +#ifdef CONFIG_APPL_INITIAL_TRACE_LEVEL +#define APPL_INITIAL_TRACE_LEVEL CONFIG_APPL_INITIAL_TRACE_LEVEL +#else #define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef BT_TRACE_APPL -#define BT_TRACE_APPL BT_USE_TRACES +#ifdef CONFIG_GATT_INITIAL_TRACE_LEVEL +#define GATT_INITIAL_TRACE_LEVEL CONFIG_GATT_INITIAL_TRACE_LEVEL +#else +#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#ifndef GATT_INITIAL_TRACE_LEVEL -#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING -#endif - -#ifndef SMP_INITIAL_TRACE_LEVEL +#ifdef CONFIG_SMP_INITIAL_TRACE_LEVEL +#define SMP_INITIAL_TRACE_LEVEL CONFIG_SMP_INITIAL_TRACE_LEVEL +#else #define SMP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -// btla-specific -- -/* Define common tracing for all */ -#define LOG_LEVEL_ERROR 1 -#define LOG_LEVEL_WARN 2 -#define LOG_LEVEL_INFO 3 -#define LOG_LEVEL_DEBUG 4 -#define LOG_LEVEL_VERBOSE 5 -#ifndef LOG_LEVEL -#define LOG_LEVEL LOG_LEVEL_INFO +#ifdef CONFIG_BTIF_INITIAL_TRACE_LEVEL +#define BTIF_INITIAL_TRACE_LEVEL CONFIG_BTIF_INITIAL_TRACE_LEVEL +#else +#define BTIF_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING #endif -#if !CONFIG_BT_STACK_NO_LOG -#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0) -#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0) -#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0) -#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0) -#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0) +#ifdef CONFIG_BTC_INITIAL_TRACE_LEVEL +#define BTC_INITIAL_TRACE_LEVEL CONFIG_BTC_INITIAL_TRACE_LEVEL +#else +#define BTC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#endif -/* Define tracing for the HCI unit -*/ -#define HCI_TRACE_ERROR(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt,## args);} -#define HCI_TRACE_WARNING(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt,## args);} -#define HCI_TRACE_EVENT(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt,## args);} -#define HCI_TRACE_DEBUG(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} +#ifdef CONFIG_OSI_INITIAL_TRACE_LEVEL +#define OSI_INITIAL_TRACE_LEVEL CONFIG_OSI_INITIAL_TRACE_LEVEL +#else +#define OSI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#endif + +#ifdef CONFIG_BLUFI_INITIAL_TRACE_LEVEL +#define BLUFI_INITIAL_TRACE_LEVEL CONFIG_BLUFI_INITIAL_TRACE_LEVEL +#else +#define BLUFI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING +#endif + +// btla-specific -- + +#if !CONFIG_BT_STACK_NO_LOG +#define LOG_ERROR(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) esp_log_write(ESP_LOG_ERROR, "BT_LOG", LOG_FORMAT(E, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); } +#define LOG_WARN(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) esp_log_write(ESP_LOG_WARN, "BT_LOG", LOG_FORMAT(W, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); } +#define LOG_INFO(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) esp_log_write(ESP_LOG_INFO, "BT_LOG", LOG_FORMAT(I, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); } +#define LOG_DEBUG(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) esp_log_write(ESP_LOG_DEBUG, "BT_LOG", LOG_FORMAT(D, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); } +#define LOG_VERBOSE(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) esp_log_write(ESP_LOG_VERBOSE, "BT_LOG", LOG_FORMAT(V, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); } /* Define tracing for BTM */ -#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTM, ERROR)) BT_PRINT_E("BT_BTM", fmt, ## args);} +#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTM, WARNING)) BT_PRINT_W("BT_BTM", fmt, ## args);} +#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTM,API)) BT_PRINT_I("BT_BTM", fmt, ## args);} +#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTM,EVENT)) BT_PRINT_D("BT_BTM", fmt, ## args);} +#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTM,DEBUG)) BT_PRINT_D("BT_BTM", fmt, ## args);} /* Define tracing for the L2CAP unit */ -#define L2CAP_TRACE_ERROR(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define L2CAP_TRACE_WARNING(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define L2CAP_TRACE_API(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define L2CAP_TRACE_EVENT(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define L2CAP_TRACE_DEBUG(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define L2CAP_TRACE_ERROR(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(L2CAP, ERROR)) BT_PRINT_E("BT_L2CAP", fmt, ## args);} +#define L2CAP_TRACE_WARNING(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(L2CAP, WARNING)) BT_PRINT_W("BT_L2CAP", fmt, ## args);} +#define L2CAP_TRACE_API(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(L2CAP,API)) BT_PRINT_I("BT_L2CAP", fmt, ## args);} +#define L2CAP_TRACE_EVENT(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(L2CAP,EVENT)) BT_PRINT_D("BT_L2CAP", fmt, ## args);} +#define L2CAP_TRACE_DEBUG(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(L2CAP,DEBUG)) BT_PRINT_D("BT_L2CAP", fmt, ## args);} /* Define tracing for the SDP unit */ -#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SDP, ERROR)) BT_PRINT_E("BT_SDP", fmt, ## args);} +#define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SDP, WARNING)) BT_PRINT_W("BT_SDP", fmt, ## args);} +#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SDP,API)) BT_PRINT_I("BT_SDP", fmt, ## args);} +#define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SDP,EVENT)) BT_PRINT_D("BT_SDP", fmt, ## args);} +#define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SDP,DEBUG)) BT_PRINT_D("BT_SDP", fmt, ## args);} /* Define tracing for the RFCOMM unit */ -#define RFCOMM_TRACE_ERROR(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define RFCOMM_TRACE_WARNING(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define RFCOMM_TRACE_API(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define RFCOMM_TRACE_EVENT(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define RFCOMM_TRACE_DEBUG(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define RFCOMM_TRACE_ERROR(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(RFCOMM, ERROR)) BT_PRINT_E("BT_RFCOMM", fmt, ## args);} +#define RFCOMM_TRACE_WARNING(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(RFCOMM, WARNING)) BT_PRINT_W("BT_RFCOMM", fmt, ## args);} +#define RFCOMM_TRACE_API(fmt, args...) {if (rfc_cb.trace_level >=BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(RFCOMM,API)) BT_PRINT_I("BT_RFCOMM", fmt, ## args);} +#define RFCOMM_TRACE_EVENT(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(RFCOMM,EVENT)) BT_PRINT_D("BT_RFCOMM", fmt, ## args);} +#define RFCOMM_TRACE_DEBUG(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(RFCOMM,DEBUG)) BT_PRINT_D("BT_RFCOMM", fmt, ## args);} /* Generic Access Profile traces */ -#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} +#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GAP, ERROR)) BT_PRINT_E("BT_GAP", fmt, ## args);} +#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GAP,API)) BT_PRINT_I("BT_GAP", fmt, ## args);} +#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GAP,EVENT)) BT_PRINT_D("BT_GAP", fmt, ## args);} +#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GAP, WARNING)) BT_PRINT_W("BT_GAP", fmt, ## args);} /* define traces for HID Host */ -#define HIDH_TRACE_ERROR(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define HIDH_TRACE_WARNING(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define HIDH_TRACE_API(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define HIDH_TRACE_EVENT(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define HIDH_TRACE_DEBUG(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define HIDH_TRACE_ERROR(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HIDH, ERROR)) BT_PRINT_E("BT_HIDH", fmt, ## args);} +#define HIDH_TRACE_WARNING(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HIDH, WARNING)) BT_PRINT_W("BT_HIDH", fmt, ## args);} +#define HIDH_TRACE_API(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(HIDH,API)) BT_PRINT_I("BT_HIDH", fmt, ## args);} +#define HIDH_TRACE_EVENT(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HIDH,EVENT)) BT_PRINT_D("BT_HIDH", fmt, ## args);} +#define HIDH_TRACE_DEBUG(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HIDH,DEBUG)) BT_PRINT_D("BT_HIDH", fmt, ## args);} /* define traces for BNEP */ -#define BNEP_TRACE_ERROR(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define BNEP_TRACE_WARNING(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define BNEP_TRACE_API(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define BNEP_TRACE_EVENT(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define BNEP_TRACE_DEBUG(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define BNEP_TRACE_ERROR(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BNEP, ERROR)) BT_PRINT_E("BT_BNEP", fmt, ## args);} +#define BNEP_TRACE_WARNING(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BNEP, WARNING)) BT_PRINT_W("BT_BNEP", fmt, ## args);} +#define BNEP_TRACE_API(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BNEP,API)) BT_PRINT_I("BT_BNEP", fmt, ## args);} +#define BNEP_TRACE_EVENT(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BNEP,EVENT)) BT_PRINT_D("BT_BNEP", fmt, ## args);} +#define BNEP_TRACE_DEBUG(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BNEP,DEBUG)) BT_PRINT_D("BT_BNEP", fmt, ## args);} /* define traces for PAN */ -#define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(PAN, ERROR)) BT_PRINT_E("BT_PAN", fmt, ## args);} +#define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(PAN, WARNING)) BT_PRINT_W("BT_PAN", fmt, ## args);} +#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(PAN,API)) BT_PRINT_I("BT_PAN", fmt, ## args);} +#define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(PAN,EVENT)) BT_PRINT_D("BT_PAN", fmt, ## args);} +#define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(PAN,DEBUG)) BT_PRINT_D("BT_PAN", fmt, ## args);} /* Define tracing for the A2DP profile */ -#define A2D_TRACE_ERROR(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define A2D_TRACE_ERROR(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(A2D, ERROR)) BT_PRINT_E("BT_A2D", fmt, ## args);} +#define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(A2D, WARNING)) BT_PRINT_W("BT_A2D", fmt, ## args);} +#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(A2D,API)) BT_PRINT_I("BT_A2D", fmt, ## args);} +#define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(A2D,EVENT)) BT_PRINT_D("BT_A2D", fmt, ## args);} +#define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(A2D,DEBUG)) BT_PRINT_D("BT_A2D", fmt, ## args);} /* AVDTP */ -#define AVDT_TRACE_ERROR(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define AVDT_TRACE_WARNING(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define AVDT_TRACE_EVENT(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define AVDT_TRACE_DEBUG(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define AVDT_TRACE_API(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define AVDT_TRACE_ERROR(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVDT, ERROR)) BT_PRINT_E("BT_AVDT", fmt, ## args);} +#define AVDT_TRACE_WARNING(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVDT, WARNING)) BT_PRINT_W("BT_AVDT", fmt, ## args);} +#define AVDT_TRACE_API(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVDT,API)) BT_PRINT_I("BT_AVDT", fmt, ## args);} +#define AVDT_TRACE_EVENT(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVDT,EVENT)) BT_PRINT_D("BT_AVDT", fmt, ## args);} +#define AVDT_TRACE_DEBUG(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVDT,DEBUG)) BT_PRINT_D("BT_AVDT", fmt, ## args);} /* Define tracing for the AVCTP protocol */ -#define AVCT_TRACE_ERROR(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define AVCT_TRACE_WARNING(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define AVCT_TRACE_EVENT(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define AVCT_TRACE_DEBUG(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define AVCT_TRACE_API(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define AVCT_TRACE_ERROR(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVCT, ERROR)) BT_PRINT_E("BT_AVCT", fmt, ## args);} +#define AVCT_TRACE_WARNING(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVCT, WARNING)) BT_PRINT_W("BT_AVCT", fmt, ## args);} +#define AVCT_TRACE_API(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVCT,API)) BT_PRINT_I("BT_AVCT", fmt, ## args);} +#define AVCT_TRACE_EVENT(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVCT,EVENT)) BT_PRINT_D("BT_AVCT", fmt, ## args);} +#define AVCT_TRACE_DEBUG(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVCT,DEBUG)) BT_PRINT_D("BT_AVCT", fmt, ## args);} /* Define tracing for the AVRCP profile */ -#define AVRC_TRACE_ERROR(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define AVRC_TRACE_WARNING(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define AVRC_TRACE_EVENT(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define AVRC_TRACE_DEBUG(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define AVRC_TRACE_API(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define AVRC_TRACE_ERROR(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVRC, ERROR)) BT_PRINT_E("BT_AVRC", fmt, ## args);} +#define AVRC_TRACE_WARNING(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVRC, WARNING)) BT_PRINT_W("BT_AVRC", fmt, ## args);} +#define AVRC_TRACE_API(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVRC,API)) BT_PRINT_I("BT_AVRC", fmt, ## args);} +#define AVRC_TRACE_EVENT(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVRC,EVENT)) BT_PRINT_D("BT_AVRC", fmt, ## args);} +#define AVRC_TRACE_DEBUG(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVRC,DEBUG)) BT_PRINT_D("BT_AVRC", fmt, ## args);} /* MCAP */ -#define MCA_TRACE_ERROR(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} +#define MCA_TRACE_ERROR(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(MCA, ERROR)) BT_PRINT_E("BT_MCA", fmt, ## args);} +#define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(MCA, WARNING)) BT_PRINT_W("BT_MCA", fmt, ## args);} +#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(MCA,API)) BT_PRINT_I("BT_MCA", fmt, ## args);} +#define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(MCA,EVENT)) BT_PRINT_D("BT_MCA", fmt, ## args);} +#define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(MCA,DEBUG)) BT_PRINT_D("BT_MCA", fmt, ## args);} /* Define tracing for the ATT/GATT unit */ -#define GATT_TRACE_ERROR(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define GATT_TRACE_WARNING(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define GATT_TRACE_API(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define GATT_TRACE_EVENT(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define GATT_TRACE_DEBUG(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define GATT_TRACE_ERROR(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GATT, ERROR)) BT_PRINT_E("BT_GATT", fmt, ## args);} +#define GATT_TRACE_WARNING(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GATT, WARNING)) BT_PRINT_W("BT_GATT", fmt, ## args);} +#define GATT_TRACE_API(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GATT,API)) BT_PRINT_I("BT_GATT", fmt, ## args);} +#define GATT_TRACE_EVENT(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GATT,EVENT)) BT_PRINT_D("BT_GATT", fmt, ## args);} +#define GATT_TRACE_DEBUG(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(GATT,DEBUG)) BT_PRINT_D("BT_GATT", fmt, ## args);} /* Define tracing for the SMP unit */ -#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} +#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SMP, ERROR)) BT_PRINT_E("BT_SMP", fmt, ## args);} +#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SMP, WARNING)) BT_PRINT_W("BT_SMP", fmt, ## args);} +#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SMP,API)) BT_PRINT_I("BT_SMP", fmt, ## args);} +#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SMP,EVENT)) BT_PRINT_D("BT_SMP", fmt, ## args);} +#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SMP,DEBUG)) BT_PRINT_D("BT_SMP", fmt, ## args);} + extern UINT8 btif_trace_level; // define traces for application -#define BTIF_TRACE_ERROR(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define BTIF_TRACE_WARNING(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define BTIF_TRACE_API(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define BTIF_TRACE_EVENT(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define BTIF_TRACE_DEBUG(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define BTIF_TRACE_VERBOSE(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE)BT_PRINTF(fmt, ## args);} +#define BTIF_TRACE_ERROR(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTIF, ERROR)) BT_PRINT_E("BT_BTIF", fmt, ## args);} +#define BTIF_TRACE_WARNING(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTIF, WARNING)) BT_PRINT_W("BT_BTIF", fmt, ## args);} +#define BTIF_TRACE_API(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTIF,API)) BT_PRINT_I("BT_BTIF", fmt, ## args);} +#define BTIF_TRACE_EVENT(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTIF,EVENT)) BT_PRINT_D("BT_BTIF", fmt, ## args);} +#define BTIF_TRACE_DEBUG(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTIF,DEBUG)) BT_PRINT_D("BT_BTIF", fmt, ## args);} +#define BTIF_TRACE_VERBOSE(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(BTIF,VERBOSE)) BT_PRINT_V("BT_BTIF", fmt, ## args);} /* define traces for application */ -#define APPL_TRACE_ERROR(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);} -#define APPL_TRACE_WARNING(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);} -#define APPL_TRACE_API(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);} -#define APPL_TRACE_EVENT(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);} -#define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);} -#define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) BT_PRINTF(fmt, ## args);} +#define APPL_TRACE_ERROR(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(APPL, ERROR)) BT_PRINT_E("BT_APPL", fmt, ## args);} +#define APPL_TRACE_WARNING(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(APPL, WARNING)) BT_PRINT_W("BT_APPL", fmt, ## args);} +#define APPL_TRACE_API(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(APPL,API)) BT_PRINT_I("BT_APPL", fmt, ## args);} +#define APPL_TRACE_EVENT(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(APPL,EVENT)) BT_PRINT_D("BT_APPL", fmt, ## args);} +#define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(APPL,DEBUG)) BT_PRINT_D("BT_APPL", fmt, ## args);} +#define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(APPL,VERBOSE)) BT_PRINT_V("BT_APPL", fmt, ## args);} + +/* Define tracing for the HCI unit + * Modified from `btu_cb.trace_level` to `HCI_INITIAL_TRACE_LEVEL`, + * to use HCI_TRACE_XXXX in hci_layer.c without including `btu.h` +*/ +#define HCI_TRACE_ERROR(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HCI, ERROR)) BT_PRINT_E("BT_HCI", fmt,## args);} +#define HCI_TRACE_WARNING(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HCI, WARNING)) BT_PRINT_W("BT_HCI", fmt,## args);} +#define HCI_TRACE_EVENT(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HCI,EVENT)) BT_PRINT_D("BT_HCI", fmt,## args);} +#define HCI_TRACE_DEBUG(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HCI,DEBUG)) BT_PRINT_D("BT_HCI", fmt,## args);} + +/* define traces for BTC */ +#define BTC_TRACE_ERROR(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTC, ERROR)) BT_PRINT_E("BT_BTC", fmt, ## args);} +#define BTC_TRACE_WARNING(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTC, WARNING)) BT_PRINT_W("BT_BTC", fmt, ## args);} +#define BTC_TRACE_API(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTC,API)) BT_PRINT_I("BT_BTC", fmt, ## args);} +#define BTC_TRACE_EVENT(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTC,EVENT)) BT_PRINT_D("BT_BTC", fmt, ## args);} +#define BTC_TRACE_DEBUG(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTC,DEBUG)) BT_PRINT_D("BT_BTC", fmt, ## args);} +#define BTC_TRACE_VERBOSE(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(BTC,VERBOSE)) BT_PRINT_V("BT_BTC", fmt, ## args);} + +/* define traces for OSI */ +#define OSI_TRACE_ERROR(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(OSI, ERROR)) BT_PRINT_E("BT_OSI", fmt, ## args);} +#define OSI_TRACE_WARNING(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(OSI, WARNING)) BT_PRINT_W("BT_OSI", fmt, ## args);} +#define OSI_TRACE_API(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(OSI,API)) BT_PRINT_I("BT_OSI", fmt, ## args);} +#define OSI_TRACE_EVENT(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(OSI,EVENT)) BT_PRINT_D("BT_OSI", fmt, ## args);} +#define OSI_TRACE_DEBUG(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(OSI,DEBUG)) BT_PRINT_D("BT_OSI", fmt, ## args);} +#define OSI_TRACE_VERBOSE(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(OSI,VERBOSE)) BT_PRINT_V("BT_OSI", fmt, ## args);} + +/* define traces for BLUFI */ +#define BLUFI_TRACE_ERROR(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BLUFI, ERROR)) BT_PRINT_E("BT_BLUFI", fmt, ## args);} +#define BLUFI_TRACE_WARNING(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BLUFI, WARNING)) BT_PRINT_W("BT_BLUFI", fmt, ## args);} +#define BLUFI_TRACE_API(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BLUFI,API)) BT_PRINT_I("BT_BLUFI", fmt, ## args);} +#define BLUFI_TRACE_EVENT(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BLUFI,EVENT)) BT_PRINT_D("BT_BLUFI", fmt, ## args);} +#define BLUFI_TRACE_DEBUG(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BLUFI,DEBUG)) BT_PRINT_D("BT_BLUFI", fmt, ## args);} +#define BLUFI_TRACE_VERBOSE(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(BLUFI,VERBOSE)) BT_PRINT_V("BT_BLUFI", fmt, ## args);} #else #define LOG_ERROR(fmt, args...) @@ -571,6 +670,30 @@ extern UINT8 btif_trace_level; #define APPL_TRACE_EVENT(fmt, args...) #define APPL_TRACE_DEBUG(fmt, args...) #define APPL_TRACE_VERBOSE(fmt, args...) + +/* define traces for BTC */ +#define BTC_TRACE_ERROR(fmt, args...) +#define BTC_TRACE_WARNING(fmt, args...) +#define BTC_TRACE_API(fmt, args...) +#define BTC_TRACE_EVENT(fmt, args...) +#define BTC_TRACE_DEBUG(fmt, args...) +#define BTC_TRACE_VERBOSE(fmt, args...) + +/* define traces for OSI */ +#define OSI_TRACE_ERROR(fmt, args...) +#define OSI_TRACE_WARNING(fmt, args...) +#define OSI_TRACE_API(fmt, args...) +#define OSI_TRACE_EVENT(fmt, args...) +#define OSI_TRACE_DEBUG(fmt, args...) +#define OSI_TRACE_VERBOSE(fmt, args...) + +/* define traces for BLUFI */ +#define BLUFI_TRACE_ERROR(fmt, args...) +#define BLUFI_TRACE_WARNING(fmt, args...) +#define BLUFI_TRACE_API(fmt, args...) +#define BLUFI_TRACE_EVENT(fmt, args...) +#define BLUFI_TRACE_DEBUG(fmt, args...) +#define BLUFI_TRACE_VERBOSE(fmt, args...) #endif ///CONFIG_BT_STACK_NO_LOG @@ -579,25 +702,25 @@ extern UINT8 btif_trace_level; #define bdld(fmt, args...) \ do{\ if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \ - BT_PRINTF(fmt, ## args); \ + BT_PRINT_D(fmt, ## args); \ }while(0) #define bdlw(fmt, args...) \ do{\ - if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \ - BT_PRINTF(fmt, ## args); \ + if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_WARNING) \ + BT_PRINT_W(fmt, ## args); \ }while(0) #define bdle(fmt, args...) \ do{\ - if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \ - BT_PRINTF(fmt, ## args); \ + if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) \ + BT_PRINT_E(fmt, ## args); \ }while(0) #define bdla(assert_if) \ do{\ if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \ - BT_PRINTF("%s: assert failed\n", #assert_if); \ + BT_PRINT_E("%s: assert failed\n", #assert_if); \ }while(0) typedef UINT8 tBTTRC_PARAM_TYPE; diff --git a/components/bt/bluedroid/hci/hci_hal_h4.c b/components/bt/bluedroid/hci/hci_hal_h4.c index ec700dd15d..8b87a6faa0 100644 --- a/components/bt/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/bluedroid/hci/hci_hal_h4.c @@ -83,7 +83,7 @@ static void hci_hal_env_init( if (hci_hal_env.rx_q) { fixed_queue_register_dequeue(hci_hal_env.rx_q, event_uart_has_bytes); } else { - LOG_ERROR("%s unable to create rx queue.\n", __func__); + HCI_TRACE_ERROR("%s unable to create rx queue.\n", __func__); } return; @@ -135,7 +135,7 @@ static uint16_t transmit_data(serial_data_type_t type, assert(length > 0); if (type < DATA_TYPE_COMMAND || type > DATA_TYPE_SCO) { - LOG_ERROR("%s invalid data type: %d", __func__, type); + HCI_TRACE_ERROR("%s invalid data type: %d", __func__, type); return 0; } @@ -178,7 +178,7 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout) evt.par = 0; if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) { - LOG_ERROR("xHciH4Queue failed\n"); + HCI_TRACE_ERROR("xHciH4Queue failed\n"); return TASK_POST_SUCCESS; } @@ -200,13 +200,13 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) if (type == HCI_BLE_EVENT) { uint8_t len = 0; STREAM_TO_UINT8(len, stream); - LOG_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n", + HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n", packet->len, len); hci_hal_env.allocator->free(packet); return; } if (type < DATA_TYPE_ACL || type > DATA_TYPE_EVENT) { - LOG_ERROR("%s Unknown HCI message type. Dropping this byte 0x%x," + HCI_TRACE_ERROR("%s Unknown HCI message type. Dropping this byte 0x%x," " min %x, max %x\n", __func__, type, DATA_TYPE_ACL, DATA_TYPE_EVENT); hci_hal_env.allocator->free(packet); @@ -214,7 +214,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) } hdr_size = preamble_sizes[type - 1]; if (packet->len < hdr_size) { - LOG_ERROR("Wrong packet length type=%d pkt_len=%d hdr_len=%d", + HCI_TRACE_ERROR("Wrong packet length type=%d pkt_len=%d hdr_len=%d", type, packet->len, hdr_size); hci_hal_env.allocator->free(packet); return; @@ -228,7 +228,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) } if ((length + hdr_size) != packet->len) { - LOG_ERROR("Wrong packet length type=%d hdr_len=%d pd_len=%d " + HCI_TRACE_ERROR("Wrong packet length type=%d hdr_len=%d pd_len=%d " "pkt_len=%d", type, hdr_size, length, packet->len); hci_hal_env.allocator->free(packet); return; @@ -263,7 +263,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len) pkt_size = BT_HDR_SIZE + len; pkt = (BT_HDR *)hci_hal_env.allocator->alloc(pkt_size); if (!pkt) { - LOG_ERROR("%s couldn't aquire memory for inbound data buffer.\n", __func__); + HCI_TRACE_ERROR("%s couldn't aquire memory for inbound data buffer.\n", __func__); return -1; } pkt->offset = 0; diff --git a/components/bt/bluedroid/hci/hci_layer.c b/components/bt/bluedroid/hci/hci_layer.c index eaeb59fea4..59b08c4810 100644 --- a/components/bt/bluedroid/hci/hci_layer.c +++ b/components/bt/bluedroid/hci/hci_layer.c @@ -143,7 +143,7 @@ task_post_status_t hci_host_task_post(task_post_t timeout) evt.par = 0; if (xQueueSend(xHciHostQueue, &evt, timeout) != pdTRUE) { - LOG_ERROR("xHciHostQueue failed\n"); + HCI_TRACE_ERROR("xHciHostQueue failed\n"); return TASK_POST_FAIL; } @@ -162,7 +162,7 @@ static int hci_layer_init_env(void) if (hci_host_env.command_queue) { fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready); } else { - LOG_ERROR("%s unable to create pending command queue.", __func__); + HCI_TRACE_ERROR("%s unable to create pending command queue.", __func__); return -1; } @@ -170,7 +170,7 @@ static int hci_layer_init_env(void) if (hci_host_env.packet_queue) { fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready); } else { - LOG_ERROR("%s unable to create pending packet queue.", __func__); + HCI_TRACE_ERROR("%s unable to create pending packet queue.", __func__); return -1; } @@ -179,13 +179,13 @@ static int hci_layer_init_env(void) cmd_wait_q->timer_is_set = false; cmd_wait_q->commands_pending_response = list_new(NULL); if (!cmd_wait_q->commands_pending_response) { - LOG_ERROR("%s unable to create list for commands pending response.", __func__); + HCI_TRACE_ERROR("%s unable to create list for commands pending response.", __func__); return -1; } osi_mutex_new(&cmd_wait_q->commands_pending_response_lock); cmd_wait_q->command_response_timer = osi_alarm_new("cmd_rsp_to", command_timed_out, cmd_wait_q, COMMAND_PENDING_TIMEOUT); if (!cmd_wait_q->command_response_timer) { - LOG_ERROR("%s unable to create command response timer.", __func__); + HCI_TRACE_ERROR("%s unable to create command response timer.", __func__); return -1; } @@ -255,7 +255,7 @@ static void transmit_command( uint8_t *stream; waiting_command_t *wait_entry = osi_calloc(sizeof(waiting_command_t)); if (!wait_entry) { - LOG_ERROR("%s couldn't allocate space for wait entry.", __func__); + HCI_TRACE_ERROR("%s couldn't allocate space for wait entry.", __func__); return; } @@ -269,7 +269,7 @@ static void transmit_command( // Store the command message type in the event field // in case the upper layer didn't already command->event = MSG_STACK_TO_HC_HCI_CMD; - LOG_DEBUG("HCI Enqueue Comamnd opcode=0x%x\n", wait_entry->opcode); + HCI_TRACE_DEBUG("HCI Enqueue Comamnd opcode=0x%x\n", wait_entry->opcode); BTTRC_DUMP_BUFFER(NULL, command->data + command->offset, command->len); fixed_queue_enqueue(hci_host_env.command_queue, wait_entry); @@ -301,7 +301,7 @@ static void transmit_downward(uint16_t type, void *data) { if (type == MSG_STACK_TO_HC_HCI_CMD) { transmit_command((BT_HDR *)data, NULL, NULL, NULL); - LOG_WARN("%s legacy transmit of command. Use transmit_command instead.\n", __func__); + HCI_TRACE_WARNING("%s legacy transmit of command. Use transmit_command instead.\n", __func__); } else { fixed_queue_enqueue(hci_host_env.packet_queue, data); } @@ -398,12 +398,12 @@ static void command_timed_out(void *context) osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock); if (wait_entry == NULL) { - LOG_ERROR("%s with no commands pending response", __func__); + HCI_TRACE_ERROR("%s with no commands pending response", __func__); } else // We shouldn't try to recover the stack from this command timeout. // If it's caused by a software bug, fix it. If it's a hardware bug, fix it. { - LOG_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, wait_entry->opcode); + HCI_TRACE_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, wait_entry->opcode); } } @@ -430,7 +430,7 @@ static bool filter_incoming_event(BT_HDR *packet) STREAM_TO_UINT8(event_code, stream); STREAM_SKIP_UINT8(stream); // Skip the parameter total length field - LOG_DEBUG("Receive packet event_code=0x%x\n", event_code); + HCI_TRACE_DEBUG("Receive packet event_code=0x%x\n", event_code); if (event_code == HCI_COMMAND_COMPLETE_EVT) { STREAM_TO_UINT8(hci_host_env.command_credits, stream); @@ -438,7 +438,7 @@ static bool filter_incoming_event(BT_HDR *packet) wait_entry = get_waiting_command(opcode); if (!wait_entry) { - LOG_WARN("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode); + HCI_TRACE_WARNING("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode); } else if (wait_entry->complete_callback) { wait_entry->complete_callback(packet, wait_entry->context); } else if (wait_entry->complete_future) { @@ -456,7 +456,7 @@ static bool filter_incoming_event(BT_HDR *packet) wait_entry = get_waiting_command(opcode); if (!wait_entry) { - LOG_WARN("%s command status event with no matching command. opcode: 0x%x", __func__, opcode); + HCI_TRACE_WARNING("%s command status event with no matching command. opcode: 0x%x", __func__, opcode); } else if (wait_entry->status_callback) { wait_entry->status_callback(status, wait_entry->command, wait_entry->context); } @@ -516,7 +516,7 @@ static serial_data_type_t event_to_data_type(uint16_t event) } else if (event == MSG_STACK_TO_HC_HCI_CMD) { return DATA_TYPE_COMMAND; } else { - LOG_ERROR("%s invalid event type, could not translate 0x%x\n", __func__, event); + HCI_TRACE_ERROR("%s invalid event type, could not translate 0x%x\n", __func__, event); } return 0; diff --git a/components/bt/bluedroid/hci/hci_packet_parser.c b/components/bt/bluedroid/hci/hci_packet_parser.c index 6866872425..627d1ccb82 100644 --- a/components/bt/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/bluedroid/hci/hci_packet_parser.c @@ -112,7 +112,7 @@ static void parse_read_local_extended_features_response( assert(*page_number_ptr < feature_pages_count); STREAM_TO_ARRAY(feature_pages[*page_number_ptr].as_array, stream, (int)sizeof(bt_device_features_t)); } else { - LOG_ERROR("%s() - WARNING: READING EXTENDED FEATURES FAILED. " + HCI_TRACE_ERROR("%s() - WARNING: READING EXTENDED FEATURES FAILED. " "THIS MAY INDICATE A FIRMWARE/CONTROLLER ISSUE.", __func__); } diff --git a/components/bt/bluedroid/hci/packet_fragmenter.c b/components/bt/bluedroid/hci/packet_fragmenter.c index 8bc593dd20..13c4e48549 100644 --- a/components/bt/bluedroid/hci/packet_fragmenter.c +++ b/components/bt/bluedroid/hci/packet_fragmenter.c @@ -130,7 +130,7 @@ static void fragment_and_dispatch(BT_HDR *packet) static void reassemble_and_dispatch(BT_HDR *packet) { - LOG_DEBUG("reassemble_and_dispatch\n"); + HCI_TRACE_DEBUG("reassemble_and_dispatch\n"); if ((packet->event & MSG_EVT_MASK) == MSG_HC_TO_STACK_HCI_ACL) { uint8_t *stream = packet->data + packet->offset; @@ -151,7 +151,7 @@ static void reassemble_and_dispatch(BT_HDR *packet) if (boundary_flag == START_PACKET_BOUNDARY) { if (partial_packet) { - LOG_WARN("%s found unfinished packet for handle with start packet. Dropping old.\n", __func__); + HCI_TRACE_WARNING("%s found unfinished packet for handle with start packet. Dropping old.\n", __func__); hash_map_erase(partial_packets, (void *)(uintptr_t)handle); buffer_allocator->free(partial_packet); } @@ -159,7 +159,7 @@ static void reassemble_and_dispatch(BT_HDR *packet) uint16_t full_length = l2cap_length + L2CAP_HEADER_SIZE + HCI_ACL_PREAMBLE_SIZE; if (full_length <= packet->len) { if (full_length < packet->len) { - LOG_WARN("%s found l2cap full length %d less than the hci length %d.\n", __func__, l2cap_length, packet->len); + HCI_TRACE_WARNING("%s found l2cap full length %d less than the hci length %d.\n", __func__, l2cap_length, packet->len); } callbacks->reassembled(packet); @@ -183,7 +183,7 @@ static void reassemble_and_dispatch(BT_HDR *packet) buffer_allocator->free(packet); } else { if (!partial_packet) { - LOG_ERROR("%s got continuation for unknown packet. Dropping it.\n", __func__); + HCI_TRACE_ERROR("%s got continuation for unknown packet. Dropping it.\n", __func__); buffer_allocator->free(packet); return; } @@ -192,7 +192,7 @@ static void reassemble_and_dispatch(BT_HDR *packet) packet->len -= HCI_ACL_PREAMBLE_SIZE; uint16_t projected_offset = partial_packet->offset + packet->len; if (projected_offset > partial_packet->len) { // len stores the expected length - LOG_ERROR("%s got packet which would exceed expected length of %d. Truncating.\n", __func__, partial_packet->len); + HCI_TRACE_ERROR("%s got packet which would exceed expected length of %d. Truncating.\n", __func__, partial_packet->len); packet->len = partial_packet->len - partial_packet->offset; projected_offset = partial_packet->len; } diff --git a/components/bt/bluedroid/main/bte_main.c b/components/bt/bluedroid/main/bte_main.c index 2db4fa03da..61c30e2824 100644 --- a/components/bt/bluedroid/main/bte_main.c +++ b/components/bt/bluedroid/main/bte_main.c @@ -77,7 +77,7 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb) { hci = hci_layer_get_interface(); if (!hci) { - LOG_ERROR("%s could not get hci layer interface.\n", __func__); + APPL_TRACE_ERROR("%s could not get hci layer interface.\n", __func__); return -2; } @@ -122,9 +122,9 @@ void bte_main_shutdown(void) ******************************************************************************/ static void bte_main_enable(void) { - LOG_DEBUG("Enable HCI\n"); + APPL_TRACE_DEBUG("Enable HCI\n"); if (hci_start_up()) { - LOG_ERROR("Start HCI Host Layer Failure\n"); + APPL_TRACE_ERROR("Start HCI Host Layer Failure\n"); return; } diff --git a/components/bt/bluedroid/osi/alarm.c b/components/bt/bluedroid/osi/alarm.c index f86332191e..5307010590 100644 --- a/components/bt/bluedroid/osi/alarm.c +++ b/components/bt/bluedroid/osi/alarm.c @@ -52,7 +52,7 @@ static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool i int osi_alarm_create_mux(void) { if (alarm_state != ALARM_STATE_IDLE) { - LOG_WARN("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_WARNING("%s, invalid state %d\n", __func__, alarm_state); return -1; } osi_mutex_new(&alarm_mutex); @@ -62,7 +62,7 @@ int osi_alarm_create_mux(void) int osi_alarm_delete_mux(void) { if (alarm_state != ALARM_STATE_IDLE) { - LOG_WARN("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_WARNING("%s, invalid state %d\n", __func__, alarm_state); return -1; } osi_mutex_free(&alarm_mutex); @@ -75,7 +75,7 @@ void osi_alarm_init(void) osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_IDLE) { - LOG_WARN("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_WARNING("%s, invalid state %d\n", __func__, alarm_state); goto end; } memset(alarm_cbs, 0x00, sizeof(alarm_cbs)); @@ -91,7 +91,7 @@ void osi_alarm_deinit(void) osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_OPEN) { - LOG_WARN("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_WARNING("%s, invalid state %d\n", __func__, alarm_state); goto end; } @@ -112,7 +112,7 @@ static struct alarm_t *alarm_cbs_lookfor_available(void) for (i = 0; i < ALARM_CBS_NUM; i++) { if (alarm_cbs[i].alarm_hdl == NULL) { //available - LOG_DEBUG("%s %d %p\n", __func__, i, &alarm_cbs[i]); + OSI_TRACE_DEBUG("%s %d %p\n", __func__, i, &alarm_cbs[i]); return &alarm_cbs[i]; } } @@ -122,9 +122,9 @@ static struct alarm_t *alarm_cbs_lookfor_available(void) static void alarm_cb_handler(struct alarm_t *alarm) { - LOG_DEBUG("TimerID %p\n", alarm); + OSI_TRACE_DEBUG("TimerID %p\n", alarm); if (alarm_state != ALARM_STATE_OPEN) { - LOG_WARN("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_WARNING("%s, invalid state %d\n", __func__, alarm_state); return; } btc_msg_t msg; @@ -144,7 +144,7 @@ osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_OPEN) { - LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_ERROR("%s, invalid state %d\n", __func__, alarm_state); timer_id = NULL; goto end; } @@ -152,7 +152,7 @@ osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback timer_id = alarm_cbs_lookfor_available(); if (!timer_id) { - LOG_ERROR("%s alarm_cbs exhausted\n", __func__); + OSI_TRACE_ERROR("%s alarm_cbs exhausted\n", __func__); timer_id = NULL; goto end; } @@ -169,7 +169,7 @@ osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback esp_err_t stat = esp_timer_create(&tca, &timer_id->alarm_hdl); if (stat != ESP_OK) { - LOG_ERROR("%s failed to create timer, err 0x%x\n", __func__, stat); + OSI_TRACE_ERROR("%s failed to create timer, err 0x%x\n", __func__, stat); timer_id = NULL; goto end; } @@ -182,13 +182,13 @@ end: static osi_alarm_err_t alarm_free(osi_alarm_t *alarm) { if (!alarm || alarm->alarm_hdl == NULL) { - LOG_ERROR("%s null\n", __func__); + OSI_TRACE_ERROR("%s null\n", __func__); return OSI_ALARM_ERR_INVALID_ARG; } esp_timer_stop(alarm->alarm_hdl); esp_err_t stat = esp_timer_delete(alarm->alarm_hdl); if (stat != ESP_OK) { - LOG_ERROR("%s failed to delete timer, err 0x%x\n", __func__, stat); + OSI_TRACE_ERROR("%s failed to delete timer, err 0x%x\n", __func__, stat); return OSI_ALARM_ERR_FAIL; } @@ -202,7 +202,7 @@ void osi_alarm_free(osi_alarm_t *alarm) osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_OPEN) { - LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_ERROR("%s, invalid state %d\n", __func__, alarm_state); goto end; } alarm_free(alarm); @@ -219,13 +219,13 @@ static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool i osi_alarm_err_t ret = OSI_ALARM_ERR_PASS; osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_OPEN) { - LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_ERROR("%s, invalid state %d\n", __func__, alarm_state); ret = OSI_ALARM_ERR_INVALID_STATE; goto end; } if (!alarm || alarm->alarm_hdl == NULL) { - LOG_ERROR("%s null\n", __func__); + OSI_TRACE_ERROR("%s null\n", __func__); ret = OSI_ALARM_ERR_INVALID_ARG; goto end; } @@ -238,7 +238,7 @@ static osi_alarm_err_t alarm_set(osi_alarm_t *alarm, period_ms_t timeout, bool i stat = esp_timer_start_once(alarm->alarm_hdl, (uint64_t)timeout_us); } if (stat != ESP_OK) { - LOG_ERROR("%s failed to start timer, err 0x%x\n", __func__, stat); + OSI_TRACE_ERROR("%s failed to start timer, err 0x%x\n", __func__, stat); ret = OSI_ALARM_ERR_FAIL; goto end; } @@ -264,20 +264,20 @@ osi_alarm_err_t osi_alarm_cancel(osi_alarm_t *alarm) int ret = OSI_ALARM_ERR_PASS; osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT); if (alarm_state != ALARM_STATE_OPEN) { - LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state); + OSI_TRACE_ERROR("%s, invalid state %d\n", __func__, alarm_state); ret = OSI_ALARM_ERR_INVALID_STATE; goto end; } if (!alarm || alarm->alarm_hdl == NULL) { - LOG_ERROR("%s null\n", __func__); + OSI_TRACE_ERROR("%s null\n", __func__); ret = OSI_ALARM_ERR_INVALID_ARG; goto end; } esp_err_t stat = esp_timer_stop(alarm->alarm_hdl); if (stat != ESP_OK) { - LOG_DEBUG("%s failed to stop timer, err 0x%x\n", __func__, stat); + OSI_TRACE_DEBUG("%s failed to stop timer, err 0x%x\n", __func__, stat); ret = OSI_ALARM_ERR_FAIL; goto end; } diff --git a/components/bt/bluedroid/osi/allocator.c b/components/bt/bluedroid/osi/allocator.c index 113f32becd..2bac1118a1 100644 --- a/components/bt/bluedroid/osi/allocator.c +++ b/components/bt/bluedroid/osi/allocator.c @@ -57,7 +57,7 @@ void osi_mem_dbg_record(void *p, int size, const char *func, int line) int i; if (!p || size == 0) { - LOG_ERROR("%s invalid !!\n", __func__); + OSI_TRACE_ERROR("%s invalid !!\n", __func__); return; } @@ -73,7 +73,7 @@ void osi_mem_dbg_record(void *p, int size, const char *func, int line) } if (i >= OSI_MEM_DBG_INFO_MAX) { - LOG_ERROR("%s full %s %d !!\n", __func__, func, line); + OSI_TRACE_ERROR("%s full %s %d !!\n", __func__, func, line); } } @@ -82,7 +82,7 @@ void osi_mem_dbg_clean(void *p, const char *func, int line) int i; if (!p) { - LOG_ERROR("%s invalid\n", __func__); + OSI_TRACE_ERROR("%s invalid\n", __func__); return; } @@ -98,7 +98,7 @@ void osi_mem_dbg_clean(void *p, const char *func, int line) } if (i >= OSI_MEM_DBG_INFO_MAX) { - LOG_ERROR("%s full %s %d !!\n", __func__, func, line); + OSI_TRACE_ERROR("%s full %s %d !!\n", __func__, func, line); } } @@ -108,10 +108,10 @@ void osi_mem_dbg_show(void) for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) { if (mem_dbg_info[i].p || mem_dbg_info[i].size != 0 ) { - LOG_ERROR("--> p %p, s %d, f %s, l %d\n", mem_dbg_info[i].p, mem_dbg_info[i].size, mem_dbg_info[i].func, mem_dbg_info[i].line); + OSI_TRACE_ERROR("--> p %p, s %d, f %s, l %d\n", mem_dbg_info[i].p, mem_dbg_info[i].size, mem_dbg_info[i].func, mem_dbg_info[i].line); } } - LOG_ERROR("--> count %d\n", mem_dbg_count); + OSI_TRACE_ERROR("--> count %d\n", mem_dbg_count); } #endif diff --git a/components/bt/bluedroid/osi/buffer.c b/components/bt/bluedroid/osi/buffer.c index 42732cf977..6b21ed8e28 100644 --- a/components/bt/bluedroid/osi/buffer.c +++ b/components/bt/bluedroid/osi/buffer.c @@ -35,7 +35,7 @@ buffer_t *buffer_new(size_t size) buffer_t *buffer = osi_malloc(sizeof(buffer_t) + size); if (!buffer) { - LOG_ERROR("%s unable to allocate buffer of %zu bytes.", __func__, size); + OSI_TRACE_ERROR("%s unable to allocate buffer of %zu bytes.", __func__, size); return NULL; } @@ -60,7 +60,7 @@ buffer_t *buffer_new_slice(const buffer_t *buf, size_t slice_size) buffer_t *ret = osi_calloc(sizeof(buffer_t)); if (!ret) { - LOG_ERROR("%s unable to allocate new buffer for slice of length %zu.", __func__, slice_size); + OSI_TRACE_ERROR("%s unable to allocate new buffer for slice of length %zu.", __func__, slice_size); return NULL; } diff --git a/components/bt/bluedroid/osi/config.c b/components/bt/bluedroid/osi/config.c index 07f47c6d9d..55e782ca6a 100644 --- a/components/bt/bluedroid/osi/config.c +++ b/components/bt/bluedroid/osi/config.c @@ -62,13 +62,13 @@ config_t *config_new_empty(void) { config_t *config = osi_calloc(sizeof(config_t)); if (!config) { - LOG_ERROR("%s unable to allocate memory for config_t.\n", __func__); + OSI_TRACE_ERROR("%s unable to allocate memory for config_t.\n", __func__); goto error; } config->sections = list_new(section_free); if (!config->sections) { - LOG_ERROR("%s unable to allocate list for sections.\n", __func__); + OSI_TRACE_ERROR("%s unable to allocate list for sections.\n", __func__); goto error; } @@ -93,10 +93,10 @@ config_t *config_new(const char *filename) err = nvs_open(filename, NVS_READWRITE, &fp); if (err != ESP_OK) { if (err == ESP_ERR_NVS_NOT_INITIALIZED) { - LOG_ERROR("%s: NVS not initialized. " + OSI_TRACE_ERROR("%s: NVS not initialized. " "Call nvs_flash_init before initializing bluetooth.", __func__); } else { - LOG_ERROR("%s unable to open NVS namespace '%s'\n", __func__, filename); + OSI_TRACE_ERROR("%s unable to open NVS namespace '%s'\n", __func__, filename); } config_free(config); return NULL; @@ -136,15 +136,15 @@ bool config_has_key(const config_t *config, const char *section, const char *key bool config_has_key_in_section(config_t *config, const char *key, char *key_value) { - LOG_DEBUG("key = %s, value = %s", key, key_value); + OSI_TRACE_DEBUG("key = %s, value = %s", key, key_value); for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) { const section_t *section = (const section_t *)list_node(node); for (const list_node_t *node = list_begin(section->entries); node != list_end(section->entries); node = list_next(node)) { entry_t *entry = list_node(node); - LOG_DEBUG("entry->key = %s, entry->value = %s", entry->key, entry->value); + OSI_TRACE_DEBUG("entry->key = %s, entry->value = %s", entry->key, entry->value); if (!strcmp(entry->key, key) && !strcmp(entry->value, key_value)) { - LOG_DEBUG("%s, the irk aready in the flash.", __func__); + OSI_TRACE_DEBUG("%s, the irk aready in the flash.", __func__); return true; } } @@ -338,7 +338,7 @@ static int get_config_size_from_flash(nvs_handle fp) esp_err_t err; char *keyname = osi_calloc(sizeof(CONFIG_KEY) + 1); if (!keyname){ - LOG_ERROR("%s, malloc error\n", __func__); + OSI_TRACE_ERROR("%s, malloc error\n", __func__); return 0; } size_t length = CONFIG_FILE_DEFAULE_LENGTH; @@ -351,7 +351,7 @@ static int get_config_size_from_flash(nvs_handle fp) return 0; } if (err != ESP_OK) { - LOG_ERROR("%s, error %d\n", __func__, err); + OSI_TRACE_ERROR("%s, error %d\n", __func__, err); osi_free(keyname); return 0; } @@ -365,7 +365,7 @@ static int get_config_size_from_flash(nvs_handle fp) break; } if (err != ESP_OK) { - LOG_ERROR("%s, error %d\n", __func__, err); + OSI_TRACE_ERROR("%s, error %d\n", __func__, err); osi_free(keyname); return 0; } @@ -396,7 +396,7 @@ bool config_save(const config_t *config, const char *filename) err = nvs_open(filename, NVS_READWRITE, &fp); if (err != ESP_OK) { if (err == ESP_ERR_NVS_NOT_INITIALIZED) { - LOG_ERROR("%s: NVS not initialized. " + OSI_TRACE_ERROR("%s: NVS not initialized. " "Call nvs_flash_init before initializing bluetooth.", __func__); } err_code |= 0x02; @@ -407,15 +407,15 @@ bool config_save(const config_t *config, const char *filename) for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) { const section_t *section = (const section_t *)list_node(node); w_cnt = snprintf(line, 1024, "[%s]\n", section->name); - LOG_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total); + OSI_TRACE_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total); memcpy(buf + w_cnt_total, line, w_cnt); w_cnt_total += w_cnt; for (const list_node_t *enode = list_begin(section->entries); enode != list_end(section->entries); enode = list_next(enode)) { const entry_t *entry = (const entry_t *)list_node(enode); - LOG_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value); + OSI_TRACE_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value); w_cnt = snprintf(line, 1024, "%s = %s\n", entry->key, entry->value); - LOG_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total); + OSI_TRACE_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total); memcpy(buf + w_cnt_total, line, w_cnt); w_cnt_total += w_cnt; } @@ -444,10 +444,10 @@ bool config_save(const config_t *config, const char *filename) snprintf(keyname, sizeof(CONFIG_KEY)+1, "%s%d", CONFIG_KEY, i); if (i == count) { err = nvs_set_blob(fp, keyname, buf + i*CONFIG_FILE_MAX_SIZE, w_cnt_total - i*CONFIG_FILE_MAX_SIZE); - LOG_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, w_cnt_total - i*CONFIG_FILE_MAX_SIZE); + OSI_TRACE_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, w_cnt_total - i*CONFIG_FILE_MAX_SIZE); }else { err = nvs_set_blob(fp, keyname, buf + i*CONFIG_FILE_MAX_SIZE, CONFIG_FILE_MAX_SIZE); - LOG_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, CONFIG_FILE_MAX_SIZE); + OSI_TRACE_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, CONFIG_FILE_MAX_SIZE); } if (err != ESP_OK) { nvs_close(fp); @@ -481,7 +481,7 @@ error: osi_free(keyname); } if (err_code) { - LOG_ERROR("%s, err_code: 0x%x\n", __func__, err_code); + OSI_TRACE_ERROR("%s, err_code: 0x%x\n", __func__, err_code); } return false; } @@ -558,7 +558,7 @@ static void config_parse(nvs_handle fp, config_t *config) // get one line int line_len = p_line_end - p_line_bgn; if (line_len > 1023) { - LOG_WARN("%s exceed max line length on line %d.\n", __func__, line_num); + OSI_TRACE_WARNING("%s exceed max line length on line %d.\n", __func__, line_num); break; } memcpy(line, p_line_bgn, line_len); @@ -575,7 +575,7 @@ static void config_parse(nvs_handle fp, config_t *config) if (*line_ptr == '[') { size_t len = strlen(line_ptr); if (line_ptr[len - 1] != ']') { - LOG_WARN("%s unterminated section name on line %d.\n", __func__, line_num); + OSI_TRACE_WARNING("%s unterminated section name on line %d.\n", __func__, line_num); continue; } strncpy(section, line_ptr + 1, len - 2); @@ -583,7 +583,7 @@ static void config_parse(nvs_handle fp, config_t *config) } else { char *split = strchr(line_ptr, '='); if (!split) { - LOG_DEBUG("%s no key/value separator found on line %d.\n", __func__, line_num); + OSI_TRACE_DEBUG("%s no key/value separator found on line %d.\n", __func__, line_num); continue; } *split = '\0'; @@ -605,7 +605,7 @@ error: osi_free(keyname); } if (err_code) { - LOG_ERROR("%s returned with err code: %d\n", __func__, err_code); + OSI_TRACE_ERROR("%s returned with err code: %d\n", __func__, err_code); } } diff --git a/components/bt/bluedroid/osi/future.c b/components/bt/bluedroid/osi/future.c index 835ccbcff1..25eb5605e6 100644 --- a/components/bt/bluedroid/osi/future.c +++ b/components/bt/bluedroid/osi/future.c @@ -28,12 +28,12 @@ future_t *future_new(void) { future_t *ret = osi_calloc(sizeof(future_t)); if (!ret) { - LOG_ERROR("%s unable to allocate memory for return value.", __func__); + OSI_TRACE_ERROR("%s unable to allocate memory for return value.", __func__); goto error; } if (osi_sem_new(&ret->semaphore, 1, 0) != 0) { - LOG_ERROR("%s unable to allocate memory for the semaphore.", __func__); + OSI_TRACE_ERROR("%s unable to allocate memory for the semaphore.", __func__); goto error; } @@ -48,7 +48,7 @@ future_t *future_new_immediate(void *value) { future_t *ret = osi_calloc(sizeof(future_t)); if (!ret) { - LOG_ERROR("%s unable to allocate memory for return value.", __func__); + OSI_TRACE_ERROR("%s unable to allocate memory for return value.", __func__); goto error; } diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index bb4ec9fd8d..35ae79dfc3 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -1812,14 +1812,14 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst, } else { cp_len = p_data->p_manu->len; } - LOG_DEBUG("cp_len = %d\n,p_data->p_manu->len=%d\n", cp_len, p_data->p_manu->len); + BTM_TRACE_DEBUG("cp_len = %d\n,p_data->p_manu->len=%d\n", cp_len, p_data->p_manu->len); for (int i = 0; i < p_data->p_manu->len; i++) { - LOG_DEBUG("p_data->p_manu->p_val[%d] = %x\n", i, p_data->p_manu->p_val[i]); + BTM_TRACE_DEBUG("p_data->p_manu->p_val[%d] = %x\n", i, p_data->p_manu->p_val[i]); } *p++ = cp_len + 1; *p++ = BTM_BLE_AD_TYPE_MANU; ARRAY_TO_STREAM(p, p_data->p_manu->p_val, cp_len); - LOG_DEBUG("p_addr = %p\n,p_data->p_manu->p_val = %p\n", p, p_data->p_manu->p_val); + BTM_TRACE_DEBUG("p_addr = %p\n,p_data->p_manu->p_val = %p\n", p, p_data->p_manu->p_val); len -= (cp_len + MIN_ADV_LENGTH); data_mask &= ~BTM_BLE_AD_BIT_MANU; } @@ -2085,7 +2085,7 @@ void btm_ble_set_adv_flag(UINT16 connect_mode, UINT16 disc_mode) btm_ble_update_dmt_flag_bits (&flag, connect_mode, disc_mode); - LOG_DEBUG("disc_mode %04x", disc_mode); + BTM_TRACE_DEBUG("disc_mode %04x", disc_mode); /* update discoverable flag */ if (disc_mode & BTM_BLE_LIMITED_DISCOVERABLE) { flag &= ~BTM_BLE_GEN_DISC_FLAG; @@ -2098,7 +2098,7 @@ void btm_ble_set_adv_flag(UINT16 connect_mode, UINT16 disc_mode) } if (flag != old_flag) { - LOG_ERROR("flag = 0x%x,old_flag = 0x%x", flag, old_flag); + BTM_TRACE_ERROR("flag = 0x%x,old_flag = 0x%x", flag, old_flag); btm_ble_update_adv_flag(flag); } } @@ -3164,7 +3164,7 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt } if ((result = btm_ble_is_discoverable(bda, evt_type, p)) == 0) { - LOG_WARN("%s device is no longer discoverable so discarding advertising packet pkt", + BTM_TRACE_WARNING("%s device is no longer discoverable so discarding advertising packet pkt", __func__); return; } diff --git a/components/bt/bluedroid/stack/btm/btm_pm.c b/components/bt/bluedroid/stack/btm/btm_pm.c index 758be72b8e..7c3629ca4b 100644 --- a/components/bt/bluedroid/stack/btm/btm_pm.c +++ b/components/bt/bluedroid/stack/btm/btm_pm.c @@ -606,7 +606,7 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD * BTM_TRACE_DEBUG("btm_pm_snd_md_req state:0x%x, link_ind: %d", p_cb->state, link_ind); #endif // BTM_PM_DEBUG - LOG_DEBUG("%s switching from %s to %s.", __func__, mode_to_string(p_cb->state), mode_to_string(md_res.mode)); + BTM_TRACE_DEBUG("%s switching from %s to %s.", __func__, mode_to_string(p_cb->state), mode_to_string(md_res.mode)); switch (md_res.mode) { case BTM_PM_MD_ACTIVE: switch (p_cb->state) { @@ -772,7 +772,7 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U p_cb->state = mode; p_cb->interval = interval; - LOG_DEBUG("%s switched from %s to %s.", __func__, mode_to_string(old_state), mode_to_string(p_cb->state)); + BTM_TRACE_DEBUG("%s switched from %s to %s.", __func__, mode_to_string(old_state), mode_to_string(p_cb->state)); if ((p_lcb = l2cu_find_lcb_by_bd_addr(p->remote_addr, BT_TRANSPORT_BR_EDR)) != NULL) { if ((p_cb->state == BTM_PM_ST_ACTIVE) || (p_cb->state == BTM_PM_ST_SNIFF)) { diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index 00923e9f80..0cfa5f70de 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -231,7 +231,7 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) BTM_TRACE_EVENT("%s application registered\n", __func__); #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE - LOG_DEBUG("%s p_cb_info->p_le_callback == 0x%p\n", __func__, p_cb_info->p_le_callback); + BTM_TRACE_DEBUG("%s p_cb_info->p_le_callback == 0x%p\n", __func__, p_cb_info->p_le_callback); if (p_cb_info->p_le_callback) { BTM_TRACE_EVENT("%s SMP_Register( btm_proc_smp_cback )\n", __func__); SMP_Register(btm_proc_smp_cback); @@ -240,13 +240,13 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) btm_ble_reset_id(); } } else { - LOG_WARN("%s p_cb_info->p_le_callback == NULL\n", __func__); + BTM_TRACE_WARNING("%s p_cb_info->p_le_callback == NULL\n", __func__); } #endif btm_cb.api = *p_cb_info; #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE - LOG_DEBUG("%s btm_cb.api.p_le_callback = 0x%p\n", __func__, btm_cb.api.p_le_callback); + BTM_TRACE_DEBUG("%s btm_cb.api.p_le_callback = 0x%p\n", __func__, btm_cb.api.p_le_callback); #endif BTM_TRACE_EVENT("%s application registered\n", __func__); return (TRUE); @@ -2325,7 +2325,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle 2046 may report HCI_Encryption_Change and L2C Connection Request out of sequence because of data path issues. Delay this disconnect a little bit */ - LOG_INFO("%s peer should have initiated security process by now (SM4 to SM4)\n", __func__); + BTM_TRACE_API("%s peer should have initiated security process by now (SM4 to SM4)\n", __func__); p_dev_rec->p_callback = p_callback; p_dev_rec->sec_state = BTM_SEC_STATE_DELAY_FOR_ENC; (*p_callback) (bd_addr, transport, p_ref_data, rc); diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index 788cd41336..f0d50ed42b 100644 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -1000,7 +1000,7 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t)); command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0]; - LOG_DEBUG("btu_hcif_command_complete_evt\n"); + HCI_TRACE_DEBUG("btu_hcif_command_complete_evt\n"); hack->callback = btu_hcif_command_complete_evt_on_task; hack->response = response; diff --git a/components/bt/bluedroid/stack/btu/btu_task.c b/components/bt/bluedroid/stack/btu/btu_task.c index af121c7050..5d6b82a0f7 100644 --- a/components/bt/bluedroid/stack/btu/btu_task.c +++ b/components/bt/bluedroid/stack/btu/btu_task.c @@ -256,7 +256,7 @@ void btu_task_thread_handler(void *arg) } default: // FAIL - LOG_ERROR("Received unexpected oneshot timer event:0x%x\n", p_tle->event); + HCI_TRACE_ERROR("Received unexpected oneshot timer event:0x%x\n", p_tle->event); break; } break; @@ -280,7 +280,7 @@ task_post_status_t btu_task_post(uint32_t sig, void *param, task_post_t timeout) evt.par = param; if (xQueueSend(xBtuQueue, &evt, timeout) != pdTRUE) { - LOG_ERROR("xBtuQueue failed\n"); + HCI_TRACE_ERROR("xBtuQueue failed\n"); return TASK_POST_FAIL; } @@ -462,7 +462,7 @@ void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) alarm = hash_map_get(btu_general_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_ERROR("%s Unable to create alarm", __func__); + HCI_TRACE_ERROR("%s Unable to create alarm", __func__); return; } osi_alarm_cancel(alarm); @@ -496,7 +496,7 @@ void btu_stop_timer(TIMER_LIST_ENT *p_tle) // Get the alarm for the timer list entry. osi_alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + HCI_TRACE_WARNING("%s Unable to find expected alarm in hashmap", __func__); return; } osi_alarm_cancel(alarm); @@ -520,7 +520,7 @@ void btu_free_timer(TIMER_LIST_ENT *p_tle) // Get the alarm for the timer list entry. osi_alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_DEBUG("%s Unable to find expected alarm in hashmap", __func__); + HCI_TRACE_DEBUG("%s Unable to find expected alarm in hashmap", __func__); return; } osi_alarm_cancel(alarm); @@ -576,7 +576,7 @@ void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ti alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_ERROR("%s Unable to create alarm", __func__); + HCI_TRACE_ERROR("%s Unable to create alarm", __func__); return; } osi_alarm_cancel(alarm); @@ -609,7 +609,7 @@ void btu_stop_quick_timer(TIMER_LIST_ENT *p_tle) // Get the alarm for the timer list entry. osi_alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + HCI_TRACE_WARNING("%s Unable to find expected alarm in hashmap", __func__); return; } osi_alarm_cancel(alarm); @@ -624,7 +624,7 @@ void btu_free_quick_timer(TIMER_LIST_ENT *p_tle) // Get the alarm for the timer list entry. osi_alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_DEBUG("%s Unable to find expected alarm in hashmap", __func__); + HCI_TRACE_DEBUG("%s Unable to find expected alarm in hashmap", __func__); return; } osi_alarm_cancel(alarm); @@ -662,7 +662,7 @@ void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_ERROR("%s Unable to create alarm", __func__); + HCI_TRACE_ERROR("%s Unable to create alarm", __func__); return; } osi_alarm_cancel(alarm); @@ -686,7 +686,7 @@ void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle) // Get the alarm for the timer list entry. osi_alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle); if (alarm == NULL) { - LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + HCI_TRACE_WARNING("%s Unable to find expected alarm in hashmap", __func__); return; } osi_alarm_cancel(alarm); diff --git a/components/bt/bluedroid/stack/gatt/gatt_sr.c b/components/bt/bluedroid/stack/gatt/gatt_sr.c index b0036320b5..697540d4c1 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_sr.c +++ b/components/bt/bluedroid/stack/gatt/gatt_sr.c @@ -1260,7 +1260,7 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand is_need_prepare_write_rsp = TRUE; is_need_queue_data = TRUE; } else if (p_attr->p_value == NULL) { - LOG_ERROR("Error in %s, attribute of handle 0x%x not allocate value buffer\n", + GATT_TRACE_ERROR("Error in %s, attribute of handle 0x%x not allocate value buffer\n", __func__, handle); status = GATT_UNKNOWN_ERROR; } else { @@ -1306,11 +1306,11 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand gatt_dequeue_sr_cmd(p_tcb); if (rsp_send_status != GATT_SUCCESS){ - LOG_ERROR("Error in %s, line=%d, fail to send prepare_write_rsp, status=0x%x\n", + GATT_TRACE_ERROR("Error in %s, line=%d, fail to send prepare_write_rsp, status=0x%x\n", __func__, __LINE__, rsp_send_status); } } else{ - LOG_ERROR("Error in %s, line=%d, queue_data should not be NULL here, fail to send prepare_write_rsp\n", + GATT_TRACE_ERROR("Error in %s, line=%d, queue_data should not be NULL here, fail to send prepare_write_rsp\n", __func__, __LINE__); } } diff --git a/components/bt/bluedroid/stack/hcic/hciblecmds.c b/components/bt/bluedroid/stack/hcic/hciblecmds.c index 634cb04521..89d4fd94c8 100644 --- a/components/bt/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/bluedroid/stack/hcic/hciblecmds.c @@ -140,7 +140,7 @@ BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data) UINT8 *pp; for (int i = 0; i < data_len; i++) { - LOG_DEBUG("p_data[%d] = %x\n", i, p_data[i]); + HCI_TRACE_DEBUG("p_data[%d] = %x\n", i, p_data[i]); } if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1)) == NULL) { diff --git a/components/bt/bluedroid/stack/l2cap/l2c_api.c b/components/bt/bluedroid/stack/l2cap/l2c_api.c index 3c7745af98..654a4df632 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_api.c @@ -327,7 +327,7 @@ bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *cal tL2C_CCB *channel_control_block = l2cu_find_ccb_by_cid(NULL, local_cid); if (!channel_control_block) { - LOG_ERROR("%s no channel control block found for L2CAP LCID=0x%04x.", __func__, local_cid); + L2CAP_TRACE_ERROR("%s no channel control block found for L2CAP LCID=0x%04x.", __func__, local_cid); return false; } @@ -339,7 +339,7 @@ bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *cal if (!channel_control_block->should_free_rcb) { registration_control_block = (tL2C_RCB *)osi_calloc(sizeof(tL2C_RCB)); if (!registration_control_block) { - LOG_ERROR("%s unable to allocate registration control block.", __func__); + L2CAP_TRACE_ERROR("%s unable to allocate registration control block.", __func__); return false; } diff --git a/components/bt/bluedroid/stack/l2cap/l2c_main.c b/components/bt/bluedroid/stack/l2cap/l2c_main.c index 9990db077b..c9f4c4d3b2 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_main.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_main.c @@ -870,7 +870,7 @@ void l2c_init (void) l2cb.rcv_pending_q = list_new(NULL); if (l2cb.rcv_pending_q == NULL) { - LOG_ERROR("%s unable to allocate memory for link layer control block", __func__); + L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__); } } diff --git a/components/bt/bluedroid/stack/l2cap/l2cap_client.c b/components/bt/bluedroid/stack/l2cap/l2cap_client.c index 002ed6b809..c7314b62ff 100644 --- a/components/bt/bluedroid/stack/l2cap/l2cap_client.c +++ b/components/bt/bluedroid/stack/l2cap/l2cap_client.c @@ -91,14 +91,14 @@ l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void if (!l2cap_clients) { l2cap_clients = list_new(NULL); if (!l2cap_clients) { - LOG_ERROR("%s unable to allocate space for L2CAP client list.", __func__); + L2CAP_TRACE_ERROR("%s unable to allocate space for L2CAP client list.", __func__); return NULL; } } l2cap_client_t *ret = (l2cap_client_t *)osi_calloc(sizeof(l2cap_client_t)); if (!ret) { - LOG_ERROR("%s unable to allocate L2CAP client.", __func__); + L2CAP_TRACE_ERROR("%s unable to allocate L2CAP client.", __func__); goto error; } @@ -108,7 +108,7 @@ l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void ret->remote_mtu = L2CAP_MTU_DEFAULT; ret->outbound_fragments = list_new(NULL); if (!ret) { - LOG_ERROR("%s unable to allocate outbound L2CAP fragment list.", __func__); + L2CAP_TRACE_ERROR("%s unable to allocate outbound L2CAP fragment list.", __func__); goto error; } @@ -146,7 +146,7 @@ bool l2cap_client_connect(l2cap_client_t *client, const bt_bdaddr_t *remote_bdad client->local_channel_id = L2CA_ConnectReq(psm, (uint8_t *)remote_bdaddr); if (!client->local_channel_id) { - LOG_ERROR("%s unable to create L2CAP connection.", __func__); + L2CAP_TRACE_ERROR("%s unable to create L2CAP connection.", __func__); return false; } @@ -159,7 +159,7 @@ void l2cap_client_disconnect(l2cap_client_t *client) assert(client != NULL); if (client->local_channel_id && !L2CA_DisconnectReq(client->local_channel_id)) { - LOG_ERROR("%s unable to send disconnect message for LCID 0x%04x.", __func__, client->local_channel_id); + L2CAP_TRACE_ERROR("%s unable to send disconnect message for LCID 0x%04x.", __func__, client->local_channel_id); } client->local_channel_id = 0; @@ -203,12 +203,12 @@ static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code) l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client for LCID 0x%04x.", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client for LCID 0x%04x.", __func__, local_channel_id); return; } if (error_code != L2CAP_CONN_OK) { - LOG_ERROR("%s error connecting L2CAP channel: %d.", __func__, error_code); + L2CAP_TRACE_ERROR("%s error connecting L2CAP channel: %d.", __func__, error_code); client->callbacks.disconnected(client, client->context); return; } @@ -216,7 +216,7 @@ static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code) // Use default L2CAP parameters. tL2CAP_CFG_INFO desired_parameters = { 0 }; if (!L2CA_ConfigReq(local_channel_id, &desired_parameters)) { - LOG_ERROR("%s error sending L2CAP config parameters.", __func__); + L2CAP_TRACE_ERROR("%s error sending L2CAP config parameters.", __func__); client->callbacks.disconnected(client, client->context); } } @@ -227,7 +227,7 @@ static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *reques l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); return; } @@ -255,7 +255,7 @@ static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *reques } if (!L2CA_ConfigRsp(local_channel_id, &response)) { - LOG_ERROR("%s unable to send config response for LCID 0x%04x.", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to send config response for LCID 0x%04x.", __func__, local_channel_id); l2cap_client_disconnect(client); return; } @@ -272,7 +272,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); return; } @@ -283,7 +283,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego case L2CAP_CFG_UNACCEPTABLE_PARAMS: // TODO: see if we can renegotiate parameters instead of dropping the connection. - LOG_WARN("%s dropping L2CAP connection due to unacceptable config parameters.\n", __func__); + L2CAP_TRACE_WARNING("%s dropping L2CAP connection due to unacceptable config parameters.\n", __func__); l2cap_client_disconnect(client); break; @@ -297,7 +297,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego // Failure, no further parameter negotiation possible. default: - LOG_WARN("%s L2CAP parameter negotiation failed with error code %d.\n", __func__, negotiated_parameters->result); + L2CAP_TRACE_WARNING("%s L2CAP parameter negotiation failed with error code %d.\n", __func__, negotiated_parameters->result); l2cap_client_disconnect(client); break; } @@ -307,7 +307,7 @@ static void disconnect_request_cb(uint16_t local_channel_id, bool ack_required) { l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -328,7 +328,7 @@ static void disconnect_completed_cb(uint16_t local_channel_id, UNUSED_ATTR uint1 l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -344,7 +344,7 @@ static void congestion_cb(uint16_t local_channel_id, bool is_congested) l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -367,7 +367,7 @@ static void read_ready_cb(uint16_t local_channel_id, BT_HDR *packet) l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); + L2CAP_TRACE_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -435,7 +435,7 @@ static void dispatch_fragments(l2cap_client_t *client) return; case L2CAP_DW_FAILED: - LOG_ERROR("%s error writing data to L2CAP connection LCID 0x%04x; disconnecting.", __func__, client->local_channel_id); + L2CAP_TRACE_ERROR("%s error writing data to L2CAP connection LCID 0x%04x; disconnecting.", __func__, client->local_channel_id); l2cap_client_disconnect(client); return; diff --git a/components/bt/bluedroid/stack/rfcomm/port_api.c b/components/bt/bluedroid/stack/rfcomm/port_api.c index ea3f7b6efc..b5e2c569fa 100644 --- a/components/bt/bluedroid/stack/rfcomm/port_api.c +++ b/components/bt/bluedroid/stack/rfcomm/port_api.c @@ -1785,4 +1785,4 @@ const char *PORT_GetResultString (const uint8_t result_code) return result_code_strings[result_code]; } -#endif ///(defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE) \ No newline at end of file +#endif ///(defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE) diff --git a/components/bt/bluedroid/stack/sdp/sdp_api.c b/components/bt/bluedroid/stack/sdp/sdp_api.c index 529359a4fe..4c2e229892 100644 --- a/components/bt/bluedroid/stack/sdp/sdp_api.c +++ b/components/bt/bluedroid/stack/sdp/sdp_api.c @@ -1240,4 +1240,4 @@ UINT8 SDP_SetTraceLevel (UINT8 new_level) return (sdp_cb.trace_level); } -#endif ///SDP_INCLUDED == TRUE \ No newline at end of file +#endif ///SDP_INCLUDED == TRUE