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 #pragma once
     20 
     21 static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module";
     22 
     23 /* BTE tracing IDs for debug purposes */
     24 /* LayerIDs for stack */
     25 #define BTTRC_ID_STK_GKI                   1
     26 #define BTTRC_ID_STK_BTU                   2
     27 #define BTTRC_ID_STK_HCI                   3
     28 #define BTTRC_ID_STK_L2CAP                 4
     29 #define BTTRC_ID_STK_RFCM_MX               5
     30 #define BTTRC_ID_STK_RFCM_PRT              6
     31 #define BTTRC_ID_STK_OBEX_C                7
     32 #define BTTRC_ID_STK_OBEX_S                8
     33 #define BTTRC_ID_STK_AVCT                  9
     34 #define BTTRC_ID_STK_AVDT                  10
     35 #define BTTRC_ID_STK_AVRC                  11
     36 #define BTTRC_ID_STK_BIC                   12
     37 #define BTTRC_ID_STK_BIS                   13
     38 #define BTTRC_ID_STK_BNEP                  14
     39 #define BTTRC_ID_STK_BPP                   15
     40 #define BTTRC_ID_STK_BTM_ACL               16
     41 #define BTTRC_ID_STK_BTM_PM                17
     42 #define BTTRC_ID_STK_BTM_DEV_CTRL          18
     43 #define BTTRC_ID_STK_BTM_SVC_DSC           19
     44 #define BTTRC_ID_STK_BTM_INQ               20
     45 #define BTTRC_ID_STK_BTM_SCO               21
     46 #define BTTRC_ID_STK_BTM_SEC               22
     47 #define BTTRC_ID_STK_HID                   24
     48 #define BTTRC_ID_STK_HSP2                  25
     49 #define BTTRC_ID_STK_CTP                   26
     50 #define BTTRC_ID_STK_FTC                   27
     51 #define BTTRC_ID_STK_FTS                   28
     52 #define BTTRC_ID_STK_GAP                   29
     53 #define BTTRC_ID_STK_HCRP                  31
     54 #define BTTRC_ID_STK_ICP                   32
     55 #define BTTRC_ID_STK_OPC                   33
     56 #define BTTRC_ID_STK_OPS                   34
     57 #define BTTRC_ID_STK_PAN                   35
     58 #define BTTRC_ID_STK_SAP                   36
     59 #define BTTRC_ID_STK_SDP                   37
     60 #define BTTRC_ID_STK_SLIP                  38
     61 #define BTTRC_ID_STK_SPP                   39
     62 #define BTTRC_ID_STK_TCS                   40
     63 #define BTTRC_ID_STK_VDP                   41
     64 #define BTTRC_ID_STK_MCAP                  42
     65 #define BTTRC_ID_STK_GATT                  43
     66 #define BTTRC_ID_STK_SMP                   44
     67 #define BTTRC_ID_STK_NFC                   45
     68 #define BTTRC_ID_STK_NCI                   46
     69 #define BTTRC_ID_STK_IDEP                  47
     70 #define BTTRC_ID_STK_NDEP                  48
     71 #define BTTRC_ID_STK_LLCP                  49
     72 #define BTTRC_ID_STK_RW                    50
     73 #define BTTRC_ID_STK_CE                    51
     74 #define BTTRC_ID_STK_SNEP                  52
     75 #define BTTRC_ID_STK_NDEF                  53
     76 
     77 /* LayerIDs for BTA */
     78 #define BTTRC_ID_BTA_ACC                   55         /* Advanced Camera Client */
     79 #define BTTRC_ID_BTA_AG                    56         /* audio gateway */
     80 #define BTTRC_ID_BTA_AV                    57         /* Advanced audio */
     81 #define BTTRC_ID_BTA_BIC                   58         /* Basic Imaging Client */
     82 #define BTTRC_ID_BTA_BIS                   59         /* Basic Imaging Server */
     83 #define BTTRC_ID_BTA_BP                    60         /* Basic Printing Client */
     84 #define BTTRC_ID_BTA_CG                    61
     85 #define BTTRC_ID_BTA_CT                    62         /* cordless telephony terminal */
     86 #define BTTRC_ID_BTA_DG                    63         /* data gateway */
     87 #define BTTRC_ID_BTA_DM                    64         /* device manager */
     88 #define BTTRC_ID_BTA_DM_SRCH               65         /* device manager search */
     89 #define BTTRC_ID_BTA_DM_SEC                66         /* device manager security */
     90 #define BTTRC_ID_BTA_FM                    67
     91 #define BTTRC_ID_BTA_FTC                   68         /* file transfer client */
     92 #define BTTRC_ID_BTA_FTS                   69         /* file transfer server */
     93 #define BTTRC_ID_BTA_HIDH                  70
     94 #define BTTRC_ID_BTA_HIDD                  71
     95 #define BTTRC_ID_BTA_JV                    72
     96 #define BTTRC_ID_BTA_OPC                   73         /* object push client */
     97 #define BTTRC_ID_BTA_OPS                   74         /* object push server */
     98 #define BTTRC_ID_BTA_PAN                   75         /* Personal Area Networking */
     99 #define BTTRC_ID_BTA_PR                    76         /* Printer client */
    100 #define BTTRC_ID_BTA_SC                    77         /* SIM Card Access server */
    101 #define BTTRC_ID_BTA_SS                    78         /* synchronization server */
    102 #define BTTRC_ID_BTA_SYS                   79         /* system manager */
    103 #define BTTRC_ID_AVDT_SCB                  80         /* avdt scb */
    104 #define BTTRC_ID_AVDT_CCB                  81         /* avdt ccb */
    105 
    106 // btla-specific ++
    107 /* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
    108 #define BTTRC_ID_STK_RFCOMM                82
    109 #define BTTRC_ID_STK_RFCOMM_DATA           83
    110 #define BTTRC_ID_STK_OBEX                  84
    111 #define BTTRC_ID_STK_A2D                   85
    112 #define BTTRC_ID_STK_BIP                   86
    113 
    114 /* LayerIDs for BT APP */
    115 #define BTTRC_ID_BTAPP                     87
    116 #define BTTRC_ID_BT_PROTOCOL               88         /* this is a temporary solution to allow dynamic
    117                                                          enable/disable of BT_PROTOCOL_TRACE */
    118 #define BTTRC_ID_MAX_ID                    BTTRC_ID_BT_PROTOCOL
    119 // btla-specific --
    120 #define BTTRC_ID_ALL_LAYERS                0xFF       /* all trace layers */
    121 /* Parameter datatypes used in Trace APIs */
    122 #define BTTRC_PARAM_UINT8                  1
    123 #define BTTRC_PARAM_UINT16                 2
    124 #define BTTRC_PARAM_UINT32                 3
    125 
    126 /* Enables or disables verbose trace information. */
    127 #ifndef BT_TRACE_VERBOSE
    128 #define BT_TRACE_VERBOSE    FALSE
    129 #endif
    130 
    131 /* Enables or disables all trace messages. */
    132 #ifndef BT_USE_TRACES
    133 #define BT_USE_TRACES       TRUE
    134 #endif
    135 
    136 /******************************************************************************
    137 **
    138 ** Trace Levels
    139 **
    140 ** The following values may be used for different levels:
    141 **      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
    142 **      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
    143 **      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
    144 **      BT_TRACE_LEVEL_API     3        * API traces
    145 **      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
    146 **      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
    147 ******************************************************************************/
    148 
    149 // btla-specific ++
    150 /* Core Stack default trace levels */
    151 #ifndef HCI_INITIAL_TRACE_LEVEL
    152 #define HCI_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    153 #endif
    154 
    155 #ifndef BTM_INITIAL_TRACE_LEVEL
    156 #define BTM_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    157 #endif
    158 
    159 #ifndef L2CAP_INITIAL_TRACE_LEVEL
    160 #define L2CAP_INITIAL_TRACE_LEVEL           BT_TRACE_LEVEL_WARNING
    161 #endif
    162 
    163 #ifndef RFCOMM_INITIAL_TRACE_LEVEL
    164 #define RFCOMM_INITIAL_TRACE_LEVEL          BT_TRACE_LEVEL_WARNING
    165 #endif
    166 
    167 #ifndef SDP_INITIAL_TRACE_LEVEL
    168 #define SDP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    169 #endif
    170 
    171 #ifndef GAP_INITIAL_TRACE_LEVEL
    172 #define GAP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    173 #endif
    174 
    175 #ifndef BNEP_INITIAL_TRACE_LEVEL
    176 #define BNEP_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    177 #endif
    178 
    179 #ifndef PAN_INITIAL_TRACE_LEVEL
    180 #define PAN_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    181 #endif
    182 
    183 #ifndef A2D_INITIAL_TRACE_LEVEL
    184 #define A2D_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    185 #endif
    186 
    187 #ifndef AVDT_INITIAL_TRACE_LEVEL
    188 #define AVDT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    189 #endif
    190 
    191 #ifndef AVCT_INITIAL_TRACE_LEVEL
    192 #define AVCT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    193 #endif
    194 
    195 #ifndef AVRC_INITIAL_TRACE_LEVEL
    196 #define AVRC_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    197 #endif
    198 
    199 #ifndef MCA_INITIAL_TRACE_LEVEL
    200 #define MCA_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    201 #endif
    202 
    203 #ifndef HID_INITIAL_TRACE_LEVEL
    204 #define HID_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    205 #endif
    206 
    207 #ifndef APPL_INITIAL_TRACE_LEVEL
    208 #define APPL_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    209 #endif
    210 
    211 #ifndef BT_TRACE_APPL
    212 #define BT_TRACE_APPL   BT_USE_TRACES
    213 #endif
    214 
    215 #ifndef GATT_INITIAL_TRACE_LEVEL
    216 #define GATT_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    217 #endif
    218 
    219 #ifndef SMP_INITIAL_TRACE_LEVEL
    220 #define SMP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    221 #endif
    222 // btla-specific --
    223 
    224 #define BT_TRACE(l,t,...)                        LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__)
    225 #define BT_ERROR_TRACE(l,...)                    LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, ##__VA_ARGS__)
    226 
    227 /* Define tracing for the HCI unit
    228 */
    229 
    230 #define HCI_TRACE_ERROR(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    231 #define HCI_TRACE_WARNING(...)                   {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    232 #define HCI_TRACE_EVENT(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    233 #define HCI_TRACE_DEBUG(...)                     {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    234 
    235 
    236 /* Define tracing for BTM
    237 */
    238 #define BTM_TRACE_ERROR(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    239 #define BTM_TRACE_WARNING(...)                   {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    240 #define BTM_TRACE_API(...)                       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_API, ##__VA_ARGS__);}
    241 #define BTM_TRACE_EVENT(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    242 #define BTM_TRACE_DEBUG(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    243 
    244 
    245 /* Define tracing for the L2CAP unit
    246 */
    247 #define L2CAP_TRACE_ERROR(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    248 #define L2CAP_TRACE_WARNING(...)                 {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    249 #define L2CAP_TRACE_API(...)                     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    250 #define L2CAP_TRACE_EVENT(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    251 #define L2CAP_TRACE_DEBUG(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    252 
    253 /* Define tracing for the SDP unit
    254 */
    255 #define SDP_TRACE_ERROR(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    256 #define SDP_TRACE_WARNING(...)                   {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    257 #define SDP_TRACE_API(...)                       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, ##__VA_ARGS__);}
    258 #define SDP_TRACE_EVENT(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    259 #define SDP_TRACE_DEBUG(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    260 
    261 /* Define tracing for the RFCOMM unit
    262 */
    263 #define RFCOMM_TRACE_ERROR(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    264 #define RFCOMM_TRACE_WARNING(...)                {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    265 #define RFCOMM_TRACE_API(...)                    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, ##__VA_ARGS__);}
    266 #define RFCOMM_TRACE_EVENT(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    267 #define RFCOMM_TRACE_DEBUG(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    268 
    269 /* Generic Access Profile traces */
    270 #define GAP_TRACE_ERROR(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    271 #define GAP_TRACE_EVENT(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    272 #define GAP_TRACE_API(...)                       {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    273 #define GAP_TRACE_WARNING(...)                   {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    274 
    275 /* define traces for HID Host */
    276 #define HIDH_TRACE_ERROR(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    277 #define HIDH_TRACE_WARNING(...)                   {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    278 #define HIDH_TRACE_API(...)                       {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, ##__VA_ARGS__);}
    279 #define HIDH_TRACE_EVENT(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    280 #define HIDH_TRACE_DEBUG(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    281 
    282 /* define traces for BNEP */
    283 
    284 #define BNEP_TRACE_ERROR(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    285 #define BNEP_TRACE_WARNING(...)                   {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    286 #define BNEP_TRACE_API(...)                       {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, ##__VA_ARGS__);}
    287 #define BNEP_TRACE_EVENT(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    288 #define BNEP_TRACE_DEBUG(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    289 
    290 /* define traces for PAN */
    291 
    292 #define PAN_TRACE_ERROR(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    293 #define PAN_TRACE_WARNING(...)                   {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    294 #define PAN_TRACE_API(...)                       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, ##__VA_ARGS__);}
    295 #define PAN_TRACE_EVENT(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    296 #define PAN_TRACE_DEBUG(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    297 
    298 /* Define tracing for the A2DP profile
    299 */
    300 #define A2D_TRACE_ERROR(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,##__VA_ARGS__);}
    301 #define A2D_TRACE_WARNING(...)                    {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,##__VA_ARGS__);}
    302 #define A2D_TRACE_EVENT(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,##__VA_ARGS__);}
    303 #define A2D_TRACE_DEBUG(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,##__VA_ARGS__);}
    304 #define A2D_TRACE_API(...)                        {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,##__VA_ARGS__);}
    305 
    306 /* AVDTP
    307 */
    308 #define AVDT_TRACE_ERROR(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    309 #define AVDT_TRACE_WARNING(...)                   {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    310 #define AVDT_TRACE_EVENT(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    311 #define AVDT_TRACE_DEBUG(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    312 #define AVDT_TRACE_API(...)                       {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    313 
    314 /* Define tracing for the AVCTP protocol
    315 */
    316 #define AVCT_TRACE_ERROR(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    317 #define AVCT_TRACE_WARNING(...)                   {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    318 #define AVCT_TRACE_EVENT(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    319 #define AVCT_TRACE_DEBUG(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    320 #define AVCT_TRACE_API(...)                       {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    321 
    322 /* Define tracing for the AVRCP profile
    323 */
    324 #define AVRC_TRACE_ERROR(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    325 #define AVRC_TRACE_WARNING(...)                    {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    326 #define AVRC_TRACE_EVENT(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    327 #define AVRC_TRACE_DEBUG(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    328 #define AVRC_TRACE_API(...)                        {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    329 
    330 /* MCAP
    331 */
    332 #define MCA_TRACE_ERROR(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    333 #define MCA_TRACE_WARNING(...)                   {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    334 #define MCA_TRACE_EVENT(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    335 #define MCA_TRACE_DEBUG(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    336 #define MCA_TRACE_API(...)                       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, ##__VA_ARGS__);}
    337 
    338 /* Define tracing for the ATT/GATT unit
    339 */
    340 #define GATT_TRACE_ERROR(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    341 #define GATT_TRACE_WARNING(...)                   {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    342 #define GATT_TRACE_API(...)                       {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, ##__VA_ARGS__);}
    343 #define GATT_TRACE_EVENT(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    344 #define GATT_TRACE_DEBUG(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    345 
    346 /* Define tracing for the SMP unit
    347 */
    348 #define SMP_TRACE_ERROR(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    349 #define SMP_TRACE_WARNING(...)                   {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    350 #define SMP_TRACE_API(...)                       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, ##__VA_ARGS__);}
    351 #define SMP_TRACE_EVENT(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    352 #define SMP_TRACE_DEBUG(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    353 
    354 extern UINT8 btif_trace_level;
    355 
    356 /* define traces for application */
    357 #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__);}
    358 #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__);}
    359 #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__);}
    360 #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__);}
    361 #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__);}
    362 #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__);}
    363 
    364 /* define traces for application */
    365 #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__);}
    366 #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__);}
    367 #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__);}
    368 #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__);}
    369 #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__);}
    370 #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__);}
    371 
    372 /* Simplified Trace Helper Macro
    373 */
    374 #define bdld(fmt, ...) \
    375     do{\
    376         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    377             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_DEBUG, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    378     }while(0)
    379 
    380 #define bdlw(fmt, ...) \
    381     do{\
    382         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    383             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_WARNING, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    384     }while(0)
    385 
    386 #define bdle(fmt, ...) \
    387     do{\
    388         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    389             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    390     }while(0)
    391 
    392 #define bdla(assert_if) \
    393     do{\
    394         if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
    395             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): assert failed: " #assert_if, __FUNCTION__, __LINE__); \
    396     }while(0)
    397 
    398 typedef UINT8 tBTTRC_PARAM_TYPE;
    399 typedef UINT8 tBTTRC_LAYER_ID;
    400 typedef UINT8 tBTTRC_TYPE;
    401 
    402 typedef struct {
    403     tBTTRC_LAYER_ID layer_id;
    404     tBTTRC_TYPE     type;      /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
    405 } tBTTRC_LEVEL;
    406 
    407 typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
    408 
    409 typedef struct {
    410     const tBTTRC_LAYER_ID         layer_id_start;
    411     const tBTTRC_LAYER_ID         layer_id_end;
    412     tBTTRC_SET_TRACE_LEVEL        *p_f;
    413     const char                    *trc_name;
    414     UINT8                         trace_level;
    415 } tBTTRC_FUNC_MAP;
    416 
    417 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
    418 extern UINT8 appl_trace_level;
    419