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 /* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
    107 #define BTTRC_ID_STK_RFCOMM                82
    108 #define BTTRC_ID_STK_RFCOMM_DATA           83
    109 #define BTTRC_ID_STK_OBEX                  84
    110 #define BTTRC_ID_STK_A2D                   85
    111 #define BTTRC_ID_STK_BIP                   86
    112 
    113 /* LayerIDs for BT APP */
    114 #define BTTRC_ID_BTAPP                     87
    115 #define BTTRC_ID_BT_PROTOCOL               88         /* this is a temporary solution to allow dynamic
    116                                                          enable/disable of BT_PROTOCOL_TRACE */
    117 #define BTTRC_ID_MAX_ID                    BTTRC_ID_BT_PROTOCOL
    118 #define BTTRC_ID_ALL_LAYERS                0xFF       /* all trace layers */
    119 /* Parameter datatypes used in Trace APIs */
    120 #define BTTRC_PARAM_UINT8                  1
    121 #define BTTRC_PARAM_UINT16                 2
    122 #define BTTRC_PARAM_UINT32                 3
    123 
    124 /* Enables or disables verbose trace information. */
    125 #ifndef BT_TRACE_VERBOSE
    126 #define BT_TRACE_VERBOSE    FALSE
    127 #endif
    128 
    129 /* Enables or disables all trace messages. */
    130 #ifndef BT_USE_TRACES
    131 #define BT_USE_TRACES       TRUE
    132 #endif
    133 
    134 /******************************************************************************
    135 **
    136 ** Trace Levels
    137 **
    138 ** The following values may be used for different levels:
    139 **      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
    140 **      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
    141 **      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
    142 **      BT_TRACE_LEVEL_API     3        * API traces
    143 **      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
    144 **      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
    145 ******************************************************************************/
    146 
    147 /* Core Stack default trace levels */
    148 #ifndef HCI_INITIAL_TRACE_LEVEL
    149 #define HCI_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    150 #endif
    151 
    152 #ifndef BTM_INITIAL_TRACE_LEVEL
    153 #define BTM_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    154 #endif
    155 
    156 #ifndef L2CAP_INITIAL_TRACE_LEVEL
    157 #define L2CAP_INITIAL_TRACE_LEVEL           BT_TRACE_LEVEL_WARNING
    158 #endif
    159 
    160 #ifndef RFCOMM_INITIAL_TRACE_LEVEL
    161 #define RFCOMM_INITIAL_TRACE_LEVEL          BT_TRACE_LEVEL_WARNING
    162 #endif
    163 
    164 #ifndef SDP_INITIAL_TRACE_LEVEL
    165 #define SDP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    166 #endif
    167 
    168 #ifndef GAP_INITIAL_TRACE_LEVEL
    169 #define GAP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    170 #endif
    171 
    172 #ifndef BNEP_INITIAL_TRACE_LEVEL
    173 #define BNEP_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    174 #endif
    175 
    176 #ifndef PAN_INITIAL_TRACE_LEVEL
    177 #define PAN_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    178 #endif
    179 
    180 #ifndef A2D_INITIAL_TRACE_LEVEL
    181 #define A2D_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    182 #endif
    183 
    184 #ifndef AVDT_INITIAL_TRACE_LEVEL
    185 #define AVDT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    186 #endif
    187 
    188 #ifndef AVCT_INITIAL_TRACE_LEVEL
    189 #define AVCT_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    190 #endif
    191 
    192 #ifndef AVRC_INITIAL_TRACE_LEVEL
    193 #define AVRC_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    194 #endif
    195 
    196 #ifndef MCA_INITIAL_TRACE_LEVEL
    197 #define MCA_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    198 #endif
    199 
    200 #ifndef HID_INITIAL_TRACE_LEVEL
    201 #define HID_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    202 #endif
    203 
    204 #ifndef APPL_INITIAL_TRACE_LEVEL
    205 #define APPL_INITIAL_TRACE_LEVEL            BT_TRACE_LEVEL_WARNING
    206 #endif
    207 
    208 #ifndef BT_TRACE_APPL
    209 #define BT_TRACE_APPL   BT_USE_TRACES
    210 #endif
    211 
    212 #ifndef GATT_INITIAL_TRACE_LEVEL
    213 #define GATT_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    214 #endif
    215 
    216 #ifndef SMP_INITIAL_TRACE_LEVEL
    217 #define SMP_INITIAL_TRACE_LEVEL             BT_TRACE_LEVEL_WARNING
    218 #endif
    219 
    220 #define BT_TRACE(l,t,...)                        LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__)
    221 #define BT_ERROR_TRACE(l,...)                    LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, ##__VA_ARGS__)
    222 
    223 /* Define tracing for the HCI unit
    224 */
    225 
    226 #define HCI_TRACE_ERROR(...)                     {if (btu_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    227 #define HCI_TRACE_WARNING(...)                   {if (btu_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    228 #define HCI_TRACE_EVENT(...)                     {if (btu_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    229 #define HCI_TRACE_DEBUG(...)                     {if (btu_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    230 
    231 
    232 /* Define tracing for BTM
    233 */
    234 #define BTM_TRACE_ERROR(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    235 #define BTM_TRACE_WARNING(...)                   {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    236 #define BTM_TRACE_API(...)                       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_API, ##__VA_ARGS__);}
    237 #define BTM_TRACE_EVENT(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    238 #define BTM_TRACE_DEBUG(...)                     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    239 
    240 
    241 /* Define tracing for the L2CAP unit
    242 */
    243 #define L2CAP_TRACE_ERROR(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    244 #define L2CAP_TRACE_WARNING(...)                 {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    245 #define L2CAP_TRACE_API(...)                     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    246 #define L2CAP_TRACE_EVENT(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    247 #define L2CAP_TRACE_DEBUG(...)                   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    248 
    249 /* Define tracing for the SDP unit
    250 */
    251 #define SDP_TRACE_ERROR(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    252 #define SDP_TRACE_WARNING(...)                   {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    253 #define SDP_TRACE_API(...)                       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, ##__VA_ARGS__);}
    254 #define SDP_TRACE_EVENT(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    255 #define SDP_TRACE_DEBUG(...)                     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    256 
    257 /* Define tracing for the RFCOMM unit
    258 */
    259 #define RFCOMM_TRACE_ERROR(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    260 #define RFCOMM_TRACE_WARNING(...)                {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    261 #define RFCOMM_TRACE_API(...)                    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, ##__VA_ARGS__);}
    262 #define RFCOMM_TRACE_EVENT(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    263 #define RFCOMM_TRACE_DEBUG(...)                  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    264 
    265 /* Generic Access Profile traces */
    266 #define GAP_TRACE_ERROR(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    267 #define GAP_TRACE_EVENT(...)                     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    268 #define GAP_TRACE_API(...)                       {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_API, ##__VA_ARGS__);}
    269 #define GAP_TRACE_WARNING(...)                   {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_GAP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    270 
    271 /* define traces for HID Host */
    272 #define HIDH_TRACE_ERROR(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    273 #define HIDH_TRACE_WARNING(...)                   {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    274 #define HIDH_TRACE_API(...)                       {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, ##__VA_ARGS__);}
    275 #define HIDH_TRACE_EVENT(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    276 #define HIDH_TRACE_DEBUG(...)                     {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    277 
    278 /* define traces for BNEP */
    279 
    280 #define BNEP_TRACE_ERROR(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    281 #define BNEP_TRACE_WARNING(...)                   {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    282 #define BNEP_TRACE_API(...)                       {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, ##__VA_ARGS__);}
    283 #define BNEP_TRACE_EVENT(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    284 #define BNEP_TRACE_DEBUG(...)                     {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    285 
    286 /* define traces for PAN */
    287 
    288 #define PAN_TRACE_ERROR(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    289 #define PAN_TRACE_WARNING(...)                   {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    290 #define PAN_TRACE_API(...)                       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, ##__VA_ARGS__);}
    291 #define PAN_TRACE_EVENT(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    292 #define PAN_TRACE_DEBUG(...)                     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    293 
    294 /* Define tracing for the A2DP profile
    295 */
    296 #define A2D_TRACE_ERROR(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_ERROR,##__VA_ARGS__);}
    297 #define A2D_TRACE_WARNING(...)                    {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_WARNING,##__VA_ARGS__);}
    298 #define A2D_TRACE_EVENT(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_EVENT,##__VA_ARGS__);}
    299 #define A2D_TRACE_DEBUG(...)                      {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_DEBUG,##__VA_ARGS__);}
    300 #define A2D_TRACE_API(...)                        {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_A2D, TRACE_TYPE_API,##__VA_ARGS__);}
    301 
    302 /* AVDTP
    303 */
    304 #define AVDT_TRACE_ERROR(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    305 #define AVDT_TRACE_WARNING(...)                   {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    306 #define AVDT_TRACE_EVENT(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    307 #define AVDT_TRACE_DEBUG(...)                     {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    308 #define AVDT_TRACE_API(...)                       {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    309 
    310 /* Define tracing for the AVCTP protocol
    311 */
    312 #define AVCT_TRACE_ERROR(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    313 #define AVCT_TRACE_WARNING(...)                   {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    314 #define AVCT_TRACE_EVENT(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    315 #define AVCT_TRACE_DEBUG(...)                     {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    316 #define AVCT_TRACE_API(...)                       {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    317 
    318 /* Define tracing for the AVRCP profile
    319 */
    320 #define AVRC_TRACE_ERROR(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    321 #define AVRC_TRACE_WARNING(...)                    {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    322 #define AVRC_TRACE_EVENT(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    323 #define AVRC_TRACE_DEBUG(...)                      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    324 #define AVRC_TRACE_API(...)                        {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__);}
    325 
    326 /* MCAP
    327 */
    328 #define MCA_TRACE_ERROR(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    329 #define MCA_TRACE_WARNING(...)                   {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    330 #define MCA_TRACE_EVENT(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    331 #define MCA_TRACE_DEBUG(...)                     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    332 #define MCA_TRACE_API(...)                       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_MCA, TRACE_TYPE_API, ##__VA_ARGS__);}
    333 
    334 /* Define tracing for the ATT/GATT unit
    335 */
    336 #define GATT_TRACE_ERROR(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    337 #define GATT_TRACE_WARNING(...)                   {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    338 #define GATT_TRACE_API(...)                       {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_API, ##__VA_ARGS__);}
    339 #define GATT_TRACE_EVENT(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    340 #define GATT_TRACE_DEBUG(...)                     {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_ATT, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    341 
    342 /* Define tracing for the SMP unit
    343 */
    344 #define SMP_TRACE_ERROR(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, ##__VA_ARGS__);}
    345 #define SMP_TRACE_WARNING(...)                   {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, ##__VA_ARGS__);}
    346 #define SMP_TRACE_API(...)                       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, ##__VA_ARGS__);}
    347 #define SMP_TRACE_EVENT(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, ##__VA_ARGS__);}
    348 #define SMP_TRACE_DEBUG(...)                     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, ##__VA_ARGS__);}
    349 
    350 extern UINT8 btif_trace_level;
    351 
    352 /* define traces for application */
    353 #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__);}
    354 #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__);}
    355 #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__);}
    356 #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__);}
    357 #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__);}
    358 #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__);}
    359 
    360 /* define traces for application */
    361 #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__);}
    362 #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__);}
    363 #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__);}
    364 #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__);}
    365 #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__);}
    366 #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__);}
    367 
    368 /* Simplified Trace Helper Macro
    369 */
    370 #define bdld(fmt, ...) \
    371     do{\
    372         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    373             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_DEBUG, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    374     }while(0)
    375 
    376 #define bdlw(fmt, ...) \
    377     do{\
    378         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    379             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_WARNING, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    380     }while(0)
    381 
    382 #define bdle(fmt, ...) \
    383     do{\
    384         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
    385             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): " fmt, __FUNCTION__, __LINE__,  ## __VA_ARGS__); \
    386     }while(0)
    387 
    388 #define bdla(assert_if) \
    389     do{\
    390         if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
    391             LogMsg((MY_LOG_LAYER) | TRACE_TYPE_ERROR, "%s(L%d): assert failed: " #assert_if, __FUNCTION__, __LINE__); \
    392     }while(0)
    393 
    394 typedef UINT8 tBTTRC_PARAM_TYPE;
    395 typedef UINT8 tBTTRC_LAYER_ID;
    396 typedef UINT8 tBTTRC_TYPE;
    397 
    398 typedef struct {
    399     tBTTRC_LAYER_ID layer_id;
    400     tBTTRC_TYPE     type;      /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
    401 } tBTTRC_LEVEL;
    402 
    403 typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
    404 
    405 typedef struct {
    406     const tBTTRC_LAYER_ID         layer_id_start;
    407     const tBTTRC_LAYER_ID         layer_id_end;
    408     tBTTRC_SET_TRACE_LEVEL        *p_f;
    409     const char                    *trc_name;
    410     UINT8                         trace_level;
    411 } tBTTRC_FUNC_MAP;
    412 
    413 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
    414 extern UINT8 appl_trace_level;
    415 
    416 void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
    417