*
******************************************************************************/
-/******************************************************************************
- *
- * This file contains definitions for implementing the
- * diagnostic trace message service.
- *
- ******************************************************************************/
-
-#ifndef BT_TRACE_H
-#define BT_TRACE_H
-
-#ifndef BTTRC_INCLUDED
-#define BTTRC_INCLUDED FALSE
-#endif
-#ifndef BTTRC_PARSER_INCLUDED
-#define BTTRC_PARSER_INCLUDED FALSE
-#endif
-#ifndef MAX_TRACE_RAM_SIZE
-#define MAX_TRACE_RAM_SIZE 10000
-#endif
+#pragma once
/* BTE tracing IDs for debug purposes */
/* LayerIDs for stack */
#define BTTRC_ID_STK_SNEP 52
#define BTTRC_ID_STK_NDEF 53
-
/* LayerIDs for BTA */
#define BTTRC_ID_BTA_ACC 55 /* Advanced Camera Client */
#define BTTRC_ID_BTA_AG 56 /* audio gateway */
#define BTTRC_ID_MAX_ID BTTRC_ID_BT_PROTOCOL
// btla-specific --
#define BTTRC_ID_ALL_LAYERS 0xFF /* all trace layers */
-typedef UINT8 tBTTRC_LAYER_ID;
-
-/* Trace type definitions. Note that these are mutually exclusive in a trace. This
-means that any trace can be either error,warning,api,event or dbg */
-#define BTTRC_TYPE_ERROR 0x01 /* Traces for error situation */
-#define BTTRC_TYPE_WARNING 0x02 /* Traces for warning situation */
-#define BTTRC_TYPE_API 0x04 /* Traces for API */
-#define BTTRC_TYPE_EVENT 0x08 /* Traces for EVENT */
-#define BTTRC_TYPE_ACTION 0x10 /* Traces for Action functions */
-#define BTTRC_TYPE_DBG 0x20 /* Traces for debugging purpose */
-typedef UINT8 tBTTRC_TYPE;
-
-/* Masks to identify the stack that originated the trace */
-#define BTTRC_TRACE_LITE 0x80 /* MM Lite stack */
-#define BTTRC_TRACE_EMBD 0x40 /* Embedded host stack */
-
/* Parameter datatypes used in Trace APIs */
#define BTTRC_PARAM_UINT8 1
#define BTTRC_PARAM_UINT16 2
#define BTTRC_PARAM_UINT32 3
-typedef UINT8 tBTTRC_PARAM_TYPE;
-
-/* Special token definitions */
-#define BTTRC_TOKEN_SM_STATE 0xFFFF /* Token indicating the State of a State m/c */
-
-// btla-specific ++
-typedef struct {
- tBTTRC_LAYER_ID layer_id;
- tBTTRC_TYPE type; /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
-} tBTTRC_LEVEL;
-
-typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
-
-typedef struct {
- const tBTTRC_LAYER_ID layer_id_start;
- const tBTTRC_LAYER_ID layer_id_end;
- tBTTRC_SET_TRACE_LEVEL *p_f;
- const char *trc_name;
- UINT8 trace_level;
-} tBTTRC_FUNC_MAP;
-
-extern tBTTRC_FUNC_MAP bttrc_set_level_map[];
-extern const UINT16 bttrc_map_size;
-extern BT_API tBTTRC_LEVEL * BTA_SysSetTraceLevel( tBTTRC_LEVEL * p_levels );
-// btla-specific --
-
-/* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
-extern UINT8 appl_trace_level ;
-
-void BTE_InitTraceLevels( void );
-
-/* Prototype for message logging function. */
-void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
-
-/* Prototype for stack tracing function. */
-void BTTRC_StackTrace0(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token);
-void BTTRC_StackTrace1(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val);
-void BTTRC_StackTrace2(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
- tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val);
-void BTTRC_StackTrace3(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
- tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
- tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val);
-void BTTRC_StackTrace4(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
- tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
- tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
- tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val);
-void BTTRC_StackTrace5(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
- tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
- tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
- tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val,
- tBTTRC_PARAM_TYPE p5_type, UINT32 p5_val);
-void BTTRC_StackTrace6(tBTTRC_LAYER_ID layer_id,
- tBTTRC_TYPE type,
- UINT16 token,
- tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
- tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
- tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
- tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val,
- tBTTRC_PARAM_TYPE p5_type, UINT32 p5_val,
- tBTTRC_PARAM_TYPE p6_type, UINT32 p6_val);
-
-/******************************************************************************
-**
-** Trace configurable parameters
-**
-******************************************************************************/
/* Enables or disables verbose trace information. */
#ifndef BT_TRACE_VERBOSE
#define BT_USE_TRACES TRUE
#endif
-
/******************************************************************************
**
** Trace Levels
#endif
// btla-specific --
-
-#if (BTTRC_INCLUDED == TRUE)
-/***************************************************************************************/
-/* BTTRC MACROS */
-
-#define BTTRC_EVENT(lid, event, state) \
- {BTTRC_StackTrace1(lid, BTTRC_TYPE_EVENT, event, BTTRC_PARAM_UINT8, state);}
-#define BTTRC_ACTION(lid, action) \
- {BTTRC_StackTrace0(lid, BTTRC_TYPE_ACTION, action);}
-#define BTTRC_STATE(lid, state) \
- {BTTRC_StackTrace1(lid, BTTRC_TYPE_EVENT, BTTRC_TOKEN_SM_STATE, BTTRC_PARAM_UINT8, state);}
-
-#define BTTRC_API0(lid, api) \
- {BTTRC_StackTrace0(lid, BTTRC_TYPE_API, api);}
-#define BTTRC_API1(lid, api, p1_t,p1_v) \
- {BTTRC_StackTrace1(lid, BTTRC_TYPE_API, api, p1_t,p1_v);}
-#define BTTRC_API2(lid, api, p1_t,p1_v,p2_t,p2_v) \
- {BTTRC_StackTrace2(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v);}
-#define BTTRC_API3(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v) \
- {BTTRC_StackTrace3(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v);}
-#define BTTRC_API4(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v) \
- {BTTRC_StackTrace4(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v);}
-#define BTTRC_API5(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v) \
- {BTTRC_StackTrace5(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v);}
-#define BTTRC_API6(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v) \
- {BTTRC_StackTrace6(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v);}
-
-
-#define BTTRC_DBG0(lid, dbg) \
- {BTTRC_StackTrace0(lid, BTTRC_TYPE_DBG, dbg);}
-#define BTTRC_DBG1(lid, dbg, p1_t,p1_v) \
- {BTTRC_StackTrace1(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v);}
-#define BTTRC_DBG2(lid, dbg, p1_t,p1_v,p2_t,p2_v) \
- {BTTRC_StackTrace2(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v);}
-#define BTTRC_DBG3(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v) \
- {BTTRC_StackTrace3(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v);}
-#define BTTRC_DBG4(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v) \
- {BTTRC_StackTrace4(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v);}
-#define BTTRC_DBG5(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v) \
- {BTTRC_StackTrace5(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v);}
-#define BTTRC_DBG6(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v) \
- {BTTRC_StackTrace6(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v);}
-
-/***************************************************************************************/
-/*AVDT MACROS */
-
-#define BTTRC_AVDT_API0(api) \
- BTTRC_API0(BTTRC_ID_STK_AVDT, api)
-#define BTTRC_AVDT_API1(api, p1_t, p1_v) \
- BTTRC_API1(BTTRC_ID_STK_AVDT, api, p1_t, p1_v)
-#define BTTRC_AVDT_API2(api, p1_t, p1_v, p2_t, p2_v) \
- BTTRC_API2(BTTRC_ID_STK_AVDT, api, p1_t, p1_v, p2_t, p2_v)
-/***************************************************************************************/
-/*AVDT_SCB MACROS */
-
-#define BTTRC_AVDT_SCB_EVENT(event, state) \
- BTTRC_EVENT(BTTRC_ID_AVDT_SCB, event, state)
-#define BTTRC_AVDT_SCB_ACTION(action) \
- BTTRC_ACTION(BTTRC_ID_AVDT_SCB, action)
-#define BTTRC_AVDT_SCB_STATE(next_state) \
- BTTRC_STATE(BTTRC_ID_AVDT_SCB, next_state)
-
-#define BTTRC_AVDT_SCB_DBG0(dbg) \
- BTTRC_DBG0(BTTRC_ID_AVDT_SCB, dbg)
-#define BTTRC_AVDT_SCB_DBG1(dbg, p1_t,p1_v) \
- BTTRC_DBG1(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v)
-#define BTTRC_AVDT_SCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v) \
- BTTRC_DBG2(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v)
-#define BTTRC_AVDT_SCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v) \
- BTTRC_DBG3(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_AVDT_SCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v) \
- BTTRC_DBG4(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_AVDT_SCB_DBG5(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v) \
- BTTRC_DBG5(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_AVDT_SCB_DBG6(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v) \
- BTTRC_DBG6(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-/***************************************************************************************/
-/*AVDT_CCB MACROS */
-
-#define BTTRC_AVDT_CCB_EVENT(event, state) \
- BTTRC_EVENT(BTTRC_ID_AVDT_CCB, event, state)
-#define BTTRC_AVDT_CCB_ACTION(action) \
- BTTRC_ACTION(BTTRC_ID_AVDT_CCB, action)
-#define BTTRC_AVDT_CCB_STATE(next_state) \
- BTTRC_STATE(BTTRC_ID_AVDT_CCB, next_state)
-
-#define BTTRC_AVDT_CCB_DBG0(dbg) \
- BTTRC_DBG0(BTTRC_ID_AVDT_CCB, dbg)
-#define BTTRC_AVDT_CCB_DBG1(dbg, p1_t,p1_v) \
- BTTRC_DBG1(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v)
-#define BTTRC_AVDT_CCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v) \
- BTTRC_DBG2(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v)
-#define BTTRC_AVDT_CCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v) \
- BTTRC_DBG3(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_AVDT_CCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v) \
- BTTRC_DBG4(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_AVDT_CCB_DBG5(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v) \
- BTTRC_DBG5(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_AVDT_CCB_DBG6(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v) \
- BTTRC_DBG6(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-/***************************************************************************************/
-
-#else /*BTTRC_INCLUDED*/
-
-/***************************************************************************************/
-/* BTTRC MACROS */
-
-#define BTTRC_EVENT(lid, event, state)
-#define BTTRC_ACTION(lid, action)
-#define BTTRC_STATE(lid, state)
-
-#define BTTRC_API0(lid, api)
-#define BTTRC_API1(lid, api, p1_t, p1_v)
-#define BTTRC_API2(lid, api, p1_t, p1_v, p2_t, p2_v)
-#define BTTRC_API3(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_API4(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_API5(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_API6(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-
-
-#define BTTRC_DBG0(lid, dbg)
-#define BTTRC_DBG1(lid, dbg, p1_t,p1_v)
-#define BTTRC_DBG2(lid, dbg, p1_t,p1_v,p2_t,p2_v)
-#define BTTRC_DBG3(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_DBG4(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_DBG5(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_DBG6(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-
/***************************************************************************************/
/*AVDT MACROS */
#define BTTRC_AVDT_API0(api)
#define BTTRC_AVDT_SCB_ACTION(action)
#define BTTRC_AVDT_SCB_STATE(next_state)
-#define BTTRC_AVDT_SCB_DBG0(dbg)
-#define BTTRC_AVDT_SCB_DBG1(dbg, p1_t,p1_v)
-#define BTTRC_AVDT_SCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)
-#define BTTRC_AVDT_SCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_AVDT_SCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_AVDT_SCB_DBG5(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_AVDT_SCB_DBG6(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-
/***************************************************************************************/
/*AVDT_CCB MACROS */
#define BTTRC_AVDT_CCB_ACTION(action)
#define BTTRC_AVDT_CCB_STATE(next_state)
-#define BTTRC_AVDT_CCB_DBG0(dbg)
-#define BTTRC_AVDT_CCB_DBG1(dbg, p1_t,p1_v)
-#define BTTRC_AVDT_CCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)
-#define BTTRC_AVDT_CCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
-#define BTTRC_AVDT_CCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
-#define BTTRC_AVDT_CCB_DBG5(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v)
-#define BTTRC_AVDT_CCB_DBG6(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v,p5_t,p5_v,p6_t,p6_v)
-
-/***************************************************************************************/
-
-#endif /*BTTRC_INCLUDED*/
-
-
-#if (BT_USE_TRACES == TRUE)
-
#define BT_TRACE(l,t,...) LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__)
#define BT_ERROR_TRACE(l,...) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, ##__VA_ARGS__)
#define SMP_TRACE_EVENT(...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
#define SMP_TRACE_DEBUG(...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
-/* END OF USE TRACES */
-#else
-
-#define BT_TRACE(l,t,...)
-#define BT_BT_ERROR_TRACE(l,...)
-
-/* Define tracing for the HCI unit
-*/
-#define HCI_TRACE_ERROR(...)
-#define HCI_TRACE_WARNING(...)
-#define HCI_TRACE_EVENT(...)
-#define HCI_TRACE_DEBUG(...)
-
-
-/* Define tracing for BTM
-*/
-#define BTM_TRACE_ERROR(...)
-#define BTM_TRACE_WARNING(...)
-#define BTM_TRACE_API(...)
-#define BTM_TRACE_EVENT(...)
-#define BTM_TRACE_DEBUG(...)
-
-
-/* Define tracing for the L2CAP unit
-*/
-#define L2CAP_TRACE_ERROR(...)
-#define L2CAP_TRACE_WARNING(...)
-#define L2CAP_TRACE_API(...)
-#define L2CAP_TRACE_EVENT(...)
-#define L2CAP_TRACE_DEBUG(...)
-
-/* Define tracing for the SDP unit
-*/
-#define SDP_TRACE_ERROR(...)
-#define SDP_TRACE_WARNING(...)
-#define SDP_TRACE_API(...)
-#define SDP_TRACE_EVENT(...)
-#define SDP_TRACE_DEBUG(...)
-
-/* Define tracing for the RFCOMM unit
-*/
-#define RFCOMM_TRACE_ERROR(...)
-#define RFCOMM_TRACE_WARNING(...)
-#define RFCOMM_TRACE_API(...)
-#define RFCOMM_TRACE_EVENT(...)
-#define RFCOMM_TRACE_DEBUG(...)
-
-/* Generic Access Profile traces */
-#define GAP_TRACE_ERROR(...)
-#define GAP_TRACE_EVENT(...)
-#define GAP_TRACE_API(...)
-#define GAP_TRACE_WARNING(...)
-
-/* define traces for HID Host */
-#define HIDH_TRACE_ERROR(...)
-#define HIDH_TRACE_WARNING(...)
-#define HIDH_TRACE_API(...)
-#define HIDH_TRACE_EVENT(...)
-#define HIDH_TRACE_DEBUG(...)
-
-/* define traces for BNEP */
-
-#define BNEP_TRACE_ERROR(...)
-#define BNEP_TRACE_WARNING(...)
-#define BNEP_TRACE_API(...)
-#define BNEP_TRACE_EVENT(...)
-#define BNEP_TRACE_DEBUG(...)
-
-/* define traces for PAN */
-
-#define PAN_TRACE_ERROR(...)
-#define PAN_TRACE_WARNING(...)
-#define PAN_TRACE_API(...)
-#define PAN_TRACE_EVENT(...)
-#define PAN_TRACE_DEBUG(...)
-
-/* Define tracing for the A2DP profile
-*/
-#define A2D_TRACE_ERROR(...)
-#define A2D_TRACE_WARNING(...)
-#define A2D_TRACE_EVENT(...)
-#define A2D_TRACE_DEBUG(...)
-#define A2D_TRACE_API(...)
-
-/* AVDTP
-*/
-#define AVDT_TRACE_ERROR(...)
-#define AVDT_TRACE_WARNING(...)
-#define AVDT_TRACE_EVENT(...)
-#define AVDT_TRACE_DEBUG(...)
-#define AVDT_TRACE_API(...)
-
-/* Define tracing for the AVCTP protocol
-*/
-#define AVCT_TRACE_ERROR(...)
-#define AVCT_TRACE_WARNING(...)
-#define AVCT_TRACE_EVENT(...)
-#define AVCT_TRACE_DEBUG(...)
-#define AVCT_TRACE_API(...)
-
-/* Define tracing for the AVRCP profile
-*/
-#define AVRC_TRACE_ERROR(...)
-#define AVRC_TRACE_WARNING(...)
-#define AVRC_TRACE_EVENT(...)
-#define AVRC_TRACE_DEBUG(...)
-#define AVRC_TRACE_API(...)
-
-/* MCAP
-*/
-#define MCA_TRACE_ERROR(...)
-#define MCA_TRACE_WARNING(...)
-#define MCA_TRACE_EVENT(...)
-#define MCA_TRACE_DEBUG(...)
-#define MCA_TRACE_API(...)
-
-/* Define tracing for the GATT
-*/
-#define GATT_TRACE_ERROR(...)
-#define GATT_TRACE_WARNING(...)
-#define GATT_TRACE_API(...)
-#define GATT_TRACE_EVENT(...)
-#define GATT_TRACE_DEBUG(...)
-
-/* Define tracing for the SMP unit
-*/
-#define SMP_TRACE_ERROR(...)
-#define SMP_TRACE_WARNING(...)
-#define SMP_TRACE_API(...)
-#define SMP_TRACE_EVENT(...)
-#define SMP_TRACE_DEBUG(...)
-
-#endif
-
-#if (BT_TRACE_BTIF == TRUE)
-
extern UINT8 btif_trace_level;
/* define traces for application */
#define BTIF_TRACE_DEBUG(...) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
#define BTIF_TRACE_VERBOSE(...) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
-#else
-/* define traces for Application */
-
-#define BTIF_TRACE_ERROR(...)
-#define BTIF_TRACE_WARNING(...)
-#define BTIF_TRACE_API(...)
-#define BTIF_TRACE_EVENT(...)
-#define BTIF_TRACE_DEBUG(...)
-#define BTIF_TRACE_VERBOSE(...)
-
-#endif
-
-
-#if (BT_USE_TRACES == TRUE || BT_TRACE_APPL == TRUE)
-
/* define traces for application */
#define APPL_TRACE_ERROR(...) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, ##__VA_ARGS__);}
#define APPL_TRACE_WARNING(...) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, ##__VA_ARGS__);}
#define APPL_TRACE_DEBUG(...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
#define APPL_TRACE_VERBOSE(...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
-#else
-/* define traces for Application */
-
-#define APPL_TRACE_ERROR(...)
-#define APPL_TRACE_WARNING(...)
-#define APPL_TRACE_API(...)
-#define APPL_TRACE_EVENT(...)
-#define APPL_TRACE_DEBUG(...)
-#define APPL_TRACE_VERBOSE(...)
-
-#endif
-
/* Simplified Trace Helper Macro
*/
-#if (BT_USE_TRACES == TRUE)
#define bdld(fmt, ...) \
do{\
if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): assert failed: " #assert_if, __FUNCTION__, __LINE__); \
}while(0)
-#else
-#define bdld(fmt, ...) ((void)0) /*Empty statement as placeholder*/
-#define bdlw(fmt, ...) ((void)0)
-#define bdle(fmt, ...) ((void)0)
-#define bdla(assert_if) ((void)0)
-#endif
-#endif /* BT_TRACE_H */
+
+typedef UINT8 tBTTRC_PARAM_TYPE;
+typedef UINT8 tBTTRC_LAYER_ID;
+typedef UINT8 tBTTRC_TYPE;
+
+typedef struct {
+ tBTTRC_LAYER_ID layer_id;
+ tBTTRC_TYPE type; /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
+} tBTTRC_LEVEL;
+
+typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
+
+typedef struct {
+ const tBTTRC_LAYER_ID layer_id_start;
+ const tBTTRC_LAYER_ID layer_id_end;
+ tBTTRC_SET_TRACE_LEVEL *p_f;
+ const char *trc_name;
+ UINT8 trace_level;
+} tBTTRC_FUNC_MAP;
+
+/* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
+extern UINT8 appl_trace_level;
+
+void BTE_InitTraceLevels(void);
*
******************************************************************************/
-/******************************************************************************
- *
- * Contains the LogMsg wrapper routines for BTE. It routes calls the
- * appropriate application's LogMsg equivalent.
- *
- ******************************************************************************/
-
#include <assert.h>
+#include <cutils/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <sys/time.h>
+#include <time.h>
-#include "config.h"
-#include "gki.h"
#include "bte.h"
-
+#include "bta_api.h"
#include "bte_appl.h"
-
-#if MMI_INCLUDED == TRUE
-#include "mmi.h"
-#endif
-
-/* always enable trace framework */
-
#include "btu.h"
+#include "config.h"
+#include "gki.h"
#include "l2c_api.h"
+
#if (RFCOMM_INCLUDED==TRUE)
#include "port_api.h"
#endif
#include "smp_api.h"
#endif
- /* LayerIDs for BTA, currently everything maps onto appl_trace_level */
-#if (BTA_INCLUDED==TRUE)
-#include "bta_api.h"
-#endif
-
-
-#if defined(__CYGWIN__) || defined(__linux__)
-
-#include <sys/time.h>
-#include <time.h>
-
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
-const char * const bt_layer_tags[] = {
- "bt-btif",
- "bt-usb",
- "bt-serial",
- "bt-socket",
- "bt-rs232",
- "bt-lc",
- "bt-lm",
- "bt-hci",
- "bt-l2cap",
- "bt-rfcomm",
- "bt-sdp",
- "bt-tcs",
- "bt-obex",
- "bt-btm",
- "bt-gap",
- "bt-dun",
- "bt-goep",
- "bt-icp",
- "bt-hsp2",
- "bt-spp",
- "bt-ctp",
- "bt-bpp",
- "bt-hcrp",
- "bt-ftp",
- "bt-opp",
- "bt-btu",
- "bt-gki",
- "bt-bnep",
- "bt-pan",
- "bt-hfp",
- "bt-hid",
- "bt-bip",
- "bt-avp",
- "bt-a2d",
- "bt-sap",
- "bt-amp",
- "bt-mca",
- "bt-att",
- "bt-smp",
- "bt-nfc",
- "bt-nci",
- "bt-idep",
- "bt-ndep",
- "bt-llcp",
- "bt-rw",
- "bt-ce",
- "bt-snep",
- "bt-ndef",
- "bt-nfa",
-};
-
-#ifndef LINUX_NATIVE
-#include <cutils/log.h>
#define LOGI0(t,s) __android_log_write(ANDROID_LOG_INFO, t, s)
#define LOGD0(t,s) __android_log_write(ANDROID_LOG_DEBUG, t, s)
#define LOGW0(t,s) __android_log_write(ANDROID_LOG_WARN, t, s)
#define LOGE0(t,s) __android_log_write(ANDROID_LOG_ERROR, t, s)
-#else
-#undef ANDROID_USE_LOGCAT
-#endif
-
-#endif
-
-
-//#include "btl_cfg.h"
-#define BTL_GLOBAL_PROP_TRC_FLAG "TRC_BTAPP"
#ifndef DEFAULT_CONF_TRACE_LEVEL
#define DEFAULT_CONF_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif
#ifndef BTE_LOG_BUF_SIZE
#define BTE_LOG_BUF_SIZE 1024
#endif
-#define BTE_LOG_MAX_SIZE (BTE_LOG_BUF_SIZE - 12)
-
-//#define BTE_MAP_TRACE_LEVEL FALSE
-/* map by default BTE trace levels onto android trace levels */
-#ifndef BTE_MAP_TRACE_LEVEL
-#define BTE_MAP_TRACE_LEVEL TRUE
-#endif
+#define BTE_LOG_MAX_SIZE (BTE_LOG_BUF_SIZE - 12)
-// #define BTE_ANDROID_INTERNAL_TIMESTAMP TRUE
-/* by default no internal timestamp. adb logcate -v time allows having timestamps */
-#ifndef BTE_ANDROID_INTERNAL_TIMESTAMP
-#define BTE_ANDROID_INTERNAL_TIMESTAMP FALSE
-#endif
-#if (BTE_ANDROID_INTERNAL_TIMESTAMP==TRUE)
-#define MSG_BUFFER_OFFSET strlen(buffer)
-#else
#define MSG_BUFFER_OFFSET 0
-#endif
-
-//#define DBG_TRACE
-
-#if defined( DBG_TRACE )
-#define DBG_TRACE_API0( m ) BT_TRACE( TRACE_LAYER_HCI, TRACE_TYPE_API, m )
-#define DBG_TRACE_WARNING2( m, p0, p1 ) BT_TRACE( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_WARNING), m, p0, p1 )
-#else
-#define DBG_TRACE_API0( m )
-#define DBG_TRACE_WARNING2( m, p0, p1 )
-#endif
-#define DBG_TRACE_DEBUG2( m, p0, p1 ) BT_TRACE( TRACE_LAYER_BTM, (TRACE_ORG_APPL|TRACE_TYPE_DEBUG), m, p0, p1 )
-
-void
-LogMsg(UINT32 trace_set_mask, const char *fmt_str, ...)
-{
- static char buffer[BTE_LOG_BUF_SIZE];
- int trace_layer = TRACE_GET_LAYER(trace_set_mask);
- if (trace_layer >= TRACE_LAYER_MAX_NUM)
- trace_layer = 0;
-
- va_list ap;
-#if (BTE_ANDROID_INTERNAL_TIMESTAMP==TRUE)
- struct timeval tv;
- struct timezone tz;
- struct tm *tm;
- time_t t;
-
- gettimeofday(&tv, &tz);
- time(&t);
- tm = localtime(&t);
-
- sprintf(buffer, "%02d:%02d:%02d.%03d ", tm->tm_hour, tm->tm_min, tm->tm_sec,
- tv.tv_usec / 1000);
-#endif
- va_start(ap, fmt_str);
- vsnprintf(&buffer[MSG_BUFFER_OFFSET], BTE_LOG_MAX_SIZE, fmt_str, ap);
- va_end(ap);
-
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
-#if (BTE_MAP_TRACE_LEVEL==TRUE)
- switch ( TRACE_GET_TYPE(trace_set_mask) )
- {
- case TRACE_TYPE_ERROR:
- LOGE0(bt_layer_tags[trace_layer], buffer);
- break;
- case TRACE_TYPE_WARNING:
- LOGW0(bt_layer_tags[trace_layer], buffer);
- break;
- case TRACE_TYPE_API:
- case TRACE_TYPE_EVENT:
- LOGI0(bt_layer_tags[trace_layer], buffer);
- break;
- case TRACE_TYPE_DEBUG:
- LOGD0(bt_layer_tags[trace_layer], buffer);
- break;
- default:
- LOGE0(bt_layer_tags[trace_layer], buffer); /* we should never get this */
- break;
- }
-#else
- LOGI0(bt_layer_tags[trace_layer], buffer);
-#endif
-#else
- write(2, buffer, strlen(buffer));
- write(2, "\n", 1);
-#endif
-}
-
-void
-ScrLog(UINT32 trace_set_mask, const char *fmt_str, ...)
-{
- static char buffer[BTE_LOG_BUF_SIZE];
-
- va_list ap;
- struct timeval tv;
- struct timezone tz;
- struct tm *tm;
- time_t t;
- int trace_layer = TRACE_GET_LAYER(trace_set_mask);
- if (trace_layer >= TRACE_LAYER_MAX_NUM)
- trace_layer = 0;
- gettimeofday(&tv, &tz);
- time(&t);
- tm = localtime(&t);
-
- sprintf(buffer, "%02d:%02d:%02d.%03ld ", tm->tm_hour, tm->tm_min, tm->tm_sec,
- tv.tv_usec / 1000);
-
- va_start(ap, fmt_str);
- vsnprintf(&buffer[strlen(buffer)], BTE_LOG_MAX_SIZE, fmt_str, ap);
- va_end(ap);
-
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
- LOGI0(bt_layer_tags[trace_layer], buffer);
-#else
- write(2, buffer, strlen(buffer));
- write(2, "\n", 1);
-#endif
-}
-
-/* this function should go into BTAPP_DM for example */
-BT_API UINT8 BTAPP_SetTraceLevel( UINT8 new_level )
-{
- if (new_level != 0xFF)
- appl_trace_level = new_level;
-
- return (appl_trace_level);
-}
-BT_API UINT8 BTIF_SetTraceLevel( UINT8 new_level )
-{
- if (new_level != 0xFF)
- btif_trace_level = new_level;
-
- return (btif_trace_level);
-}
-
-BTU_API UINT8 BTU_SetTraceLevel( UINT8 new_level )
-{
- if (new_level != 0xFF)
- btu_cb.trace_level = new_level;
-
- return (btu_cb.trace_level);
-}
-
-BOOLEAN trace_conf_enabled = FALSE;
-
-void bte_trace_conf(const char *p_conf_name, const char *p_conf_value)
-{
- tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *) &bttrc_set_level_map[0];
-
- while (p_f_map->trc_name != NULL)
- {
- if (strcmp(p_f_map->trc_name, (const char *)p_conf_name) == 0)
- {
- p_f_map->trace_level = (UINT8) atoi(p_conf_value);
- break;
- }
- p_f_map++;
- }
-}
-
-void bte_trace_conf_config(const config_t *config) {
- assert(config != NULL);
-
- for (tBTTRC_FUNC_MAP *functions = &bttrc_set_level_map[0]; functions->trc_name; ++functions) {
- int value = config_get_int(config, CONFIG_DEFAULT_SECTION, functions->trc_name, -1);
- if (value != -1)
- functions->trace_level = value;
- }
-}
-
-/********************************************************************************
- **
- ** Function Name: BTA_SysSetTraceLevel
- **
- ** Purpose: set or reads the different Trace Levels of layer IDs (see bt_trace.h,
- ** BTTRC_ID_xxxx
- **
- ** Input Parameters: Array with trace layers to set to a given level or read. a layer ID of 0
- ** defines the end of the list
- ** WARNING: currently type should be 0-5! or FF for reading!!!!
- **
- ** Returns:
- ** input array with trace levels for given layer id
- **
- *********************************************************************************/
-BT_API tBTTRC_LEVEL * BTA_SysSetTraceLevel(tBTTRC_LEVEL * p_levels)
-{
- const tBTTRC_FUNC_MAP *p_f_map;
- tBTTRC_LEVEL *p_l = p_levels;
-
- DBG_TRACE_API0( "BTA_SysSetTraceLevel()" );
-
- while (0 != p_l->layer_id)
- {
- p_f_map = &bttrc_set_level_map[0];
-
- while (0 != p_f_map->layer_id_start)
- {
- printf("BTA_SysSetTraceLevel - trace id in map start = %d end= %d, paramter id = %d\r\n", p_f_map->layer_id_start, p_f_map->layer_id_end, p_l->layer_id );
- /* as p_f_map is ordered by increasing layer id, go to next map entry as long end id
- * is smaller */
- //if (p_f_map->layer_id_end < p_l->layer_id)
- //{
- //p_f_map++;
- //}
- //else
- {
- /* check if layer_id actually false into a range or if it is note existing in the map */
- if ((NULL != p_f_map->p_f) && (p_f_map->layer_id_start <= p_l->layer_id) && (p_f_map->layer_id_end >= p_l->layer_id) )
- {
- DBG_TRACE_DEBUG2( "BTA_SysSetTraceLevel( id:%d, level:%d ): setting/reading",
- p_l->layer_id, p_l->type );
- p_l->type = p_f_map->p_f(p_l->type);
- break;
- }
- else
- {
- DBG_TRACE_WARNING2( "BTA_SysSetTraceLevel( id:%d, level:%d ): MISSING Set function OR ID in map!",
- p_l->layer_id, p_l->type );
- }
- /* set/read next trace level by getting out ot map loop */
- //p_l++;
- //break;
- }
- p_f_map++;
- }
- //if (0 == p_f_map->layer_id_start)
- {
- DBG_TRACE_WARNING2( "BTA_SysSetTraceLevel( id:%d, level:%d ): ID NOT FOUND in map. Skip to next",
- p_l->layer_id, p_l->type );
- p_l++;
- }
- }
+bool trace_conf_enabled = false;
+
+/* LayerIDs for BTA, currently everything maps onto appl_trace_level */
+static const char * const bt_layer_tags[] = {
+ "bt-btif",
+ "bt-usb",
+ "bt-serial",
+ "bt-socket",
+ "bt-rs232",
+ "bt-lc",
+ "bt-lm",
+ "bt-hci",
+ "bt-l2cap",
+ "bt-rfcomm",
+ "bt-sdp",
+ "bt-tcs",
+ "bt-obex",
+ "bt-btm",
+ "bt-gap",
+ "bt-dun",
+ "bt-goep",
+ "bt-icp",
+ "bt-hsp2",
+ "bt-spp",
+ "bt-ctp",
+ "bt-bpp",
+ "bt-hcrp",
+ "bt-ftp",
+ "bt-opp",
+ "bt-btu",
+ "bt-gki",
+ "bt-bnep",
+ "bt-pan",
+ "bt-hfp",
+ "bt-hid",
+ "bt-bip",
+ "bt-avp",
+ "bt-a2d",
+ "bt-sap",
+ "bt-amp",
+ "bt-mca",
+ "bt-att",
+ "bt-smp",
+ "bt-nfc",
+ "bt-nci",
+ "bt-idep",
+ "bt-ndep",
+ "bt-llcp",
+ "bt-rw",
+ "bt-ce",
+ "bt-snep",
+ "bt-ndef",
+ "bt-nfa",
+};
- return p_levels;
-} /* BTA_SysSetTraceLevel() */
+static uint8_t BTAPP_SetTraceLevel(uint8_t new_level);
+static uint8_t BTIF_SetTraceLevel(uint8_t new_level);
+static uint8_t BTU_SetTraceLevel(uint8_t new_level);
/* make sure list is order by increasing layer id!!! */
-tBTTRC_FUNC_MAP bttrc_set_level_map[] = {
- {BTTRC_ID_STK_BTU, BTTRC_ID_STK_HCI, BTU_SetTraceLevel, "TRC_HCI", DEFAULT_CONF_TRACE_LEVEL},
- {BTTRC_ID_STK_L2CAP, BTTRC_ID_STK_L2CAP, L2CA_SetTraceLevel, "TRC_L2CAP", DEFAULT_CONF_TRACE_LEVEL},
+static tBTTRC_FUNC_MAP bttrc_set_level_map[] = {
+ {BTTRC_ID_STK_BTU, BTTRC_ID_STK_HCI, BTU_SetTraceLevel, "TRC_HCI", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_L2CAP, BTTRC_ID_STK_L2CAP, L2CA_SetTraceLevel, "TRC_L2CAP", DEFAULT_CONF_TRACE_LEVEL},
#if (RFCOMM_INCLUDED==TRUE)
- {BTTRC_ID_STK_RFCOMM, BTTRC_ID_STK_RFCOMM_DATA, PORT_SetTraceLevel, "TRC_RFCOMM", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_RFCOMM, BTTRC_ID_STK_RFCOMM_DATA, PORT_SetTraceLevel, "TRC_RFCOMM", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (OBX_INCLUDED==TRUE)
- {BTTRC_ID_STK_OBEX, BTTRC_ID_STK_OBEX, OBX_SetTraceLevel, "TRC_OBEX", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_OBEX, BTTRC_ID_STK_OBEX, OBX_SetTraceLevel, "TRC_OBEX", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVCT_INCLUDED==TRUE)
- //{BTTRC_ID_STK_AVCT, BTTRC_ID_STK_AVCT, NULL, "TRC_AVCT", DEFAULT_CONF_TRACE_LEVEL},
+ //{BTTRC_ID_STK_AVCT, BTTRC_ID_STK_AVCT, NULL, "TRC_AVCT", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVDT_INCLUDED==TRUE)
- {BTTRC_ID_STK_AVDT, BTTRC_ID_STK_AVDT, AVDT_SetTraceLevel, "TRC_AVDT", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_AVDT, BTTRC_ID_STK_AVDT, AVDT_SetTraceLevel, "TRC_AVDT", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVRC_INCLUDED==TRUE)
- {BTTRC_ID_STK_AVRC, BTTRC_ID_STK_AVRC, AVRC_SetTraceLevel, "TRC_AVRC", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_AVRC, BTTRC_ID_STK_AVRC, AVRC_SetTraceLevel, "TRC_AVRC", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVDT_INCLUDED==TRUE)
- //{BTTRC_ID_AVDT_SCB, BTTRC_ID_AVDT_CCB, NULL, "TRC_AVDT_SCB", DEFAULT_CONF_TRACE_LEVEL},
+ //{BTTRC_ID_AVDT_SCB, BTTRC_ID_AVDT_CCB, NULL, "TRC_AVDT_SCB", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (A2D_INCLUDED==TRUE)
- {BTTRC_ID_STK_A2D, BTTRC_ID_STK_A2D, A2D_SetTraceLevel, "TRC_A2D", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_A2D, BTTRC_ID_STK_A2D, A2D_SetTraceLevel, "TRC_A2D", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BIP_INCLUDED==TRUE)
- {BTTRC_ID_STK_BIP, BTTRC_ID_STK_BIP, BIP_SetTraceLevel, "TRC_BIP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_BIP, BTTRC_ID_STK_BIP, BIP_SetTraceLevel, "TRC_BIP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BNEP_INCLUDED==TRUE)
- {BTTRC_ID_STK_BNEP, BTTRC_ID_STK_BNEP, BNEP_SetTraceLevel, "TRC_BNEP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_BNEP, BTTRC_ID_STK_BNEP, BNEP_SetTraceLevel, "TRC_BNEP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BPP_INCLUDED==TRUE)
- {BTTRC_ID_STK_BPP, BTTRC_ID_STK_BPP, BPP_SetTraceLevel, "TRC_BPP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_BPP, BTTRC_ID_STK_BPP, BPP_SetTraceLevel, "TRC_BPP", DEFAULT_CONF_TRACE_LEVEL},
#endif
- {BTTRC_ID_STK_BTM_ACL, BTTRC_ID_STK_BTM_SEC, BTM_SetTraceLevel, "TRC_BTM", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_BTM_ACL, BTTRC_ID_STK_BTM_SEC, BTM_SetTraceLevel, "TRC_BTM", DEFAULT_CONF_TRACE_LEVEL},
#if (DUN_INCLUDED==TRUE)
- {BTTRC_ID_STK_DUN, BTTRC_ID_STK_DUN, DUN_SetTraceLevel, "TRC_DUN", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_DUN, BTTRC_ID_STK_DUN, DUN_SetTraceLevel, "TRC_DUN", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (GAP_INCLUDED==TRUE)
- {BTTRC_ID_STK_GAP, BTTRC_ID_STK_GAP, GAP_SetTraceLevel, "TRC_GAP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_GAP, BTTRC_ID_STK_GAP, GAP_SetTraceLevel, "TRC_GAP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (GOEP_INCLUDED==TRUE)
- {BTTRC_ID_STK_GOEP, BTTRC_ID_STK_GOEP, GOEP_SetTraceLevel, "TRC_GOEP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_GOEP, BTTRC_ID_STK_GOEP, GOEP_SetTraceLevel, "TRC_GOEP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (HCRP_INCLUDED==TRUE)
- {BTTRC_ID_STK_HCRP, BTTRC_ID_STK_HCRP, HCRP_SetTraceLevel, "TRC_HCRP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_HCRP, BTTRC_ID_STK_HCRP, HCRP_SetTraceLevel, "TRC_HCRP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (PAN_INCLUDED==TRUE)
- {BTTRC_ID_STK_PAN, BTTRC_ID_STK_PAN, PAN_SetTraceLevel, "TRC_PAN", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_PAN, BTTRC_ID_STK_PAN, PAN_SetTraceLevel, "TRC_PAN", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (SAP_SERVER_INCLUDED==TRUE)
- {BTTRC_ID_STK_SAP, BTTRC_ID_STK_SAP, NULL, "TRC_SAP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_SAP, BTTRC_ID_STK_SAP, NULL, "TRC_SAP", DEFAULT_CONF_TRACE_LEVEL},
#endif
- {BTTRC_ID_STK_SDP, BTTRC_ID_STK_SDP, SDP_SetTraceLevel, "TRC_SDP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_SDP, BTTRC_ID_STK_SDP, SDP_SetTraceLevel, "TRC_SDP", DEFAULT_CONF_TRACE_LEVEL},
#if (BLE_INCLUDED==TRUE)
- {BTTRC_ID_STK_GATT, BTTRC_ID_STK_GATT, GATT_SetTraceLevel, "TRC_GATT", DEFAULT_CONF_TRACE_LEVEL},
- {BTTRC_ID_STK_SMP, BTTRC_ID_STK_SMP, SMP_SetTraceLevel, "TRC_SMP", DEFAULT_CONF_TRACE_LEVEL},
-#endif
-
-#if (BTA_INCLUDED==TRUE)
- /* LayerIDs for BTA, currently everything maps onto appl_trace_level.
- * BTL_GLOBAL_PROP_TRC_FLAG serves as flag in conf.
- */
- {BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, BTAPP_SetTraceLevel, BTL_GLOBAL_PROP_TRC_FLAG, DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_GATT, BTTRC_ID_STK_GATT, GATT_SetTraceLevel, "TRC_GATT", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_SMP, BTTRC_ID_STK_SMP, SMP_SetTraceLevel, "TRC_SMP", DEFAULT_CONF_TRACE_LEVEL},
#endif
-#if (BT_TRACE_BTIF == TRUE)
- {BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, BTIF_SetTraceLevel, "TRC_BTIF", DEFAULT_CONF_TRACE_LEVEL},
-#endif
+ /* LayerIDs for BTA, currently everything maps onto appl_trace_level.
+ */
+ {BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, BTAPP_SetTraceLevel, "TRC_BTAPP", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, BTIF_SetTraceLevel, "TRC_BTIF", DEFAULT_CONF_TRACE_LEVEL},
- {0, 0, NULL, NULL, DEFAULT_CONF_TRACE_LEVEL}
+ {0, 0, NULL, NULL, DEFAULT_CONF_TRACE_LEVEL}
};
-const UINT16 bttrc_map_size = sizeof(bttrc_set_level_map)/sizeof(tBTTRC_FUNC_MAP);
-#endif
+static const UINT16 bttrc_map_size = sizeof(bttrc_set_level_map)/sizeof(tBTTRC_FUNC_MAP);
+
+void bte_trace_conf_config(const config_t *config) {
+ assert(config != NULL);
+
+ for (tBTTRC_FUNC_MAP *functions = &bttrc_set_level_map[0]; functions->trc_name; ++functions) {
+ int value = config_get_int(config, CONFIG_DEFAULT_SECTION, functions->trc_name, -1);
+ if (value != -1)
+ functions->trace_level = value;
+ }
+}
+
+void LogMsg(uint32_t trace_set_mask, const char *fmt_str, ...) {
+ static char buffer[BTE_LOG_BUF_SIZE];
+ int trace_layer = TRACE_GET_LAYER(trace_set_mask);
+ if (trace_layer >= TRACE_LAYER_MAX_NUM)
+ trace_layer = 0;
+
+ va_list ap;
+ va_start(ap, fmt_str);
+ vsnprintf(&buffer[MSG_BUFFER_OFFSET], BTE_LOG_MAX_SIZE, fmt_str, ap);
+ va_end(ap);
+
+ switch ( TRACE_GET_TYPE(trace_set_mask) ) {
+ case TRACE_TYPE_ERROR:
+ LOGE0(bt_layer_tags[trace_layer], buffer);
+ break;
+ case TRACE_TYPE_WARNING:
+ LOGW0(bt_layer_tags[trace_layer], buffer);
+ break;
+ case TRACE_TYPE_API:
+ case TRACE_TYPE_EVENT:
+ LOGI0(bt_layer_tags[trace_layer], buffer);
+ break;
+ case TRACE_TYPE_DEBUG:
+ LOGD0(bt_layer_tags[trace_layer], buffer);
+ break;
+ default:
+ LOGE0(bt_layer_tags[trace_layer], buffer); /* we should never get this */
+ break;
+ }
+}
/********************************************************************************
**
** Newly set levels, if any!
**
*********************************************************************************/
-BT_API void BTE_InitTraceLevels( void )
-{
- /* read and set trace levels by calling the different XXX_SetTraceLevel().
- */
-#if ( BT_USE_TRACES==TRUE )
- if (trace_conf_enabled == TRUE)
- {
- tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *) &bttrc_set_level_map[0];
+void BTE_InitTraceLevels(void) {
+ // Read and set trace levels by calling the different XXX_SetTraceLevel().
+ if (trace_conf_enabled == false) {
+ ALOGI("[bttrc] using compile default trace settings");
+ return;
+ }
- while (p_f_map->trc_name != NULL)
- {
- ALOGI("BTE_InitTraceLevels -- %s", p_f_map->trc_name);
+ tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *)&bttrc_set_level_map[0];
+ while (p_f_map->trc_name != NULL) {
+ ALOGI("BTE_InitTraceLevels -- %s", p_f_map->trc_name);
+ if (p_f_map->p_f)
+ p_f_map->p_f(p_f_map->trace_level);
+ p_f_map++;
+ }
+}
- if (p_f_map->p_f)
- p_f_map->p_f(p_f_map->trace_level);
+/* this function should go into BTAPP_DM for example */
+static uint8_t BTAPP_SetTraceLevel(uint8_t new_level) {
+ if (new_level != 0xFF)
+ appl_trace_level = new_level;
- p_f_map++;
- }
- }
- else
- {
- ALOGI("[bttrc] using compile default trace settings");
- }
-#endif
+ return appl_trace_level;
+}
+
+static uint8_t BTIF_SetTraceLevel(uint8_t new_level) {
+ if (new_level != 0xFF)
+ btif_trace_level = new_level;
+
+ return btif_trace_level;
+}
+
+static uint8_t BTU_SetTraceLevel(uint8_t new_level) {
+ if (new_level != 0xFF)
+ btu_cb.trace_level = new_level;
+
+ return btu_cb.trace_level;
}