Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 1999-2012 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This file contains definitions for implementing the
     22  *  diagnostic trace message service.
     23  *
     24  ******************************************************************************/
     25 
     26 #ifndef BT_TRACE_H
     27 #define BT_TRACE_H
     28 
     29 #ifndef BTTRC_INCLUDED
     30 #define BTTRC_INCLUDED  FALSE
     31 #endif
     32 #ifndef BTTRC_PARSER_INCLUDED
     33 #define BTTRC_PARSER_INCLUDED FALSE
     34 #endif
     35 #ifndef MAX_TRACE_RAM_SIZE
     36 #define MAX_TRACE_RAM_SIZE 10000
     37 #endif
     38 
     39 /* BTE tracing IDs for debug purposes */
     40 /* LayerIDs for stack */
     41 #define BTTRC_ID_STK_GKI                   1
     42 #define BTTRC_ID_STK_BTU                   2
     43 #define BTTRC_ID_STK_HCI                   3
     44 #define BTTRC_ID_STK_L2CAP                 4
     45 #define BTTRC_ID_STK_RFCM_MX               5
     46 #define BTTRC_ID_STK_RFCM_PRT              6
     47 #define BTTRC_ID_STK_OBEX_C                7
     48 #define BTTRC_ID_STK_OBEX_S                8
     49 #define BTTRC_ID_STK_AVCT                  9
     50 #define BTTRC_ID_STK_AVDT                  10
     51 #define BTTRC_ID_STK_AVRC                  11
     52 #define BTTRC_ID_STK_BIC                   12
     53 #define BTTRC_ID_STK_BIS                   13
     54 #define BTTRC_ID_STK_BNEP                  14
     55 #define BTTRC_ID_STK_BPP                   15
     56 #define BTTRC_ID_STK_BTM_ACL               16
     57 #define BTTRC_ID_STK_BTM_PM                17
     58 #define BTTRC_ID_STK_BTM_DEV_CTRL          18
     59 #define BTTRC_ID_STK_BTM_SVC_DSC           19
     60 #define BTTRC_ID_STK_BTM_INQ               20
     61 #define BTTRC_ID_STK_BTM_SCO               21
     62 #define BTTRC_ID_STK_BTM_SEC               22
     63 #define BTTRC_ID_STK_DUN                   23
     64 #define BTTRC_ID_STK_HID                   24
     65 #define BTTRC_ID_STK_HSP2                  25
     66 #define BTTRC_ID_STK_CTP                   26
     67 #define BTTRC_ID_STK_FTC                   27
     68 #define BTTRC_ID_STK_FTS                   28
     69 #define BTTRC_ID_STK_GAP                   29
     70 #define BTTRC_ID_STK_GOEP                  30
     71 #define BTTRC_ID_STK_HCRP                  31
     72 #define BTTRC_ID_STK_ICP                   32
     73 #define BTTRC_ID_STK_OPC                   33
     74 #define BTTRC_ID_STK_OPS                   34
     75 #define BTTRC_ID_STK_PAN                   35
     76 #define BTTRC_ID_STK_SAP                   36
     77 #define BTTRC_ID_STK_SDP                   37
     78 #define BTTRC_ID_STK_SLIP                  38
     79 #define BTTRC_ID_STK_SPP                   39
     80 #define BTTRC_ID_STK_TCS                   40
     81 #define BTTRC_ID_STK_VDP                   41
     82 #define BTTRC_ID_STK_MCAP                  42
     83 #define BTTRC_ID_STK_GATT                  43
     84 #define BTTRC_ID_STK_SMP                   44
     85 #define BTTRC_ID_STK_NFC                   45
     86 #define BTTRC_ID_STK_NCI                   46
     87 #define BTTRC_ID_STK_IDEP                  47
     88 #define BTTRC_ID_STK_NDEP                  48
     89 #define BTTRC_ID_STK_LLCP                  49
     90 #define BTTRC_ID_STK_RW                    50
     91 #define BTTRC_ID_STK_CE                    51
     92 #define BTTRC_ID_STK_SNEP                  52
     93 #define BTTRC_ID_STK_NDEF                  53
     94 
     95 
     96 /* LayerIDs for BTA */
     97 #define BTTRC_ID_BTA_ACC                   55         /* Advanced Camera Client */
     98 #define BTTRC_ID_BTA_AG                    56         /* audio gateway */
     99 #define BTTRC_ID_BTA_AV                    57         /* Advanced audio */
    100 #define BTTRC_ID_BTA_BIC                   58         /* Basic Imaging Client */
    101 #define BTTRC_ID_BTA_BIS                   59         /* Basic Imaging Server */
    102 #define BTTRC_ID_BTA_BP                    60         /* Basic Printing Client */
    103 #define BTTRC_ID_BTA_CG                    61
    104 #define BTTRC_ID_BTA_CT                    62         /* cordless telephony terminal */
    105 #define BTTRC_ID_BTA_DG                    63         /* data gateway */
    106 #define BTTRC_ID_BTA_DM                    64         /* device manager */
    107 #define BTTRC_ID_BTA_DM_SRCH               65         /* device manager search */
    108 #define BTTRC_ID_BTA_DM_SEC                66         /* device manager security */
    109 #define BTTRC_ID_BTA_FM                    67
    110 #define BTTRC_ID_BTA_FTC                   68         /* file transfer client */
    111 #define BTTRC_ID_BTA_FTS                   69         /* file transfer server */
    112 #define BTTRC_ID_BTA_HIDH                  70
    113 #define BTTRC_ID_BTA_HIDD                  71
    114 #define BTTRC_ID_BTA_JV                    72
    115 #define BTTRC_ID_BTA_OPC                   73         /* object push client */
    116 #define BTTRC_ID_BTA_OPS                   74         /* object push server */
    117 #define BTTRC_ID_BTA_PAN                   75         /* Personal Area Networking */
    118 #define BTTRC_ID_BTA_PR                    76         /* Printer client */
    119 #define BTTRC_ID_BTA_SC                    77         /* SIM Card Access server */
    120 #define BTTRC_ID_BTA_SS                    78         /* synchronization server */
    121 #define BTTRC_ID_BTA_SYS                   79         /* system manager */
    122 #define BTTRC_ID_AVDT_SCB                  80         /* avdt scb */
    123 #define BTTRC_ID_AVDT_CCB                  81         /* avdt ccb */
    124 
    125 // btla-specific ++
    126 /* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
    127 #define BTTRC_ID_STK_RFCOMM                82
    128 #define BTTRC_ID_STK_RFCOMM_DATA           83
    129 #define BTTRC_ID_STK_OBEX                  84
    130 #define BTTRC_ID_STK_A2D                   85
    131 #define BTTRC_ID_STK_BIP                   86
    132 
    133 /* LayerIDs for BT APP */
    134 #define BTTRC_ID_BTAPP                     87
    135 #define BTTRC_ID_BT_PROTOCOL               88         /* this is a temporary solution to allow dynamic
    136                                                          enable/disable of BT_PROTOCOL_TRACE */
    137 #define BTTRC_ID_MAX_ID                    BTTRC_ID_BT_PROTOCOL
    138 // btla-specific --
    139 #define BTTRC_ID_ALL_LAYERS                0xFF       /* all trace layers */
    140 typedef UINT8 tBTTRC_LAYER_ID;
    141 
    142 /* Trace type definitions. Note that these are mutually exclusive in a trace. This
    143 means that any trace can be either error,warning,api,event or dbg */
    144 #define BTTRC_TYPE_ERROR                   0x01       /* Traces for error situation */
    145 #define BTTRC_TYPE_WARNING	               0x02       /* Traces for warning situation */
    146 #define BTTRC_TYPE_API                     0x04       /* Traces for API */
    147 #define BTTRC_TYPE_EVENT                   0x08       /* Traces for EVENT */
    148 #define BTTRC_TYPE_ACTION                  0x10       /* Traces for Action functions */
    149 #define BTTRC_TYPE_DBG                     0x20       /* Traces for debugging purpose */
    150 typedef UINT8 tBTTRC_TYPE;
    151 
    152 /* Masks to identify the stack that originated the trace */
    153 #define BTTRC_TRACE_LITE                   0x80       /* MM Lite stack */
    154 #define BTTRC_TRACE_EMBD                   0x40       /* Embedded host stack */
    155 
    156 /* Parameter datatypes used in Trace APIs */
    157 #define BTTRC_PARAM_UINT8                  1
    158 #define BTTRC_PARAM_UINT16                 2
    159 #define BTTRC_PARAM_UINT32                 3
    160 typedef UINT8 tBTTRC_PARAM_TYPE;
    161 
    162 /* Special token definitions */
    163 #define BTTRC_TOKEN_SM_STATE               0xFFFF     /* Token indicating the State of a State m/c */
    164 
    165 // btla-specific ++
    166 typedef struct {
    167     tBTTRC_LAYER_ID layer_id;
    168     tBTTRC_TYPE     type;      /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
    169 } tBTTRC_LEVEL;
    170 
    171 typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
    172 
    173 typedef struct {
    174     const tBTTRC_LAYER_ID         layer_id_start;
    175     const tBTTRC_LAYER_ID         layer_id_end;
    176     tBTTRC_SET_TRACE_LEVEL        *p_f;
    177     const char                    *trc_name;
    178     UINT8                         trace_level;
    179 } tBTTRC_FUNC_MAP;
    180 
    181 extern tBTTRC_FUNC_MAP bttrc_set_level_map[];
    182 extern const UINT16 bttrc_map_size;
    183 extern BT_API tBTTRC_LEVEL * BTA_SysSetTraceLevel( tBTTRC_LEVEL * p_levels );
    184 // btla-specific --
    185 
    186 
    187 #ifdef __cplusplus
    188 extern "C" {
    189 #endif
    190 
    191 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
    192 extern UINT8 appl_trace_level ;
    193 
    194 // btla-specific ++
    195 EXPORT_API extern void BTE_InitTraceLevels( void );
    196 // btla-specific --
    197 
    198 /* Prototype for message logging function. */
    199 EXPORT_API extern void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
    200 
    201 /* Prototype for stack tracing function. */
    202 EXPORT_API extern void BTTRC_StackTrace0(tBTTRC_LAYER_ID layer_id,
    203                                    tBTTRC_TYPE type,
    204                                    UINT16 token);
    205 EXPORT_API extern void BTTRC_StackTrace1(tBTTRC_LAYER_ID layer_id,
    206                                    tBTTRC_TYPE type,
    207                                    UINT16 token,
    208                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val);
    209 EXPORT_API extern void BTTRC_StackTrace2(tBTTRC_LAYER_ID layer_id,
    210                                    tBTTRC_TYPE type,
    211                                    UINT16 token,
    212                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
    213                                    tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val);
    214 EXPORT_API extern void BTTRC_StackTrace3(tBTTRC_LAYER_ID layer_id,
    215                                    tBTTRC_TYPE type,
    216                                    UINT16 token,
    217                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
    218                                    tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
    219                                    tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val);
    220 EXPORT_API extern void BTTRC_StackTrace4(tBTTRC_LAYER_ID layer_id,
    221                                    tBTTRC_TYPE type,
    222                                    UINT16 token,
    223                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
    224                                    tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
    225                                    tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
    226                                    tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val);
    227 EXPORT_API extern void BTTRC_StackTrace5(tBTTRC_LAYER_ID layer_id,
    228                                    tBTTRC_TYPE type,
    229                                    UINT16 token,
    230                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
    231                                    tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
    232                                    tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
    233                                    tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val,
    234                                    tBTTRC_PARAM_TYPE p5_type, UINT32 p5_val);
    235 EXPORT_API extern void BTTRC_StackTrace6(tBTTRC_LAYER_ID layer_id,
    236                                    tBTTRC_TYPE type,
    237                                    UINT16 token,
    238                                    tBTTRC_PARAM_TYPE p1_type, UINT32 p1_val,
    239                                    tBTTRC_PARAM_TYPE p2_type, UINT32 p2_val,
    240                                    tBTTRC_PARAM_TYPE p3_type, UINT32 p3_val,
    241                                    tBTTRC_PARAM_TYPE p4_type, UINT32 p4_val,
    242                                    tBTTRC_PARAM_TYPE p5_type, UINT32 p5_val,
    243                                    tBTTRC_PARAM_TYPE p6_type, UINT32 p6_val);
    244 
    245 // btla-specific ++
    246 /* p_levels must be a 0 terminated list ! */
    247 //EXPORT_API extern tBTTRC_LEVEL * BTA_SysSetTraceLevel( tBTTRC_LEVEL * p_levels );
    248 // btla-specific --
    249 
    250 #ifdef __cplusplus
    251 }
    252 #endif
    253 
    254 /******************************************************************************
    255 **
    256 ** Trace configurable parameters
    257 **
    258 ******************************************************************************/
    259 
    260 /* Enables or disables verbose trace information. */
    261 #ifndef BT_TRACE_VERBOSE
    262 #define BT_TRACE_VERBOSE    FALSE
    263 #endif
    264 
    265 /* Enables or disables all trace messages. */
    266 #ifndef BT_USE_TRACES
    267 #define BT_USE_TRACES       TRUE
    268 #endif
    269 
    270 
    271 /******************************************************************************
    272 **
    273 ** Trace Levels
    274 **
    275 ** The following values may be used for different levels:
    276 **      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
    277 **      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
    278 **      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
    279 **      BT_TRACE_LEVEL_API     3        * API traces
    280 **      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
    281 **      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
    282 ******************************************************************************/
    283 
    284 // btla-specific ++
    285 /* Core Stack default trace levels */
    286 #ifndef HCI_INITIAL_TRACE_LEVEL
    287 #define HCI_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    288 #endif
    289 
    290 #ifndef BTM_INITIAL_TRACE_LEVEL
    291 #define BTM_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    292 #endif
    293 
    294 #ifndef L2CAP_INITIAL_TRACE_LEVEL
    295 #define L2CAP_INITIAL_TRACE_LEVEL           BT_TRACE_LEVEL_WARNING
    296 #endif
    297 
    298 #ifndef RFCOMM_INITIAL_TRACE_LEVEL
    299 #define RFCOMM_INITIAL_TRACE_LEVEL          BT_TRACE_LEVEL_WARNING
    300 #endif
    301 
    302 #ifndef SDP_INITIAL_TRACE_LEVEL
    303 #define SDP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    304 #endif
    305 
    306 #ifndef GAP_INITIAL_TRACE_LEVEL
    307 #define GAP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    308 #endif
    309 
    310 #ifndef BNEP_INITIAL_TRACE_LEVEL
    311 #define BNEP_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    312 #endif
    313 
    314 #ifndef PAN_INITIAL_TRACE_LEVEL
    315 #define PAN_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    316 #endif
    317 
    318 #ifndef A2D_INITIAL_TRACE_LEVEL
    319 #define A2D_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    320 #endif
    321 
    322 #ifndef AVDT_INITIAL_TRACE_LEVEL
    323 #define AVDT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    324 #endif
    325 
    326 #ifndef AVCT_INITIAL_TRACE_LEVEL
    327 #define AVCT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    328 #endif
    329 
    330 #ifndef AVRC_INITIAL_TRACE_LEVEL
    331 #define AVRC_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    332 #endif
    333 
    334 #ifndef MCA_INITIAL_TRACE_LEVEL
    335 #define MCA_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    336 #endif
    337 
    338 #ifndef HID_INITIAL_TRACE_LEVEL
    339 #define HID_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    340 #endif
    341 
    342 #ifndef APPL_INITIAL_TRACE_LEVEL
    343 #define APPL_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    344 #endif
    345 
    346 #ifndef BT_TRACE_APPL
    347 #define BT_TRACE_APPL   BT_USE_TRACES
    348 #endif
    349 
    350 #ifndef GATT_INITIAL_TRACE_LEVEL
    351 #define GATT_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    352 #endif
    353 
    354 #ifndef SMP_INITIAL_TRACE_LEVEL
    355 #define SMP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    356 #endif
    357 // btla-specific --
    358 
    359 
    360 #if (BTTRC_INCLUDED == TRUE)
    361 /***************************************************************************************/
    362 /* BTTRC MACROS */
    363 
    364 #define BTTRC_EVENT(lid, event, state)   \
    365             {BTTRC_StackTrace1(lid, BTTRC_TYPE_EVENT, event, BTTRC_PARAM_UINT8, state);}
    366 #define BTTRC_ACTION(lid, action)  \
    367             {BTTRC_StackTrace0(lid, BTTRC_TYPE_ACTION, action);}
    368 #define BTTRC_STATE(lid, state)   \
    369             {BTTRC_StackTrace1(lid, BTTRC_TYPE_EVENT, BTTRC_TOKEN_SM_STATE, BTTRC_PARAM_UINT8, state);}
    370 
    371 #define BTTRC_API0(lid, api)  \
    372             {BTTRC_StackTrace0(lid, BTTRC_TYPE_API, api);}
    373 #define BTTRC_API1(lid, api, p1_t,p1_v)  \
    374             {BTTRC_StackTrace1(lid, BTTRC_TYPE_API, api, p1_t,p1_v);}
    375 #define BTTRC_API2(lid, api, p1_t,p1_v,p2_t,p2_v)  \
    376             {BTTRC_StackTrace2(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v);}
    377 #define BTTRC_API3(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)  \
    378             {BTTRC_StackTrace3(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v);}
    379 #define BTTRC_API4(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)  \
    380             {BTTRC_StackTrace4(lid, BTTRC_TYPE_API, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v);}
    381 #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)  \
    382             {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);}
    383 #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)  \
    384             {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);}
    385 
    386 
    387 #define BTTRC_DBG0(lid, dbg)  \
    388             {BTTRC_StackTrace0(lid, BTTRC_TYPE_DBG, dbg);}
    389 #define BTTRC_DBG1(lid, dbg, p1_t,p1_v)  \
    390             {BTTRC_StackTrace1(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v);}
    391 #define BTTRC_DBG2(lid, dbg, p1_t,p1_v,p2_t,p2_v)  \
    392             {BTTRC_StackTrace2(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v);}
    393 #define BTTRC_DBG3(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)  \
    394             {BTTRC_StackTrace3(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v);}
    395 #define BTTRC_DBG4(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)  \
    396             {BTTRC_StackTrace4(lid, BTTRC_TYPE_DBG, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v);}
    397 #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)  \
    398             {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);}
    399 #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)  \
    400             {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);}
    401 
    402 /***************************************************************************************/
    403 /*AVDT MACROS */
    404 
    405 #define BTTRC_AVDT_API0(api)   \
    406         BTTRC_API0(BTTRC_ID_STK_AVDT, api)
    407 #define BTTRC_AVDT_API1(api, p1_t, p1_v) \
    408         BTTRC_API1(BTTRC_ID_STK_AVDT, api, p1_t, p1_v)
    409 #define BTTRC_AVDT_API2(api, p1_t, p1_v, p2_t, p2_v) \
    410         BTTRC_API2(BTTRC_ID_STK_AVDT, api, p1_t, p1_v, p2_t, p2_v)
    411 /***************************************************************************************/
    412 /*AVDT_SCB MACROS */
    413 
    414 #define BTTRC_AVDT_SCB_EVENT(event, state)   \
    415             BTTRC_EVENT(BTTRC_ID_AVDT_SCB, event, state)
    416 #define BTTRC_AVDT_SCB_ACTION(action)  \
    417             BTTRC_ACTION(BTTRC_ID_AVDT_SCB, action)
    418 #define BTTRC_AVDT_SCB_STATE(next_state)   \
    419             BTTRC_STATE(BTTRC_ID_AVDT_SCB, next_state)
    420 
    421 #define BTTRC_AVDT_SCB_DBG0(dbg)  \
    422             BTTRC_DBG0(BTTRC_ID_AVDT_SCB, dbg)
    423 #define BTTRC_AVDT_SCB_DBG1(dbg, p1_t,p1_v)  \
    424             BTTRC_DBG1(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v)
    425 #define BTTRC_AVDT_SCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)  \
    426             BTTRC_DBG2(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v)
    427 #define BTTRC_AVDT_SCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)  \
    428             BTTRC_DBG3(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    429 #define BTTRC_AVDT_SCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)  \
    430             BTTRC_DBG4(BTTRC_ID_AVDT_SCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    431 #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)  \
    432             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)
    433 #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)  \
    434             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)
    435 /***************************************************************************************/
    436 /*AVDT_CCB MACROS */
    437 
    438 #define BTTRC_AVDT_CCB_EVENT(event, state)   \
    439             BTTRC_EVENT(BTTRC_ID_AVDT_CCB, event, state)
    440 #define BTTRC_AVDT_CCB_ACTION(action)  \
    441             BTTRC_ACTION(BTTRC_ID_AVDT_CCB, action)
    442 #define BTTRC_AVDT_CCB_STATE(next_state)   \
    443             BTTRC_STATE(BTTRC_ID_AVDT_CCB, next_state)
    444 
    445 #define BTTRC_AVDT_CCB_DBG0(dbg)  \
    446             BTTRC_DBG0(BTTRC_ID_AVDT_CCB, dbg)
    447 #define BTTRC_AVDT_CCB_DBG1(dbg, p1_t,p1_v)  \
    448             BTTRC_DBG1(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v)
    449 #define BTTRC_AVDT_CCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)  \
    450             BTTRC_DBG2(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v)
    451 #define BTTRC_AVDT_CCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)  \
    452             BTTRC_DBG3(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    453 #define BTTRC_AVDT_CCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)  \
    454             BTTRC_DBG4(BTTRC_ID_AVDT_CCB, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    455 #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)  \
    456             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)
    457 #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)  \
    458             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)
    459 /***************************************************************************************/
    460 
    461 #else /*BTTRC_INCLUDED*/
    462 
    463 /***************************************************************************************/
    464 /* BTTRC MACROS */
    465 
    466 #define BTTRC_EVENT(lid, event, state)
    467 #define BTTRC_ACTION(lid, action)
    468 #define BTTRC_STATE(lid, state)
    469 
    470 #define BTTRC_API0(lid, api)
    471 #define BTTRC_API1(lid, api, p1_t, p1_v)
    472 #define BTTRC_API2(lid, api, p1_t, p1_v, p2_t, p2_v)
    473 #define BTTRC_API3(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    474 #define BTTRC_API4(lid, api, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    475 #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)
    476 #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)
    477 
    478 
    479 #define BTTRC_DBG0(lid, dbg)
    480 #define BTTRC_DBG1(lid, dbg, p1_t,p1_v)
    481 #define BTTRC_DBG2(lid, dbg, p1_t,p1_v,p2_t,p2_v)
    482 #define BTTRC_DBG3(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    483 #define BTTRC_DBG4(lid, dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    484 #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)
    485 #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)
    486 
    487 /***************************************************************************************/
    488 /*AVDT MACROS */
    489 #define BTTRC_AVDT_API0(api)
    490 #define BTTRC_AVDT_API1(api, p1_t,p1_v)
    491 #define BTTRC_AVDT_API2(api, p1_t,p1_v,p2_t,p2_v)
    492 /***************************************************************************************/
    493 /*AVDT_SCB MACROS */
    494 
    495 #define BTTRC_AVDT_SCB_EVENT(event, state)
    496 #define BTTRC_AVDT_SCB_ACTION(action)
    497 #define BTTRC_AVDT_SCB_STATE(next_state)
    498 
    499 #define BTTRC_AVDT_SCB_DBG0(dbg)
    500 #define BTTRC_AVDT_SCB_DBG1(dbg, p1_t,p1_v)
    501 #define BTTRC_AVDT_SCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)
    502 #define BTTRC_AVDT_SCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    503 #define BTTRC_AVDT_SCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    504 #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)
    505 #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)
    506 
    507 /***************************************************************************************/
    508 /*AVDT_CCB MACROS */
    509 
    510 #define BTTRC_AVDT_CCB_EVENT(event, state)
    511 #define BTTRC_AVDT_CCB_ACTION(action)
    512 #define BTTRC_AVDT_CCB_STATE(next_state)
    513 
    514 #define BTTRC_AVDT_CCB_DBG0(dbg)
    515 #define BTTRC_AVDT_CCB_DBG1(dbg, p1_t,p1_v)
    516 #define BTTRC_AVDT_CCB_DBG2(dbg, p1_t,p1_v,p2_t,p2_v)
    517 #define BTTRC_AVDT_CCB_DBG3(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v)
    518 #define BTTRC_AVDT_CCB_DBG4(dbg, p1_t,p1_v,p2_t,p2_v,p3_t,p3_v,p4_t,p4_v)
    519 #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)
    520 #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)
    521 
    522 /***************************************************************************************/
    523 
    524 #endif /*BTTRC_INCLUDED*/
    525 
    526 
    527 #if (BT_USE_TRACES == TRUE)
    528 
    529 #define BT_TRACE(l,t,...)                        LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__)
    530 #define BT_ERROR_TRACE(l,...)                    LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, ##__VA_ARGS__)
    531 
    532 /* Define tracing for the HCI unit
    533 */
    534 
    535 #define HCI_TRACE_ERROR(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    536 #define HCI_TRACE_WARNING(...)                   {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    537 #define HCI_TRACE_EVENT(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    538 #define HCI_TRACE_DEBUG(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    539 
    540 
    541 /* Define tracing for BTM
    542 */
    543 #define BTM_TRACE_ERROR(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    544 #define BTM_TRACE_WARNING(...)                   {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    545 #define BTM_TRACE_API(...)                       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_API, ##__VA_ARGS__);}
    546 #define BTM_TRACE_EVENT(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    547 #define BTM_TRACE_DEBUG(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    548 
    549 
    550 /* Define tracing for the L2CAP unit
    551 */
    552 #define L2CAP_TRACE_ERROR(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    553 #define L2CAP_TRACE_WARNING(...)                 {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    554 #define L2CAP_TRACE_API(...)                     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    555 #define L2CAP_TRACE_EVENT(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    556 #define L2CAP_TRACE_DEBUG(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    557 
    558 /* Define tracing for the SDP unit
    559 */
    560 #define SDP_TRACE_ERROR(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    561 #define SDP_TRACE_WARNING(...)                   {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    562 #define SDP_TRACE_API(...)                       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, ##__VA_ARGS__);}
    563 #define SDP_TRACE_EVENT(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    564 #define SDP_TRACE_DEBUG(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    565 
    566 /* Define tracing for the RFCOMM unit
    567 */
    568 #define RFCOMM_TRACE_ERROR(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    569 #define RFCOMM_TRACE_WARNING(...)                {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    570 #define RFCOMM_TRACE_API(...)                    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, ##__VA_ARGS__);}
    571 #define RFCOMM_TRACE_EVENT(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    572 #define RFCOMM_TRACE_DEBUG(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    573 
    574 /* Generic Access Profile traces */
    575 #define GAP_TRACE_ERROR(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    576 #define GAP_TRACE_EVENT(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    577 #define GAP_TRACE_API(...)                       {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    578 #define GAP_TRACE_WARNING(...)                   {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    579 
    580 /* define traces for HID Host */
    581 #define HIDH_TRACE_ERROR(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    582 #define HIDH_TRACE_WARNING(...)                   {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    583 #define HIDH_TRACE_API(...)                       {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, ##__VA_ARGS__);}
    584 #define HIDH_TRACE_EVENT(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    585 #define HIDH_TRACE_DEBUG(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    586 
    587 /* define traces for BNEP */
    588 
    589 #define BNEP_TRACE_ERROR(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    590 #define BNEP_TRACE_WARNING(...)                   {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    591 #define BNEP_TRACE_API(...)                       {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, ##__VA_ARGS__);}
    592 #define BNEP_TRACE_EVENT(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    593 #define BNEP_TRACE_DEBUG(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    594 
    595 /* define traces for PAN */
    596 
    597 #define PAN_TRACE_ERROR(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    598 #define PAN_TRACE_WARNING(...)                   {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    599 #define PAN_TRACE_API(...)                       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, ##__VA_ARGS__);}
    600 #define PAN_TRACE_EVENT(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    601 #define PAN_TRACE_DEBUG(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    602 
    603 /* Define tracing for the A2DP profile
    604 */
    605 #define A2D_TRACE_ERROR(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,##__VA_ARGS__);}
    606 #define A2D_TRACE_WARNING(...)                    {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,##__VA_ARGS__);}
    607 #define A2D_TRACE_EVENT(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,##__VA_ARGS__);}
    608 #define A2D_TRACE_DEBUG(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,##__VA_ARGS__);}
    609 #define A2D_TRACE_API(...)                        {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,##__VA_ARGS__);}
    610 
    611 /* AVDTP
    612 */
    613 #define AVDT_TRACE_ERROR(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    614 #define AVDT_TRACE_WARNING(...)                   {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    615 #define AVDT_TRACE_EVENT(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    616 #define AVDT_TRACE_DEBUG(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    617 #define AVDT_TRACE_API(...)                       {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    618 
    619 /* Define tracing for the AVCTP protocol
    620 */
    621 #define AVCT_TRACE_ERROR(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    622 #define AVCT_TRACE_WARNING(...)                   {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    623 #define AVCT_TRACE_EVENT(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    624 #define AVCT_TRACE_DEBUG(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    625 #define AVCT_TRACE_API(...)                       {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    626 
    627 /* Define tracing for the AVRCP profile
    628 */
    629 #define AVRC_TRACE_ERROR(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    630 #define AVRC_TRACE_WARNING(...)                    {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    631 #define AVRC_TRACE_EVENT(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    632 #define AVRC_TRACE_DEBUG(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    633 #define AVRC_TRACE_API(...)                        {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    634 
    635 /* MCAP
    636 */
    637 #define MCA_TRACE_ERROR(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    638 #define MCA_TRACE_WARNING(...)                   {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    639 #define MCA_TRACE_EVENT(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    640 #define MCA_TRACE_DEBUG(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    641 #define MCA_TRACE_API(...)                       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, ##__VA_ARGS__);}
    642 
    643 /* Define tracing for the ATT/GATT unit
    644 */
    645 #define GATT_TRACE_ERROR(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    646 #define GATT_TRACE_WARNING(...)                   {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    647 #define GATT_TRACE_API(...)                       {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, ##__VA_ARGS__);}
    648 #define GATT_TRACE_EVENT(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    649 #define GATT_TRACE_DEBUG(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    650 
    651 /* Define tracing for the SMP unit
    652 */
    653 #define SMP_TRACE_ERROR(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    654 #define SMP_TRACE_WARNING(...)                   {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    655 #define SMP_TRACE_API(...)                       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, ##__VA_ARGS__);}
    656 #define SMP_TRACE_EVENT(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    657 #define SMP_TRACE_DEBUG(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    658 
    659 /* END OF USE TRACES */
    660 #else
    661 
    662 #define BT_TRACE(l,t,...)
    663 #define BT_BT_ERROR_TRACE(l,...)
    664 
    665 /* Define tracing for the HCI unit
    666 */
    667 #define HCI_TRACE_ERROR(...)
    668 #define HCI_TRACE_WARNING(...)
    669 #define HCI_TRACE_EVENT(...)
    670 #define HCI_TRACE_DEBUG(...)
    671 
    672 
    673 /* Define tracing for BTM
    674 */
    675 #define BTM_TRACE_ERROR(...)
    676 #define BTM_TRACE_WARNING(...)
    677 #define BTM_TRACE_API(...)
    678 #define BTM_TRACE_EVENT(...)
    679 #define BTM_TRACE_DEBUG(...)
    680 
    681 
    682 /* Define tracing for the L2CAP unit
    683 */
    684 #define L2CAP_TRACE_ERROR(...)
    685 #define L2CAP_TRACE_WARNING(...)
    686 #define L2CAP_TRACE_API(...)
    687 #define L2CAP_TRACE_EVENT(...)
    688 #define L2CAP_TRACE_DEBUG(...)
    689 
    690 /* Define tracing for the SDP unit
    691 */
    692 #define SDP_TRACE_ERROR(...)
    693 #define SDP_TRACE_WARNING(...)
    694 #define SDP_TRACE_API(...)
    695 #define SDP_TRACE_EVENT(...)
    696 #define SDP_TRACE_DEBUG(...)
    697 
    698 /* Define tracing for the RFCOMM unit
    699 */
    700 #define RFCOMM_TRACE_ERROR(...)
    701 #define RFCOMM_TRACE_WARNING(...)
    702 #define RFCOMM_TRACE_API(...)
    703 #define RFCOMM_TRACE_EVENT(...)
    704 #define RFCOMM_TRACE_DEBUG(...)
    705 
    706 /* Generic Access Profile traces */
    707 #define GAP_TRACE_ERROR(...)
    708 #define GAP_TRACE_EVENT(...)
    709 #define GAP_TRACE_API(...)
    710 #define GAP_TRACE_WARNING(...)
    711 
    712 /* define traces for HID Host */
    713 #define HIDH_TRACE_ERROR(...)
    714 #define HIDH_TRACE_WARNING(...)
    715 #define HIDH_TRACE_API(...)
    716 #define HIDH_TRACE_EVENT(...)
    717 #define HIDH_TRACE_DEBUG(...)
    718 
    719 /* define traces for BNEP */
    720 
    721 #define BNEP_TRACE_ERROR(...)
    722 #define BNEP_TRACE_WARNING(...)
    723 #define BNEP_TRACE_API(...)
    724 #define BNEP_TRACE_EVENT(...)
    725 #define BNEP_TRACE_DEBUG(...)
    726 
    727 /* define traces for PAN */
    728 
    729 #define PAN_TRACE_ERROR(...)
    730 #define PAN_TRACE_WARNING(...)
    731 #define PAN_TRACE_API(...)
    732 #define PAN_TRACE_EVENT(...)
    733 #define PAN_TRACE_DEBUG(...)
    734 
    735 /* Define tracing for the A2DP profile
    736 */
    737 #define A2D_TRACE_ERROR(...)
    738 #define A2D_TRACE_WARNING(...)
    739 #define A2D_TRACE_EVENT(...)
    740 #define A2D_TRACE_DEBUG(...)
    741 #define A2D_TRACE_API(...)
    742 
    743 /* AVDTP
    744 */
    745 #define AVDT_TRACE_ERROR(...)
    746 #define AVDT_TRACE_WARNING(...)
    747 #define AVDT_TRACE_EVENT(...)
    748 #define AVDT_TRACE_DEBUG(...)
    749 #define AVDT_TRACE_API(...)
    750 
    751 /* Define tracing for the AVCTP protocol
    752 */
    753 #define AVCT_TRACE_ERROR(...)
    754 #define AVCT_TRACE_WARNING(...)
    755 #define AVCT_TRACE_EVENT(...)
    756 #define AVCT_TRACE_DEBUG(...)
    757 #define AVCT_TRACE_API(...)
    758 
    759 /* Define tracing for the AVRCP profile
    760 */
    761 #define AVRC_TRACE_ERROR(...)
    762 #define AVRC_TRACE_WARNING(...)
    763 #define AVRC_TRACE_EVENT(...)
    764 #define AVRC_TRACE_DEBUG(...)
    765 #define AVRC_TRACE_API(...)
    766 
    767 /* MCAP
    768 */
    769 #define MCA_TRACE_ERROR(...)
    770 #define MCA_TRACE_WARNING(...)
    771 #define MCA_TRACE_EVENT(...)
    772 #define MCA_TRACE_DEBUG(...)
    773 #define MCA_TRACE_API(...)
    774 
    775 /* Define tracing for the GATT
    776 */
    777 #define GATT_TRACE_ERROR(...)
    778 #define GATT_TRACE_WARNING(...)
    779 #define GATT_TRACE_API(...)
    780 #define GATT_TRACE_EVENT(...)
    781 #define GATT_TRACE_DEBUG(...)
    782 
    783 /* Define tracing for the SMP unit
    784 */
    785 #define SMP_TRACE_ERROR(...)
    786 #define SMP_TRACE_WARNING(...)
    787 #define SMP_TRACE_API(...)
    788 #define SMP_TRACE_EVENT(...)
    789 #define SMP_TRACE_DEBUG(...)
    790 
    791 #endif
    792 
    793 #if (BT_TRACE_BTIF == TRUE)
    794 
    795 extern UINT8 btif_trace_level;
    796 
    797 /* define traces for application */
    798 #define BTIF_TRACE_ERROR(...)                    {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    799 #define BTIF_TRACE_WARNING(...)                  {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    800 #define BTIF_TRACE_API(...)                      {if (btif_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, ##__VA_ARGS__);}
    801 #define BTIF_TRACE_EVENT(...)                    {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    802 #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__);}
    803 #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__);}
    804 
    805 #else
    806 /* define traces for Application */
    807 
    808 #define BTIF_TRACE_ERROR(...)
    809 #define BTIF_TRACE_WARNING(...)
    810 #define BTIF_TRACE_API(...)
    811 #define BTIF_TRACE_EVENT(...)
    812 #define BTIF_TRACE_DEBUG(...)
    813 #define BTIF_TRACE_VERBOSE(...)
    814 
    815 #endif
    816 
    817 
    818 #if (BT_USE_TRACES == TRUE || BT_TRACE_APPL == TRUE)
    819 
    820 /* define traces for application */
    821 #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__);}
    822 #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__);}
    823 #define APPL_TRACE_API(...)                      {if (appl_trace_level >= BT_TRACE_LEVEL_API) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_API, ##__VA_ARGS__);}
    824 #define APPL_TRACE_EVENT(...)                    {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    825 #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__);}
    826 #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__);}
    827 
    828 #else
    829 /* define traces for Application */
    830 
    831 #define APPL_TRACE_ERROR(...)
    832 #define APPL_TRACE_WARNING(...)
    833 #define APPL_TRACE_API(...)
    834 #define APPL_TRACE_EVENT(...)
    835 #define APPL_TRACE_DEBUG(...)
    836 #define APPL_TRACE_VERBOSE(...)
    837 
    838 #endif
    839 
    840 /* Simplified Trace Helper Macro
    841 */
    842 #if (BT_USE_TRACES == TRUE)
    843 #define bdld(fmt, ...) \
    844     do{\
    845         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    846             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_DEBUG, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    847     }while(0)
    848 
    849 #define bdlw(fmt, ...) \
    850     do{\
    851         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    852             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_WARNING, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    853     }while(0)
    854 
    855 #define bdle(fmt, ...) \
    856     do{\
    857         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    858             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    859     }while(0)
    860 
    861 #define bdla(assert_if) \
    862     do{\
    863         if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
    864             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): assert failed: " #assert_if, __FUNCTION__, __LINE__); \
    865     }while(0)
    866 #else
    867 #define bdld(fmt, ...)  ((void)0) /*Empty statement as placeholder*/
    868 #define bdlw(fmt, ...)  ((void)0)
    869 #define bdle(fmt, ...)  ((void)0)
    870 #define bdla(assert_if) ((void)0)
    871 #endif
    872 #endif /* BT_TRACE_H */
    873