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 #ifndef _BT_TRACE_H_
20 #define _BT_TRACE_H_
21 
22 #include <assert.h>
23 #include <stdio.h>
24 #include "bluedroid_user_config.h"
25 #include "stack/bt_types.h"
26 #include "bt_common.h"
27 
trc_dump_buffer(const char * prefix,uint8_t * data,uint16_t len)28 static inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
29 {
30     uint16_t i;
31 
32     if (!data || !len) {
33         return;
34     }
35 
36     if (prefix) {
37         printf("%s: len %d\r\n", prefix, len);
38     }
39 
40     for (i = 0; i < len; i+=16) {
41         printf("%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x\r\n",
42                 *(data + i), *(data + i + 1), *(data + i + 2), *(data + i + 3), *(data + i + 4), *(data + i + 5), *(data + i + 6), *(data + i + 7),
43                 *(data + i + 8), *(data + i + 9), *(data + i + 10), *(data + i + 11), *(data + i + 12), *(data + i + 13), *(data + i + 14), *(data + i + 15));
44     }
45     printf("\r\n");
46 }
47 
48 #ifdef BTTRC_DUMP_BUFFER
49 #define BTTRC_DUMP_BUFFER(_prefix, _data, _len) trc_dump_buffer(_prefix, _data, _len)
50 #else
51 #define BTTRC_DUMP_BUFFER(_prefix, _data, _len)
52 #endif
53 
54 //static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module";
55 
56 /* BTrgs);E tracing IDs for debug purposes */
57 /* LayerIDs for stack */
58 #define BTTRC_ID_STK_GKI                   1
59 #define BTTRC_ID_STK_BTU                   2
60 #define BTTRC_ID_STK_HCI                   3
61 #define BTTRC_ID_STK_L2CAP                 4
62 #define BTTRC_ID_STK_RFCM_MX               5
63 #define BTTRC_ID_STK_RFCM_PRT              6
64 #define BTTRC_ID_STK_OBEX_C                7
65 #define BTTRC_ID_STK_OBEX_S                8
66 #define BTTRC_ID_STK_AVCT                  9
67 #define BTTRC_ID_STK_AVDT                  10
68 #define BTTRC_ID_STK_AVRC                  11
69 #define BTTRC_ID_STK_BIC                   12
70 #define BTTRC_ID_STK_BIS                   13
71 #define BTTRC_ID_STK_BNEP                  14
72 #define BTTRC_ID_STK_BPP                   15
73 #define BTTRC_ID_STK_BTM_ACL               16
74 #define BTTRC_ID_STK_BTM_PM                17
75 #define BTTRC_ID_STK_BTM_DEV_CTRL          18
76 #define BTTRC_ID_STK_BTM_SVC_DSC           19
77 #define BTTRC_ID_STK_BTM_INQ               20
78 #define BTTRC_ID_STK_BTM_SCO               21
79 #define BTTRC_ID_STK_BTM_SEC               22
80 #define BTTRC_ID_STK_HID                   24
81 #define BTTRC_ID_STK_HSP2                  25
82 #define BTTRC_ID_STK_CTP                   26
83 #define BTTRC_ID_STK_FTC                   27
84 #define BTTRC_ID_STK_FTS                   28
85 #define BTTRC_ID_STK_GAP                   29
86 #define BTTRC_ID_STK_HCRP                  31
87 #define BTTRC_ID_STK_ICP                   32
88 #define BTTRC_ID_STK_OPC                   33
89 #define BTTRC_ID_STK_OPS                   34
90 #define BTTRC_ID_STK_PAN                   35
91 #define BTTRC_ID_STK_SAP                   36
92 #define BTTRC_ID_STK_SDP                   37
93 #define BTTRC_ID_STK_SLIP                  38
94 #define BTTRC_ID_STK_SPP                   39
95 #define BTTRC_ID_STK_TCS                   40
96 #define BTTRC_ID_STK_VDP                   41
97 #define BTTRC_ID_STK_MCAP                  42
98 #define BTTRC_ID_STK_GATT                  43
99 #define BTTRC_ID_STK_SMP                   44
100 #define BTTRC_ID_STK_NFC                   45
101 #define BTTRC_ID_STK_NCI                   46
102 #define BTTRC_ID_STK_IDEP                  47
103 #define BTTRC_ID_STK_NDEP                  48
104 #define BTTRC_ID_STK_LLCP                  49
105 #define BTTRC_ID_STK_RW                    50
106 #define BTTRC_ID_STK_CE                    51
107 #define BTTRC_ID_STK_SNEP                  52
108 #define BTTRC_ID_STK_NDEF                  53
109 #define BTTRC_ID_STK_HIDD                  54
110 
111 /* LayerIDs for BTA */
112 #define BTTRC_ID_BTA_ACC                   55         /* Advanced Camera Client */
113 #define BTTRC_ID_BTA_AG                    56         /* audio gateway */
114 #define BTTRC_ID_BTA_AV                    57         /* Advanced audio */
115 #define BTTRC_ID_BTA_BIC                   58         /* Basic Imaging Client */
116 #define BTTRC_ID_BTA_BIS                   59         /* Basic Imaging Server */
117 #define BTTRC_ID_BTA_BP                    60         /* Basic Printing Client */
118 #define BTTRC_ID_BTA_CG                    61
119 #define BTTRC_ID_BTA_CT                    62         /* cordless telephony terminal */
120 #define BTTRC_ID_BTA_DG                    63         /* data gateway */
121 #define BTTRC_ID_BTA_DM                    64         /* device manager */
122 #define BTTRC_ID_BTA_DM_SRCH               65         /* device manager search */
123 #define BTTRC_ID_BTA_DM_SEC                66         /* device manager security */
124 #define BTTRC_ID_BTA_FM                    67
125 #define BTTRC_ID_BTA_FTC                   68         /* file transfer client */
126 #define BTTRC_ID_BTA_FTS                   69         /* file transfer server */
127 #define BTTRC_ID_BTA_HIDH                  70
128 #define BTTRC_ID_BTA_HIDD                  71
129 #define BTTRC_ID_BTA_JV                    72
130 #define BTTRC_ID_BTA_OPC                   73         /* object push client */
131 #define BTTRC_ID_BTA_OPS                   74         /* object push server */
132 #define BTTRC_ID_BTA_PAN                   75         /* Personal Area Networking */
133 #define BTTRC_ID_BTA_PR                    76         /* Printer client */
134 #define BTTRC_ID_BTA_SC                    77         /* SIM Card Access server */
135 #define BTTRC_ID_BTA_SS                    78         /* synchronization server */
136 #define BTTRC_ID_BTA_SYS                   79         /* system manager */
137 #define BTTRC_ID_AVDT_SCB                  80         /* avdt scb */
138 #define BTTRC_ID_AVDT_CCB                  81         /* avdt ccb */
139 
140 // btla-specific ++
141 /* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
142 #define BTTRC_ID_STK_RFCOMM                82
143 #define BTTRC_ID_STK_RFCOMM_DATA           83
144 #define BTTRC_ID_STK_OBEX                  84
145 #define BTTRC_ID_STK_A2D                   85
146 #define BTTRC_ID_STK_BIP                   86
147 
148 /* LayerIDs for BT APP */
149 #define BTTRC_ID_BTAPP                     87
150 #define BTTRC_ID_BT_PROTOCOL               88         /* this is a temporary solution to allow dynamic
151                                                          enable/disable of BT_PROTOCOL_TRACE */
152 #define BTTRC_ID_MAX_ID                    BTTRC_ID_BT_PROTOCOL
153 // btla-specific --
154 #define BTTRC_ID_ALL_LAYERS                0xFF       /* all trace layers */
155 /* Parameter datatypes used in Trace APIs */
156 #define BTTRC_PARAM_UINT8                  1
157 #define BTTRC_PARAM_UINT16                 2
158 #define BTTRC_PARAM_UINT32                 3
159 
160 /* Enables or disables verbose trace information. */
161 #ifndef BT_TRACE_VERBOSE
162 #define BT_TRACE_VERBOSE    FALSE
163 #endif
164 
165 /* Enables or disables all trace messages. */
166 #ifndef BT_USE_TRACES
167 #define BT_USE_TRACES       FALSE
168 #endif
169 
170 #ifndef BT_TRACE_APPL
171 #define BT_TRACE_APPL   BT_USE_TRACES
172 #endif
173 
174 /******************************************************************************
175 **
176 ** Trace Levels
177 **
178 ** The following values may be used for different levels:
179 **      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
180 **      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
181 **      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
182 **      BT_TRACE_LEVEL_API     3        * API traces
183 **      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
184 **      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
185 ******************************************************************************/
186 
187 // btla-specific ++
188 /* Core Stack default trace levels */
189 #define HCI_INITIAL_TRACE_LEVEL             UC_BT_LOG_HCI_TRACE_LEVEL
190 #define BTM_INITIAL_TRACE_LEVEL             UC_BT_LOG_BTM_TRACE_LEVEL
191 #define L2CAP_INITIAL_TRACE_LEVEL           UC_BT_LOG_L2CAP_TRACE_LEVEL
192 #define RFCOMM_INITIAL_TRACE_LEVEL          UC_BT_LOG_RFCOMM_TRACE_LEVEL
193 #define SDP_INITIAL_TRACE_LEVEL             UC_BT_LOG_SDP_TRACE_LEVEL
194 #define GAP_INITIAL_TRACE_LEVEL             UC_BT_LOG_GAP_TRACE_LEVEL
195 #define BNEP_INITIAL_TRACE_LEVEL            UC_BT_LOG_BNEP_TRACE_LEVEL
196 #define PAN_INITIAL_TRACE_LEVEL             UC_BT_LOG_PAN_TRACE_LEVEL
197 #define A2D_INITIAL_TRACE_LEVEL             UC_BT_LOG_A2D_TRACE_LEVEL
198 #define AVDT_INITIAL_TRACE_LEVEL            UC_BT_LOG_AVDT_TRACE_LEVEL
199 #define AVCT_INITIAL_TRACE_LEVEL            UC_BT_LOG_AVCT_TRACE_LEVEL
200 #define AVRC_INITIAL_TRACE_LEVEL            UC_BT_LOG_AVRC_TRACE_LEVEL
201 #define MCA_INITIAL_TRACE_LEVEL             UC_BT_LOG_MCA_TRACE_LEVEL
202 #define HIDH_INITIAL_TRACE_LEVEL            UC_BT_LOG_HIDH_TRACE_LEVEL
203 #define HIDD_INITIAL_TRACE_LEVEL            UC_BT_LOG_HIDD_TRACE_LEVEL
204 #define APPL_INITIAL_TRACE_LEVEL            UC_BT_LOG_APPL_TRACE_LEVEL
205 #define GATT_INITIAL_TRACE_LEVEL            UC_BT_LOG_GATT_TRACE_LEVEL
206 #define SMP_INITIAL_TRACE_LEVEL             UC_BT_LOG_SMP_TRACE_LEVEL
207 #define BTIF_INITIAL_TRACE_LEVEL            UC_BT_LOG_BTIF_TRACE_LEVEL
208 
209 // btla-specific --
210 
211 #if !UC_BT_STACK_NO_LOG
212 #define LOG_ERROR(format, ... )             {if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)    esp_log_write(ESP_LOG_ERROR,   "BT_LOG", LOG_FORMAT(E, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
213 #define LOG_WARN(format, ... )              {if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN)     esp_log_write(ESP_LOG_WARN,    "BT_LOG", LOG_FORMAT(W, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
214 #define LOG_INFO(format, ... )              {if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO)     esp_log_write(ESP_LOG_INFO,    "BT_LOG", LOG_FORMAT(I, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
215 #define LOG_DEBUG(format, ... )             {if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG)    esp_log_write(ESP_LOG_DEBUG,   "BT_LOG", LOG_FORMAT(D, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
216 #define LOG_VERBOSE(format, ... )           {if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE)  esp_log_write(ESP_LOG_VERBOSE, "BT_LOG", LOG_FORMAT(V, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
217 
218 /* Define tracing for BTM
219 */
220 #define BTM_TRACE_ERROR(fmt, args...)       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTM, ERROR)) BT_PRINT_E("BT_BTM", fmt, ## args);}
221 #define BTM_TRACE_WARNING(fmt, args...)     {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTM, WARNING)) BT_PRINT_W("BT_BTM", fmt, ## args);}
222 #define BTM_TRACE_API(fmt, args...)         {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTM,API)) BT_PRINT_I("BT_BTM", fmt, ## args);}
223 #define BTM_TRACE_EVENT(fmt, args...)       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTM,EVENT)) BT_PRINT_D("BT_BTM", fmt, ## args);}
224 #define BTM_TRACE_DEBUG(fmt, args...)       {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTM,DEBUG)) BT_PRINT_D("BT_BTM", fmt, ## args);}
225 
226 /* Define tracing for the L2CAP unit
227 */
228 #define L2CAP_TRACE_ERROR(fmt, args...)     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(L2CAP, ERROR)) BT_PRINT_E("BT_L2CAP", fmt, ## args);}
229 #define L2CAP_TRACE_WARNING(fmt, args...)   {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(L2CAP, WARNING)) BT_PRINT_W("BT_L2CAP", fmt, ## args);}
230 #define L2CAP_TRACE_API(fmt, args...)       {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(L2CAP,API)) BT_PRINT_I("BT_L2CAP", fmt, ## args);}
231 #define L2CAP_TRACE_EVENT(fmt, args...)     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(L2CAP,EVENT)) BT_PRINT_D("BT_L2CAP", fmt, ## args);}
232 #define L2CAP_TRACE_DEBUG(fmt, args...)     {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(L2CAP,DEBUG)) BT_PRINT_D("BT_L2CAP", fmt, ## args);}
233 
234 /* Define tracing for the SDP unit
235 */
236 #define SDP_TRACE_ERROR(fmt, args...)       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SDP, ERROR)) BT_PRINT_E("BT_SDP", fmt, ## args);}
237 #define SDP_TRACE_WARNING(fmt, args...)     {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SDP, WARNING)) BT_PRINT_W("BT_SDP", fmt, ## args);}
238 #define SDP_TRACE_API(fmt, args...)         {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SDP,API)) BT_PRINT_I("BT_SDP", fmt, ## args);}
239 #define SDP_TRACE_EVENT(fmt, args...)       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SDP,EVENT)) BT_PRINT_D("BT_SDP", fmt, ## args);}
240 #define SDP_TRACE_DEBUG(fmt, args...)       {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SDP,DEBUG)) BT_PRINT_D("BT_SDP", fmt, ## args);}
241 
242 /* Define tracing for the RFCOMM unit
243 */
244 #define RFCOMM_TRACE_ERROR(fmt, args...)    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(RFCOMM, ERROR)) BT_PRINT_E("BT_RFCOMM", fmt, ## args);}
245 #define RFCOMM_TRACE_WARNING(fmt, args...)  {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(RFCOMM, WARNING)) BT_PRINT_W("BT_RFCOMM", fmt, ## args);}
246 #define RFCOMM_TRACE_API(fmt, args...)      {if (rfc_cb.trace_level >=BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(RFCOMM,API)) BT_PRINT_I("BT_RFCOMM", fmt, ## args);}
247 #define RFCOMM_TRACE_EVENT(fmt, args...)    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(RFCOMM,EVENT)) BT_PRINT_D("BT_RFCOMM", fmt, ## args);}
248 #define RFCOMM_TRACE_DEBUG(fmt, args...)    {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(RFCOMM,DEBUG)) BT_PRINT_D("BT_RFCOMM", fmt, ## args);}
249 
250 /* Generic Access Profile traces */
251 #define GAP_TRACE_ERROR(fmt, args...)       {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GAP, ERROR)) BT_PRINT_E("BT_GAP", fmt, ## args);}
252 #define GAP_TRACE_API(fmt, args...)         {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GAP,API)) BT_PRINT_I("BT_GAP", fmt, ## args);}
253 #define GAP_TRACE_EVENT(fmt, args...)       {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GAP,EVENT)) BT_PRINT_D("BT_GAP", fmt, ## args);}
254 #define GAP_TRACE_WARNING(fmt, args...)     {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GAP, WARNING)) BT_PRINT_W("BT_GAP", fmt, ## args);}
255 
256 /* define traces for HID Host */
257 #define HIDH_TRACE_ERROR(fmt, args...)      {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HIDH, ERROR)) BT_PRINT_E("BT_HIDH", fmt, ## args);}
258 #define HIDH_TRACE_WARNING(fmt, args...)    {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HIDH, WARNING)) BT_PRINT_W("BT_HIDH", fmt, ## args);}
259 #define HIDH_TRACE_API(fmt, args...)        {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(HIDH,API)) BT_PRINT_I("BT_HIDH", fmt, ## args);}
260 #define HIDH_TRACE_EVENT(fmt, args...)      {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HIDH,EVENT)) BT_PRINT_D("BT_HIDH", fmt, ## args);}
261 #define HIDH_TRACE_DEBUG(fmt, args...)      {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HIDH,DEBUG)) BT_PRINT_D("BT_HIDH", fmt, ## args);}
262 
263 /* define traces for HID Device */
264 #define HIDD_TRACE_ERROR(fmt, args...)      {if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HIDD, ERROR)) BT_PRINT_E("BT_HIDD", fmt, ## args);}
265 #define HIDD_TRACE_WARNING(fmt, args...)    {if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HIDD, WARNING)) BT_PRINT_W("BT_HIDD", fmt, ## args);}
266 #define HIDD_TRACE_API(fmt, args...)        {if (hd_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(HIDD,API)) BT_PRINT_I("BT_HIDD", fmt, ## args);}
267 #define HIDD_TRACE_EVENT(fmt, args...)      {if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HIDD,EVENT)) BT_PRINT_D("BT_HIDD", fmt, ## args);}
268 #define HIDD_TRACE_DEBUG(fmt, args...)      {if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HIDD,DEBUG)) BT_PRINT_D("BT_HIDD", fmt, ## args);}
269 #define HIDD_TRACE_VERBOSE(fmt, args...)    {if (hd_cb.trace_level >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(HIDD,VERBOSE)) BT_PRINT_D("BT_HIDD", fmt, ## args);}
270 
271 /* define traces for BNEP */
272 
273 #define BNEP_TRACE_ERROR(fmt, args...)      {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BNEP, ERROR)) BT_PRINT_E("BT_BNEP", fmt, ## args);}
274 #define BNEP_TRACE_WARNING(fmt, args...)    {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BNEP, WARNING)) BT_PRINT_W("BT_BNEP", fmt, ## args);}
275 #define BNEP_TRACE_API(fmt, args...)        {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BNEP,API)) BT_PRINT_I("BT_BNEP", fmt, ## args);}
276 #define BNEP_TRACE_EVENT(fmt, args...)      {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BNEP,EVENT)) BT_PRINT_D("BT_BNEP", fmt, ## args);}
277 #define BNEP_TRACE_DEBUG(fmt, args...)      {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BNEP,DEBUG)) BT_PRINT_D("BT_BNEP", fmt, ## args);}
278 
279 /* define traces for PAN */
280 
281 #define PAN_TRACE_ERROR(fmt, args...)       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(PAN, ERROR)) BT_PRINT_E("BT_PAN", fmt, ## args);}
282 #define PAN_TRACE_WARNING(fmt, args...)     {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(PAN, WARNING)) BT_PRINT_W("BT_PAN", fmt, ## args);}
283 #define PAN_TRACE_API(fmt, args...)         {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(PAN,API)) BT_PRINT_I("BT_PAN", fmt, ## args);}
284 #define PAN_TRACE_EVENT(fmt, args...)       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(PAN,EVENT)) BT_PRINT_D("BT_PAN", fmt, ## args);}
285 #define PAN_TRACE_DEBUG(fmt, args...)       {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(PAN,DEBUG)) BT_PRINT_D("BT_PAN", fmt, ## args);}
286 
287 /* Define tracing for the A2DP profile
288 */
289 #define A2D_TRACE_ERROR(fmt, args...)       {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(A2D, ERROR)) BT_PRINT_E("BT_A2D", fmt, ## args);}
290 #define A2D_TRACE_WARNING(fmt, args...)     {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(A2D, WARNING)) BT_PRINT_W("BT_A2D", fmt, ## args);}
291 #define A2D_TRACE_API(fmt, args...)         {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(A2D,API)) BT_PRINT_I("BT_A2D", fmt, ## args);}
292 #define A2D_TRACE_EVENT(fmt, args...)       {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(A2D,EVENT)) BT_PRINT_D("BT_A2D", fmt, ## args);}
293 #define A2D_TRACE_DEBUG(fmt, args...)       {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(A2D,DEBUG)) BT_PRINT_D("BT_A2D", fmt, ## args);}
294 
295 /* AVDTP
296 */
297 #define AVDT_TRACE_ERROR(fmt, args...)      {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVDT, ERROR)) BT_PRINT_E("BT_AVDT", fmt, ## args);}
298 #define AVDT_TRACE_WARNING(fmt, args...)    {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVDT, WARNING)) BT_PRINT_W("BT_AVDT", fmt, ## args);}
299 #define AVDT_TRACE_API(fmt, args...)        {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVDT,API)) BT_PRINT_I("BT_AVDT", fmt, ## args);}
300 #define AVDT_TRACE_EVENT(fmt, args...)      {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVDT,EVENT)) BT_PRINT_D("BT_AVDT", fmt, ## args);}
301 #define AVDT_TRACE_DEBUG(fmt, args...)      {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVDT,DEBUG)) BT_PRINT_D("BT_AVDT", fmt, ## args);}
302 
303 /* Define tracing for the AVCTP protocol
304 */
305 #define AVCT_TRACE_ERROR(fmt, args...)      {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVCT, ERROR)) BT_PRINT_E("BT_AVCT", fmt, ## args);}
306 #define AVCT_TRACE_WARNING(fmt, args...)    {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVCT, WARNING)) BT_PRINT_W("BT_AVCT", fmt, ## args);}
307 #define AVCT_TRACE_API(fmt, args...)        {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVCT,API)) BT_PRINT_I("BT_AVCT", fmt, ## args);}
308 #define AVCT_TRACE_EVENT(fmt, args...)      {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVCT,EVENT)) BT_PRINT_D("BT_AVCT", fmt, ## args);}
309 #define AVCT_TRACE_DEBUG(fmt, args...)      {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVCT,DEBUG)) BT_PRINT_D("BT_AVCT", fmt, ## args);}
310 
311 /* Define tracing for the AVRCP profile
312 */
313 #define AVRC_TRACE_ERROR(fmt, args...)      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(AVRC, ERROR)) BT_PRINT_E("BT_AVRC", fmt, ## args);}
314 #define AVRC_TRACE_WARNING(fmt, args...)    {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(AVRC, WARNING)) BT_PRINT_W("BT_AVRC", fmt, ## args);}
315 #define AVRC_TRACE_API(fmt, args...)        {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(AVRC,API)) BT_PRINT_I("BT_AVRC", fmt, ## args);}
316 #define AVRC_TRACE_EVENT(fmt, args...)      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(AVRC,EVENT)) BT_PRINT_D("BT_AVRC", fmt, ## args);}
317 #define AVRC_TRACE_DEBUG(fmt, args...)      {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(AVRC,DEBUG)) BT_PRINT_D("BT_AVRC", fmt, ## args);}
318 
319 /* MCAP
320 */
321 #define MCA_TRACE_ERROR(fmt, args...)       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(MCA, ERROR)) BT_PRINT_E("BT_MCA", fmt, ## args);}
322 #define MCA_TRACE_WARNING(fmt, args...)     {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(MCA, WARNING)) BT_PRINT_W("BT_MCA", fmt, ## args);}
323 #define MCA_TRACE_API(fmt, args...)         {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(MCA,API)) BT_PRINT_I("BT_MCA", fmt, ## args);}
324 #define MCA_TRACE_EVENT(fmt, args...)       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(MCA,EVENT)) BT_PRINT_D("BT_MCA", fmt, ## args);}
325 #define MCA_TRACE_DEBUG(fmt, args...)       {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(MCA,DEBUG)) BT_PRINT_D("BT_MCA", fmt, ## args);}
326 
327 /* Define tracing for the ATT/GATT unit
328 */
329 #define GATT_TRACE_ERROR(fmt, args...)      {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GATT, ERROR)) BT_PRINT_E("BT_GATT", fmt, ## args);}
330 #define GATT_TRACE_WARNING(fmt, args...)    {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GATT, WARNING)) BT_PRINT_W("BT_GATT", fmt, ## args);}
331 #define GATT_TRACE_API(fmt, args...)        {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GATT,API)) BT_PRINT_I("BT_GATT", fmt, ## args);}
332 #define GATT_TRACE_EVENT(fmt, args...)      {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GATT,EVENT)) BT_PRINT_D("BT_GATT", fmt, ## args);}
333 #define GATT_TRACE_DEBUG(fmt, args...)      {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(GATT,DEBUG)) BT_PRINT_D("BT_GATT", fmt, ## args);}
334 
335 /* Define tracing for the SMP unit
336 */
337 #define SMP_TRACE_ERROR(fmt, args...)       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SMP, ERROR)) BT_PRINT_E("BT_SMP", fmt, ## args);}
338 #define SMP_TRACE_WARNING(fmt, args...)     {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SMP, WARNING)) BT_PRINT_W("BT_SMP", fmt, ## args);}
339 #define SMP_TRACE_API(fmt, args...)         {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SMP,API)) BT_PRINT_I("BT_SMP", fmt, ## args);}
340 #define SMP_TRACE_EVENT(fmt, args...)       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SMP,EVENT)) BT_PRINT_D("BT_SMP", fmt, ## args);}
341 #define SMP_TRACE_DEBUG(fmt, args...)       {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SMP,DEBUG)) BT_PRINT_D("BT_SMP", fmt, ## args);}
342 
343 
344 extern UINT8 btif_trace_level;
345 
346 // define traces for application
347 #define BTIF_TRACE_ERROR(fmt, args...)      {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTIF, ERROR)) BT_PRINT_E("BT_BTIF", fmt, ## args);}
348 #define BTIF_TRACE_WARNING(fmt, args...)    {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTIF, WARNING)) BT_PRINT_W("BT_BTIF", fmt, ## args);}
349 #define BTIF_TRACE_API(fmt, args...)        {if (btif_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTIF,API)) BT_PRINT_I("BT_BTIF", fmt, ## args);}
350 #define BTIF_TRACE_EVENT(fmt, args...)      {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTIF,EVENT)) BT_PRINT_D("BT_BTIF", fmt, ## args);}
351 #define BTIF_TRACE_DEBUG(fmt, args...)      {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTIF,DEBUG)) BT_PRINT_D("BT_BTIF", fmt, ## args);}
352 #define BTIF_TRACE_VERBOSE(fmt, args...)    {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(BTIF,VERBOSE)) BT_PRINT_V("BT_BTIF", fmt, ## args);}
353 
354 /* define traces for application */
355 
356 #define APPL_TRACE_ERROR(fmt, args...)      {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(APPL, ERROR)) BT_PRINT_E("BT_APPL", fmt, ## args);}
357 #define APPL_TRACE_WARNING(fmt, args...)    {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(APPL, WARNING)) BT_PRINT_W("BT_APPL", fmt, ## args);}
358 #define APPL_TRACE_API(fmt, args...)        {if (appl_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(APPL,API)) BT_PRINT_I("BT_APPL", fmt, ## args);}
359 #define APPL_TRACE_EVENT(fmt, args...)      {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(APPL,EVENT)) BT_PRINT_D("BT_APPL", fmt, ## args);}
360 #define APPL_TRACE_DEBUG(fmt, args...)      {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(APPL,DEBUG)) BT_PRINT_D("BT_APPL", fmt, ## args);}
361 #define APPL_TRACE_VERBOSE(fmt, args...)    {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(APPL,VERBOSE)) BT_PRINT_V("BT_APPL", fmt, ## args);}
362 
363 /* Define tracing for the HCI unit
364  * Modified from `btu_cb.trace_level` to `HCI_INITIAL_TRACE_LEVEL`,
365  * to use HCI_TRACE_XXXX in hci_layer.c without including `btu.h`
366 */
367 #define HCI_TRACE_ERROR(fmt, args...)       {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HCI, ERROR)) BT_PRINT_E("BT_HCI", fmt,## args);}
368 #define HCI_TRACE_WARNING(fmt, args...)     {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HCI, WARNING)) BT_PRINT_W("BT_HCI", fmt,## args);}
369 #define HCI_TRACE_EVENT(fmt, args...)       {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HCI,EVENT)) BT_PRINT_D("BT_HCI", fmt,## args);}
370 #define HCI_TRACE_DEBUG(fmt, args...)       {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HCI,DEBUG)) BT_PRINT_D("BT_HCI", fmt,## args);}
371 
372 #else
373 #define LOG_ERROR(fmt, args...)
374 #define LOG_WARN(fmt, args...)
375 #define LOG_INFO(fmt, args...)
376 #define LOG_DEBUG(fmt, args...)
377 #define LOG_VERBOSE(fmt, args...)
378 
379 /* Define tracing for the HCI unit
380 */
381 #define HCI_TRACE_ERROR(fmt, args...)
382 #define HCI_TRACE_WARNING(fmt, args...)
383 #define HCI_TRACE_EVENT(fmt, args...)
384 #define HCI_TRACE_DEBUG(fmt, args...)
385 
386 /* Define tracing for BTM
387 */
388 #define BTM_TRACE_ERROR(fmt, args...)
389 #define BTM_TRACE_WARNING(fmt, args...)
390 #define BTM_TRACE_API(fmt, args...)
391 #define BTM_TRACE_EVENT(fmt, args...)
392 #define BTM_TRACE_DEBUG(fmt, args...)
393 
394 /* Define tracing for the L2CAP unit
395 */
396 #define L2CAP_TRACE_ERROR(fmt, args...)
397 #define L2CAP_TRACE_WARNING(fmt, args...)
398 #define L2CAP_TRACE_API(fmt, args...)
399 #define L2CAP_TRACE_EVENT(fmt, args...)
400 #define L2CAP_TRACE_DEBUG(fmt, args...)
401 
402 /* Define tracing for the SDP unit
403 */
404 #define SDP_TRACE_ERROR(fmt, args...)
405 #define SDP_TRACE_WARNING(fmt, args...)
406 #define SDP_TRACE_API(fmt, args...)
407 #define SDP_TRACE_EVENT(fmt, args...)
408 #define SDP_TRACE_DEBUG(fmt, args...)
409 
410 /* Define tracing for the RFCOMM unit
411 */
412 #define RFCOMM_TRACE_ERROR(fmt, args...)
413 #define RFCOMM_TRACE_WARNING(fmt, args...)
414 #define RFCOMM_TRACE_API(fmt, args...)
415 #define RFCOMM_TRACE_EVENT(fmt, args...)
416 #define RFCOMM_TRACE_DEBUG(fmt, args...)
417 
418 /* Generic Access Profile traces */
419 #define GAP_TRACE_ERROR(fmt, args...)
420 #define GAP_TRACE_EVENT(fmt, args...)
421 #define GAP_TRACE_API(fmt, args...)
422 #define GAP_TRACE_WARNING(fmt, args...)
423 
424 /* define traces for HID Host */
425 #define HIDH_TRACE_ERROR(fmt, args...)
426 #define HIDH_TRACE_WARNING(fmt, args...)
427 #define HIDH_TRACE_API(fmt, args...)
428 #define HIDH_TRACE_EVENT(fmt, args...)
429 #define HIDH_TRACE_DEBUG(fmt, args...)
430 
431 /* define traces for HID Device */
432 #define HIDD_TRACE_ERROR(fmt, args...)
433 #define HIDD_TRACE_WARNING(fmt, args...)
434 #define HIDD_TRACE_API(fmt, args...)
435 #define HIDD_TRACE_EVENT(fmt, args...)
436 #define HIDD_TRACE_DEBUG(fmt, args...)
437 #define HIDD_TRACE_VERBOSE(fmt, args...)
438 
439 /* define traces for BNEP */
440 
441 #define BNEP_TRACE_ERROR(fmt, args...)
442 #define BNEP_TRACE_WARNING(fmt, args...)
443 #define BNEP_TRACE_API(fmt, args...)
444 #define BNEP_TRACE_EVENT(fmt, args...)
445 #define BNEP_TRACE_DEBUG(fmt, args...)
446 
447 /* define traces for PAN */
448 
449 #define PAN_TRACE_ERROR(fmt, args...)
450 #define PAN_TRACE_WARNING(fmt, args...)
451 #define PAN_TRACE_API(fmt, args...)
452 #define PAN_TRACE_EVENT(fmt, args...)
453 #define PAN_TRACE_DEBUG(fmt, args...)
454 
455 /* Define tracing for the A2DP profile
456 */
457 #define A2D_TRACE_ERROR(fmt, args...)
458 #define A2D_TRACE_WARNING(fmt, args...)
459 #define A2D_TRACE_EVENT(fmt, args...)
460 #define A2D_TRACE_DEBUG(fmt, args...)
461 #define A2D_TRACE_API(fmt, args...)
462 
463 /* AVDTP
464 */
465 #define AVDT_TRACE_ERROR(fmt, args...)
466 #define AVDT_TRACE_WARNING(fmt, args...)
467 #define AVDT_TRACE_EVENT(fmt, args...)
468 #define AVDT_TRACE_DEBUG(fmt, args...)
469 #define AVDT_TRACE_API(fmt, args...)
470 
471 /* Define tracing for the AVCTP protocol
472 */
473 #define AVCT_TRACE_ERROR(fmt, args...)
474 #define AVCT_TRACE_WARNING(fmt, args...)
475 #define AVCT_TRACE_EVENT(fmt, args...)
476 #define AVCT_TRACE_DEBUG(fmt, args...)
477 #define AVCT_TRACE_API(fmt, args...)
478 
479 /* Define tracing for the AVRCP profile
480 */
481 #define AVRC_TRACE_ERROR(fmt, args...)
482 #define AVRC_TRACE_WARNING(fmt, args...)
483 #define AVRC_TRACE_EVENT(fmt, args...)
484 #define AVRC_TRACE_DEBUG(fmt, args...)
485 #define AVRC_TRACE_API(fmt, args...)
486 
487 /* MCAP
488 */
489 #define MCA_TRACE_ERROR(fmt, args...)
490 #define MCA_TRACE_WARNING(fmt, args...)
491 #define MCA_TRACE_EVENT(fmt, args...)
492 #define MCA_TRACE_DEBUG(fmt, args...)
493 #define MCA_TRACE_API(fmt, args...)
494 
495 /* Define tracing for the ATT/GATT unit
496 */
497 #define GATT_TRACE_ERROR(fmt, args...)
498 #define GATT_TRACE_WARNING(fmt, args...)
499 #define GATT_TRACE_API(fmt, args...)
500 #define GATT_TRACE_EVENT(fmt, args...)
501 #define GATT_TRACE_DEBUG(fmt, args...)
502 
503 /* Define tracing for the SMP unit
504 */
505 #define SMP_TRACE_ERROR(fmt, args...)
506 #define SMP_TRACE_WARNING(fmt, args...)
507 #define SMP_TRACE_API(fmt, args...)
508 #define SMP_TRACE_EVENT(fmt, args...)
509 #define SMP_TRACE_DEBUG(fmt, args...)
510 
511 extern UINT8 btif_trace_level;
512 
513 // define traces for application
514 #define BTIF_TRACE_ERROR(fmt, args...)
515 #define BTIF_TRACE_WARNING(fmt, args...)
516 #define BTIF_TRACE_API(fmt, args...)
517 #define BTIF_TRACE_EVENT(fmt, args...)
518 #define BTIF_TRACE_DEBUG(fmt, args...)
519 #define BTIF_TRACE_VERBOSE(fmt, args...)
520 
521 /* define traces for application */
522 
523 #define APPL_TRACE_ERROR(fmt, args...)
524 #define APPL_TRACE_WARNING(fmt, args...)
525 #define APPL_TRACE_API(fmt, args...)
526 #define APPL_TRACE_EVENT(fmt, args...)
527 #define APPL_TRACE_DEBUG(fmt, args...)
528 #define APPL_TRACE_VERBOSE(fmt, args...)
529 
530 #endif  ///!UC_BT_STACK_NO_LOG
531 
532 
533 /* Simplified Trace Helper Macro
534 */
535 #define bdld(fmt, args...) \
536     do{\
537         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
538         BT_PRINT_D(fmt, ## args);        \
539     }while(0)
540 
541 #define bdlw(fmt, args...) \
542     do{\
543         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_WARNING) \
544         BT_PRINT_W(fmt, ## args);        \
545     }while(0)
546 
547 #define bdle(fmt, args...) \
548     do{\
549         if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) \
550         BT_PRINT_E(fmt, ## args);        \
551     }while(0)
552 
553 #define bdla(assert_if) \
554     do{\
555         if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
556         BT_PRINT_E("%s: assert failed\n", #assert_if);       \
557     }while(0)
558 
559 typedef UINT8 tBTTRC_PARAM_TYPE;
560 typedef UINT8 tBTTRC_LAYER_ID;
561 typedef UINT8 tBTTRC_TYPE;
562 
563 typedef struct {
564     tBTTRC_LAYER_ID layer_id;
565     tBTTRC_TYPE     type;      /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
566 } tBTTRC_LEVEL;
567 
568 typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
569 
570 typedef struct {
571     const tBTTRC_LAYER_ID         layer_id_start;
572     const tBTTRC_LAYER_ID         layer_id_end;
573     tBTTRC_SET_TRACE_LEVEL        *p_f;
574     const char                    *trc_name;
575     UINT8                         trace_level;
576 } tBTTRC_FUNC_MAP;
577 
578 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
579 extern UINT8 appl_trace_level;
580 
581 #endif /*_BT_TRACE_H_*/
582