The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 1999-2012 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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 | |
Chris Manton | aa0f6ec | 2014-09-24 15:18:41 -0700 | [diff] [blame] | 19 | #pragma once |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 20 | |
Jack He | 1f60d2d | 2016-11-22 12:39:52 -0800 | [diff] [blame] | 21 | #include <stdint.h> |
| 22 | |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Sharvil Nanavati | 06ef205 | 2014-11-06 18:34:06 -0800 | [diff] [blame] | 27 | static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module"; |
Zach Johnson | 9891f32 | 2014-09-22 22:11:55 -0700 | [diff] [blame] | 28 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 29 | /* BTE tracing IDs for debug purposes */ |
| 30 | /* LayerIDs for stack */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 31 | #define BTTRC_ID_STK_GKI 1 |
| 32 | #define BTTRC_ID_STK_BTU 2 |
| 33 | #define BTTRC_ID_STK_HCI 3 |
| 34 | #define BTTRC_ID_STK_L2CAP 4 |
| 35 | #define BTTRC_ID_STK_RFCM_MX 5 |
| 36 | #define BTTRC_ID_STK_RFCM_PRT 6 |
| 37 | #define BTTRC_ID_STK_OBEX_C 7 |
| 38 | #define BTTRC_ID_STK_OBEX_S 8 |
| 39 | #define BTTRC_ID_STK_AVCT 9 |
| 40 | #define BTTRC_ID_STK_AVDT 10 |
| 41 | #define BTTRC_ID_STK_AVRC 11 |
| 42 | #define BTTRC_ID_STK_BIC 12 |
| 43 | #define BTTRC_ID_STK_BIS 13 |
| 44 | #define BTTRC_ID_STK_BNEP 14 |
| 45 | #define BTTRC_ID_STK_BPP 15 |
| 46 | #define BTTRC_ID_STK_BTM_ACL 16 |
| 47 | #define BTTRC_ID_STK_BTM_PM 17 |
| 48 | #define BTTRC_ID_STK_BTM_DEV_CTRL 18 |
| 49 | #define BTTRC_ID_STK_BTM_SVC_DSC 19 |
| 50 | #define BTTRC_ID_STK_BTM_INQ 20 |
| 51 | #define BTTRC_ID_STK_BTM_SCO 21 |
| 52 | #define BTTRC_ID_STK_BTM_SEC 22 |
| 53 | #define BTTRC_ID_STK_HID 24 |
| 54 | #define BTTRC_ID_STK_HSP2 25 |
| 55 | #define BTTRC_ID_STK_CTP 26 |
| 56 | #define BTTRC_ID_STK_FTC 27 |
| 57 | #define BTTRC_ID_STK_FTS 28 |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 58 | #define BTTRC_ID_STK_HCRP 31 |
| 59 | #define BTTRC_ID_STK_ICP 32 |
| 60 | #define BTTRC_ID_STK_OPC 33 |
| 61 | #define BTTRC_ID_STK_OPS 34 |
| 62 | #define BTTRC_ID_STK_PAN 35 |
| 63 | #define BTTRC_ID_STK_SAP 36 |
| 64 | #define BTTRC_ID_STK_SDP 37 |
| 65 | #define BTTRC_ID_STK_SLIP 38 |
| 66 | #define BTTRC_ID_STK_SPP 39 |
| 67 | #define BTTRC_ID_STK_TCS 40 |
| 68 | #define BTTRC_ID_STK_VDP 41 |
Jack He | fb87f56 | 2019-01-09 20:47:57 -0800 | [diff] [blame] | 69 | #define BTTRC_ID_STK_MCAP 42 /* OBSOLETE */ |
| 70 | #define BTTRC_ID_STK_GATT 43 |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 71 | #define BTTRC_ID_STK_SMP 44 |
| 72 | #define BTTRC_ID_STK_NFC 45 |
| 73 | #define BTTRC_ID_STK_NCI 46 |
| 74 | #define BTTRC_ID_STK_IDEP 47 |
| 75 | #define BTTRC_ID_STK_NDEP 48 |
| 76 | #define BTTRC_ID_STK_LLCP 49 |
| 77 | #define BTTRC_ID_STK_RW 50 |
| 78 | #define BTTRC_ID_STK_CE 51 |
| 79 | #define BTTRC_ID_STK_SNEP 52 |
| 80 | #define BTTRC_ID_STK_NDEF 53 |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 81 | #define BTTRC_ID_STK_HIDD 54 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 82 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 83 | /* LayerIDs for BTA */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 84 | #define BTTRC_ID_BTA_ACC 55 /* Advanced Camera Client */ |
| 85 | #define BTTRC_ID_BTA_AG 56 /* audio gateway */ |
| 86 | #define BTTRC_ID_BTA_AV 57 /* Advanced audio */ |
| 87 | #define BTTRC_ID_BTA_BIC 58 /* Basic Imaging Client */ |
| 88 | #define BTTRC_ID_BTA_BIS 59 /* Basic Imaging Server */ |
| 89 | #define BTTRC_ID_BTA_BP 60 /* Basic Printing Client */ |
| 90 | #define BTTRC_ID_BTA_CG 61 |
| 91 | #define BTTRC_ID_BTA_CT 62 /* cordless telephony terminal */ |
| 92 | #define BTTRC_ID_BTA_DG 63 /* data gateway */ |
| 93 | #define BTTRC_ID_BTA_DM 64 /* device manager */ |
| 94 | #define BTTRC_ID_BTA_DM_SRCH 65 /* device manager search */ |
| 95 | #define BTTRC_ID_BTA_DM_SEC 66 /* device manager security */ |
| 96 | #define BTTRC_ID_BTA_FM 67 |
| 97 | #define BTTRC_ID_BTA_FTC 68 /* file transfer client */ |
| 98 | #define BTTRC_ID_BTA_FTS 69 /* file transfer server */ |
| 99 | #define BTTRC_ID_BTA_HIDH 70 |
| 100 | #define BTTRC_ID_BTA_HIDD 71 |
| 101 | #define BTTRC_ID_BTA_JV 72 |
| 102 | #define BTTRC_ID_BTA_OPC 73 /* object push client */ |
| 103 | #define BTTRC_ID_BTA_OPS 74 /* object push server */ |
| 104 | #define BTTRC_ID_BTA_PAN 75 /* Personal Area Networking */ |
| 105 | #define BTTRC_ID_BTA_PR 76 /* Printer client */ |
| 106 | #define BTTRC_ID_BTA_SC 77 /* SIM Card Access server */ |
| 107 | #define BTTRC_ID_BTA_SS 78 /* synchronization server */ |
| 108 | #define BTTRC_ID_BTA_SYS 79 /* system manager */ |
| 109 | #define BTTRC_ID_AVDT_SCB 80 /* avdt scb */ |
| 110 | #define BTTRC_ID_AVDT_CCB 81 /* avdt ccb */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 111 | |
Pavlin Radoslavov | b2a292b | 2016-10-14 19:34:48 -0700 | [diff] [blame] | 112 | /* LayerIDs added for BTL-A. Probably should modify bte_logmsg.cc in future. */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 113 | #define BTTRC_ID_STK_RFCOMM 82 |
| 114 | #define BTTRC_ID_STK_RFCOMM_DATA 83 |
| 115 | #define BTTRC_ID_STK_OBEX 84 |
| 116 | #define BTTRC_ID_STK_A2DP 85 |
| 117 | #define BTTRC_ID_STK_BIP 86 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 118 | |
| 119 | /* LayerIDs for BT APP */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 120 | #define BTTRC_ID_BTAPP 87 |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 121 | /* this is a temporary solution to allow dynamic enable/disable of |
| 122 | * BT_PROTOCOL_TRACE */ |
| 123 | #define BTTRC_ID_BT_PROTOCOL 88 |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 124 | #define BTTRC_ID_MAX_ID BTTRC_ID_BT_PROTOCOL |
| 125 | #define BTTRC_ID_ALL_LAYERS 0xFF /* all trace layers */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 126 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 127 | /****************************************************************************** |
Myles Watson | a88d1e3 | 2016-11-09 09:41:48 -0800 | [diff] [blame] | 128 | * |
| 129 | * Trace Levels |
| 130 | * |
| 131 | * The following values may be used for different levels: |
| 132 | * BT_TRACE_LEVEL_NONE 0 * No trace messages to be generated |
| 133 | * BT_TRACE_LEVEL_ERROR 1 * Error condition trace messages |
| 134 | * BT_TRACE_LEVEL_WARNING 2 * Warning condition trace messages |
| 135 | * BT_TRACE_LEVEL_API 3 * API traces |
| 136 | * BT_TRACE_LEVEL_EVENT 4 * Debug messages for events |
| 137 | * BT_TRACE_LEVEL_DEBUG 5 * Debug messages (general) |
| 138 | *****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 139 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 140 | /* Core Stack default trace levels */ |
| 141 | #ifndef HCI_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 142 | #define HCI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 143 | #endif |
| 144 | |
| 145 | #ifndef BTM_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 146 | #define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 147 | #endif |
| 148 | |
| 149 | #ifndef L2CAP_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 150 | #define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 151 | #endif |
| 152 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 153 | #ifndef RFCOMM_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 154 | #define RFCOMM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 155 | #endif |
| 156 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 157 | #ifndef SDP_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 158 | #define SDP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 159 | #endif |
| 160 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 161 | #ifndef BNEP_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 162 | #define BNEP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 163 | #endif |
| 164 | |
| 165 | #ifndef PAN_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 166 | #define PAN_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 167 | #endif |
| 168 | |
Pavlin Radoslavov | f66f4e9 | 2016-10-14 15:14:37 -0700 | [diff] [blame] | 169 | #ifndef A2DP_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 170 | #define A2DP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 171 | #endif |
| 172 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 173 | #ifndef AVDT_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 174 | #define AVDT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 175 | #endif |
| 176 | |
| 177 | #ifndef AVCT_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 178 | #define AVCT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 179 | #endif |
| 180 | |
| 181 | #ifndef AVRC_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 182 | #define AVRC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 183 | #endif |
| 184 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 185 | #ifndef HID_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 186 | #define HID_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 187 | #endif |
| 188 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 189 | #ifndef APPL_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 190 | #define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 191 | #endif |
| 192 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 193 | #ifndef GATT_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 194 | #define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 195 | #endif |
| 196 | |
| 197 | #ifndef SMP_INITIAL_TRACE_LEVEL |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 198 | #define SMP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 199 | #endif |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 200 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 201 | #define BT_TRACE(l, t, ...) \ |
| 202 | LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), ##__VA_ARGS__) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 203 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 204 | /* Define tracing for the HCI unit */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 205 | #define HCI_TRACE_ERROR(...) \ |
| 206 | { \ |
| 207 | if (btu_trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 208 | BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 209 | } |
| 210 | #define HCI_TRACE_WARNING(...) \ |
| 211 | { \ |
| 212 | if (btu_trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 213 | BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 214 | } |
| 215 | #define HCI_TRACE_EVENT(...) \ |
| 216 | { \ |
| 217 | if (btu_trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 218 | BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 219 | } |
| 220 | #define HCI_TRACE_DEBUG(...) \ |
| 221 | { \ |
| 222 | if (btu_trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 223 | BT_TRACE(TRACE_LAYER_HCI, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 224 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 225 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 226 | /* Define tracing for BTM */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 227 | #define BTM_TRACE_ERROR(...) \ |
| 228 | { \ |
| 229 | if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 230 | BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 231 | } |
| 232 | #define BTM_TRACE_WARNING(...) \ |
| 233 | { \ |
| 234 | if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 235 | BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 236 | } |
| 237 | #define BTM_TRACE_API(...) \ |
| 238 | { \ |
| 239 | if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 240 | BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 241 | } |
| 242 | #define BTM_TRACE_EVENT(...) \ |
| 243 | { \ |
| 244 | if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 245 | BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 246 | } |
| 247 | #define BTM_TRACE_DEBUG(...) \ |
| 248 | { \ |
| 249 | if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 250 | BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 251 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 252 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 253 | /* Define tracing for the L2CAP unit */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 254 | #define L2CAP_TRACE_ERROR(...) \ |
| 255 | { \ |
| 256 | if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 257 | BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 258 | } |
| 259 | #define L2CAP_TRACE_WARNING(...) \ |
| 260 | { \ |
| 261 | if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 262 | BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 263 | } |
| 264 | #define L2CAP_TRACE_API(...) \ |
| 265 | { \ |
| 266 | if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) \ |
| 267 | BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 268 | } |
| 269 | #define L2CAP_TRACE_EVENT(...) \ |
| 270 | { \ |
| 271 | if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 272 | BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 273 | } |
| 274 | #define L2CAP_TRACE_DEBUG(...) \ |
| 275 | { \ |
| 276 | if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 277 | BT_TRACE(TRACE_LAYER_L2CAP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 278 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 279 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 280 | /* Define tracing for the SDP unit */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 281 | #define SDP_TRACE_ERROR(...) \ |
| 282 | { \ |
| 283 | if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 284 | BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 285 | } |
| 286 | #define SDP_TRACE_WARNING(...) \ |
| 287 | { \ |
| 288 | if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 289 | BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 290 | } |
| 291 | #define SDP_TRACE_API(...) \ |
| 292 | { \ |
| 293 | if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 294 | BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 295 | } |
| 296 | #define SDP_TRACE_EVENT(...) \ |
| 297 | { \ |
| 298 | if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 299 | BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 300 | } |
| 301 | #define SDP_TRACE_DEBUG(...) \ |
| 302 | { \ |
| 303 | if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 304 | BT_TRACE(TRACE_LAYER_SDP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 305 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 306 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 307 | /* Define tracing for the RFCOMM unit */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 308 | #define RFCOMM_TRACE_ERROR(...) \ |
| 309 | { \ |
| 310 | if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 311 | BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 312 | } |
| 313 | #define RFCOMM_TRACE_WARNING(...) \ |
| 314 | { \ |
| 315 | if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 316 | BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 317 | } |
| 318 | #define RFCOMM_TRACE_API(...) \ |
| 319 | { \ |
| 320 | if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 321 | BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 322 | } |
| 323 | #define RFCOMM_TRACE_EVENT(...) \ |
| 324 | { \ |
| 325 | if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 326 | BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 327 | } |
| 328 | #define RFCOMM_TRACE_DEBUG(...) \ |
| 329 | { \ |
| 330 | if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 331 | BT_TRACE(TRACE_LAYER_RFCOMM, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 332 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 333 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 334 | /* define traces for HID Host */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 335 | #define HIDH_TRACE_ERROR(...) \ |
| 336 | { \ |
| 337 | if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 338 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 339 | } |
| 340 | #define HIDH_TRACE_WARNING(...) \ |
| 341 | { \ |
| 342 | if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 343 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 344 | } |
| 345 | #define HIDH_TRACE_API(...) \ |
| 346 | { \ |
| 347 | if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 348 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 349 | } |
| 350 | #define HIDH_TRACE_EVENT(...) \ |
| 351 | { \ |
| 352 | if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 353 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 354 | } |
| 355 | #define HIDH_TRACE_DEBUG(...) \ |
| 356 | { \ |
| 357 | if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 358 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 359 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 360 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 361 | /* define traces for HID Device */ |
| 362 | #define HIDD_TRACE_ERROR(...) \ |
| 363 | { \ |
| 364 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 365 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 366 | } |
| 367 | #define HIDD_TRACE_WARNING(...) \ |
| 368 | { \ |
| 369 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 370 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 371 | } |
| 372 | #define HIDD_TRACE_API(...) \ |
| 373 | { \ |
| 374 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 375 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 376 | } |
| 377 | #define HIDD_TRACE_EVENT(...) \ |
| 378 | { \ |
| 379 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 380 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 381 | } |
| 382 | #define HIDD_TRACE_DEBUG(...) \ |
| 383 | { \ |
| 384 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 385 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 386 | } |
| 387 | #define HIDD_TRACE_VERBOSE(...) \ |
| 388 | { \ |
| 389 | if (hd_cb.trace_level >= BT_TRACE_LEVEL_VERBOSE) \ |
| 390 | BT_TRACE(TRACE_LAYER_HID, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 391 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 392 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 393 | /* define traces for BNEP */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 394 | #define BNEP_TRACE_ERROR(...) \ |
| 395 | { \ |
| 396 | if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 397 | BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 398 | } |
| 399 | #define BNEP_TRACE_WARNING(...) \ |
| 400 | { \ |
| 401 | if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 402 | BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 403 | } |
| 404 | #define BNEP_TRACE_API(...) \ |
| 405 | { \ |
| 406 | if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 407 | BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 408 | } |
| 409 | #define BNEP_TRACE_EVENT(...) \ |
| 410 | { \ |
| 411 | if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 412 | BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 413 | } |
| 414 | #define BNEP_TRACE_DEBUG(...) \ |
| 415 | { \ |
| 416 | if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 417 | BT_TRACE(TRACE_LAYER_BNEP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 418 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 419 | |
| 420 | /* define traces for PAN */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 421 | #define PAN_TRACE_ERROR(...) \ |
| 422 | { \ |
| 423 | if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 424 | BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 425 | } |
| 426 | #define PAN_TRACE_WARNING(...) \ |
| 427 | { \ |
| 428 | if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 429 | BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 430 | } |
| 431 | #define PAN_TRACE_API(...) \ |
| 432 | { \ |
| 433 | if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 434 | BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 435 | } |
| 436 | #define PAN_TRACE_EVENT(...) \ |
| 437 | { \ |
| 438 | if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 439 | BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 440 | } |
| 441 | #define PAN_TRACE_DEBUG(...) \ |
| 442 | { \ |
| 443 | if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 444 | BT_TRACE(TRACE_LAYER_PAN, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 445 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 446 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 447 | /* Define tracing for the A2DP profile */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 448 | #define A2DP_TRACE_ERROR(...) \ |
| 449 | { \ |
| 450 | if (a2dp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 451 | BT_TRACE(TRACE_LAYER_A2DP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 452 | } |
| 453 | #define A2DP_TRACE_WARNING(...) \ |
| 454 | { \ |
| 455 | if (a2dp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 456 | BT_TRACE(TRACE_LAYER_A2DP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 457 | } |
| 458 | #define A2DP_TRACE_EVENT(...) \ |
| 459 | { \ |
| 460 | if (a2dp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 461 | BT_TRACE(TRACE_LAYER_A2DP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 462 | } |
| 463 | #define A2DP_TRACE_DEBUG(...) \ |
| 464 | { \ |
| 465 | if (a2dp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 466 | BT_TRACE(TRACE_LAYER_A2DP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 467 | } |
| 468 | #define A2DP_TRACE_API(...) \ |
| 469 | { \ |
| 470 | if (a2dp_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 471 | BT_TRACE(TRACE_LAYER_A2DP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 472 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 473 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 474 | /* AVDTP */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 475 | #define AVDT_TRACE_ERROR(...) \ |
| 476 | { \ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 477 | if (avdtp_cb.TraceLevel() >= BT_TRACE_LEVEL_ERROR) \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 478 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 479 | } |
| 480 | #define AVDT_TRACE_WARNING(...) \ |
| 481 | { \ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 482 | if (avdtp_cb.TraceLevel() >= BT_TRACE_LEVEL_WARNING) \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 483 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 484 | } |
| 485 | #define AVDT_TRACE_EVENT(...) \ |
| 486 | { \ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 487 | if (avdtp_cb.TraceLevel() >= BT_TRACE_LEVEL_EVENT) \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 488 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 489 | } |
| 490 | #define AVDT_TRACE_DEBUG(...) \ |
| 491 | { \ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 492 | if (avdtp_cb.TraceLevel() >= BT_TRACE_LEVEL_DEBUG) \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 493 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 494 | } |
| 495 | #define AVDT_TRACE_API(...) \ |
| 496 | { \ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 497 | if (avdtp_cb.TraceLevel() >= BT_TRACE_LEVEL_API) \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 498 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 499 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 500 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 501 | /* Define tracing for the AVCTP protocol */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 502 | #define AVCT_TRACE_ERROR(...) \ |
| 503 | { \ |
| 504 | if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 505 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 506 | } |
| 507 | #define AVCT_TRACE_WARNING(...) \ |
| 508 | { \ |
| 509 | if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 510 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 511 | } |
| 512 | #define AVCT_TRACE_EVENT(...) \ |
| 513 | { \ |
| 514 | if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 515 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 516 | } |
| 517 | #define AVCT_TRACE_DEBUG(...) \ |
| 518 | { \ |
| 519 | if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 520 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 521 | } |
| 522 | #define AVCT_TRACE_API(...) \ |
| 523 | { \ |
| 524 | if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 525 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 526 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 527 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 528 | /* Define tracing for the AVRCP profile */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 529 | #define AVRC_TRACE_ERROR(...) \ |
| 530 | { \ |
| 531 | if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 532 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 533 | } |
| 534 | #define AVRC_TRACE_WARNING(...) \ |
| 535 | { \ |
| 536 | if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 537 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 538 | } |
| 539 | #define AVRC_TRACE_EVENT(...) \ |
| 540 | { \ |
| 541 | if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 542 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 543 | } |
| 544 | #define AVRC_TRACE_DEBUG(...) \ |
| 545 | { \ |
| 546 | if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 547 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 548 | } |
| 549 | #define AVRC_TRACE_API(...) \ |
| 550 | { \ |
| 551 | if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 552 | BT_TRACE(TRACE_LAYER_AVP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 553 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 554 | |
Hemant Gupta | 8843cc8 | 2014-04-18 12:34:55 +0530 | [diff] [blame] | 555 | /* Define tracing for the SMP unit */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 556 | #define SMP_TRACE_ERROR(...) \ |
| 557 | { \ |
| 558 | if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 559 | BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_ERROR, ##__VA_ARGS__); \ |
| 560 | } |
| 561 | #define SMP_TRACE_WARNING(...) \ |
| 562 | { \ |
| 563 | if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 564 | BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_WARNING, ##__VA_ARGS__); \ |
| 565 | } |
| 566 | #define SMP_TRACE_API(...) \ |
| 567 | { \ |
| 568 | if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) \ |
| 569 | BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_API, ##__VA_ARGS__); \ |
| 570 | } |
| 571 | #define SMP_TRACE_EVENT(...) \ |
| 572 | { \ |
| 573 | if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 574 | BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_EVENT, ##__VA_ARGS__); \ |
| 575 | } |
| 576 | #define SMP_TRACE_DEBUG(...) \ |
| 577 | { \ |
| 578 | if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 579 | BT_TRACE(TRACE_LAYER_SMP, TRACE_TYPE_DEBUG, ##__VA_ARGS__); \ |
| 580 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 581 | |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 582 | extern uint8_t btif_trace_level; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 583 | |
| 584 | /* define traces for application */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 585 | #define BTIF_TRACE_ERROR(...) \ |
| 586 | { \ |
| 587 | if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 588 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 589 | TRACE_TYPE_ERROR, \ |
| 590 | ##__VA_ARGS__); \ |
| 591 | } |
| 592 | #define BTIF_TRACE_WARNING(...) \ |
| 593 | { \ |
| 594 | if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 595 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 596 | TRACE_TYPE_WARNING, \ |
| 597 | ##__VA_ARGS__); \ |
| 598 | } |
| 599 | #define BTIF_TRACE_API(...) \ |
| 600 | { \ |
| 601 | if (btif_trace_level >= BT_TRACE_LEVEL_API) \ |
| 602 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 603 | TRACE_TYPE_API, \ |
| 604 | ##__VA_ARGS__); \ |
| 605 | } |
| 606 | #define BTIF_TRACE_EVENT(...) \ |
| 607 | { \ |
| 608 | if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 609 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 610 | TRACE_TYPE_EVENT, \ |
| 611 | ##__VA_ARGS__); \ |
| 612 | } |
| 613 | #define BTIF_TRACE_DEBUG(...) \ |
| 614 | { \ |
| 615 | if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 616 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 617 | TRACE_TYPE_DEBUG, \ |
| 618 | ##__VA_ARGS__); \ |
| 619 | } |
| 620 | #define BTIF_TRACE_VERBOSE(...) \ |
| 621 | { \ |
| 622 | if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE) \ |
| 623 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 624 | TRACE_TYPE_DEBUG, \ |
| 625 | ##__VA_ARGS__); \ |
| 626 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 627 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 628 | /* define traces for application */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 629 | #define APPL_TRACE_ERROR(...) \ |
| 630 | { \ |
| 631 | if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) \ |
| 632 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 633 | TRACE_TYPE_ERROR, \ |
| 634 | ##__VA_ARGS__); \ |
| 635 | } |
| 636 | #define APPL_TRACE_WARNING(...) \ |
| 637 | { \ |
| 638 | if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) \ |
| 639 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 640 | TRACE_TYPE_WARNING, \ |
| 641 | ##__VA_ARGS__); \ |
| 642 | } |
| 643 | #define APPL_TRACE_API(...) \ |
| 644 | { \ |
| 645 | if (appl_trace_level >= BT_TRACE_LEVEL_API) \ |
| 646 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 647 | TRACE_TYPE_API, \ |
| 648 | ##__VA_ARGS__); \ |
| 649 | } |
| 650 | #define APPL_TRACE_EVENT(...) \ |
| 651 | { \ |
| 652 | if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) \ |
| 653 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 654 | TRACE_TYPE_EVENT, \ |
| 655 | ##__VA_ARGS__); \ |
| 656 | } |
| 657 | #define APPL_TRACE_DEBUG(...) \ |
| 658 | { \ |
| 659 | if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) \ |
| 660 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 661 | TRACE_TYPE_DEBUG, \ |
| 662 | ##__VA_ARGS__); \ |
| 663 | } |
| 664 | #define APPL_TRACE_VERBOSE(...) \ |
| 665 | { \ |
| 666 | if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) \ |
| 667 | LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \ |
| 668 | TRACE_TYPE_DEBUG, \ |
| 669 | ##__VA_ARGS__); \ |
| 670 | } |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 671 | |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 672 | typedef uint8_t tBTTRC_LAYER_ID; |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 673 | typedef uint8_t(tBTTRC_SET_TRACE_LEVEL)(uint8_t); |
Chris Manton | aa0f6ec | 2014-09-24 15:18:41 -0700 | [diff] [blame] | 674 | |
| 675 | typedef struct { |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 676 | const tBTTRC_LAYER_ID layer_id_start; |
| 677 | const tBTTRC_LAYER_ID layer_id_end; |
| 678 | tBTTRC_SET_TRACE_LEVEL* p_f; |
| 679 | const char* trc_name; |
| 680 | uint8_t trace_level; |
Chris Manton | aa0f6ec | 2014-09-24 15:18:41 -0700 | [diff] [blame] | 681 | } tBTTRC_FUNC_MAP; |
| 682 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 683 | /* External declaration for appl_trace_level here to avoid to add the |
| 684 | * declaration in all the files using APPL_TRACExxx macros */ |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 685 | extern uint8_t appl_trace_level; |
Pavlin Radoslavov | 258c253 | 2015-09-27 20:59:05 -0700 | [diff] [blame] | 686 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 687 | void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...); |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame] | 688 | |
| 689 | #ifdef __cplusplus |
| 690 | } |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 691 | #endif |
Jakub Pawlowski | 2647452 | 2017-10-04 12:22:10 -0700 | [diff] [blame] | 692 | |
| 693 | #ifdef __cplusplus |
| 694 | |
| 695 | #include <iomanip> |
| 696 | #include <sstream> |
| 697 | #include <type_traits> |
| 698 | |
Pavlin Radoslavov | 25cd054 | 2018-04-06 17:05:47 -0700 | [diff] [blame] | 699 | #include <base/logging.h> |
| 700 | |
Jack He | 78b69d9 | 2018-11-16 02:59:43 -0800 | [diff] [blame] | 701 | /* Prints integral parameter x as hex string, with '0' fill */ |
Jakub Pawlowski | 2647452 | 2017-10-04 12:22:10 -0700 | [diff] [blame] | 702 | template <typename T> |
| 703 | std::string loghex(T x) { |
| 704 | static_assert(std::is_integral<T>::value, |
| 705 | "loghex parameter must be integral."); |
| 706 | std::stringstream tmp; |
| 707 | tmp << std::showbase << std::internal << std::hex << std::setfill('0') |
Jakub Pawlowski | 78b3e7b | 2018-02-12 13:18:33 -0800 | [diff] [blame] | 708 | << std::setw((sizeof(T) * 2) + 2) << +x; |
Jakub Pawlowski | 2647452 | 2017-10-04 12:22:10 -0700 | [diff] [blame] | 709 | return tmp.str(); |
| 710 | } |
| 711 | |
Jack He | 78b69d9 | 2018-11-16 02:59:43 -0800 | [diff] [blame] | 712 | /* Prints integral array as hex string, with '0' fill */ |
| 713 | template <typename T, size_t N> |
| 714 | std::string loghex(std::array<T, N> array) { |
| 715 | static_assert(std::is_integral<T>::value, |
| 716 | "type stored in array must be integral."); |
| 717 | std::stringstream tmp; |
| 718 | for (const auto& x : array) { |
| 719 | tmp << std::internal << std::hex << std::setfill('0') |
| 720 | << std::setw((sizeof(uint8_t) * 2) + 2) << +x; |
| 721 | } |
| 722 | return tmp.str(); |
| 723 | } |
| 724 | |
Pavlin Radoslavov | 25cd054 | 2018-04-06 17:05:47 -0700 | [diff] [blame] | 725 | /** |
Guang Xie | 1b548bb | 2018-02-15 12:42:15 -0800 | [diff] [blame] | 726 | * Obtains the string representation of a boolean value. |
| 727 | * |
| 728 | * @param value the boolean value to use |
| 729 | * @return the string representation of the boolean value: "true" or "false" |
| 730 | */ |
| 731 | inline std::string logbool(bool value) { |
| 732 | std::stringstream tmp; |
| 733 | tmp << std::boolalpha << value; |
| 734 | return tmp.str(); |
| 735 | } |
| 736 | |
| 737 | /** |
Pavlin Radoslavov | 25cd054 | 2018-04-06 17:05:47 -0700 | [diff] [blame] | 738 | * Append a field name to a string. |
| 739 | * |
| 740 | * The field names are added to the string with "|" in between. |
| 741 | * |
| 742 | * @param p_result a pointer to the result string to add the field name to |
| 743 | * @param append if true the field name will be added |
| 744 | * @param name the field name to add |
| 745 | * @return the result string |
| 746 | */ |
| 747 | inline std::string& AppendField(std::string* p_result, bool append, |
| 748 | const std::string& name) { |
| 749 | CHECK(p_result != nullptr); |
| 750 | if (!append) return *p_result; |
| 751 | if (!p_result->empty()) *p_result += "|"; |
| 752 | *p_result += name; |
| 753 | return *p_result; |
| 754 | } |
| 755 | |
Ajay Panicker | fe8edd0 | 2018-05-03 12:58:53 -0700 | [diff] [blame] | 756 | // This object puts the stream in a state where every time that a new line |
| 757 | // occurs, the next line is indented a certain number of spaces. The stream is |
| 758 | // reset to its previous state when the object is destroyed. |
| 759 | class ScopedIndent { |
| 760 | public: |
| 761 | ScopedIndent(std::ostream& stream, int indent_size = DEFAULT_TAB) |
| 762 | : indented_buf_(stream, indent_size) { |
| 763 | old_stream_ = &stream; |
| 764 | old_stream_buf_ = stream.rdbuf(); |
| 765 | stream.rdbuf(&indented_buf_); |
| 766 | } |
| 767 | |
| 768 | ~ScopedIndent() { old_stream_->rdbuf(old_stream_buf_); } |
| 769 | |
| 770 | static const size_t DEFAULT_TAB = 2; |
| 771 | |
| 772 | private: |
| 773 | class IndentedStreamBuf : public std::streambuf { |
| 774 | public: |
| 775 | IndentedStreamBuf(std::ostream& stream, int indent_size) |
| 776 | : wrapped_buf_(stream.rdbuf()), |
| 777 | indent_size_(indent_size), |
| 778 | indent_next_line_(true){}; |
| 779 | |
| 780 | protected: |
| 781 | virtual int overflow(int character) override { |
| 782 | if (indent_next_line_ && character != '\n') { |
| 783 | for (int i = 0; i < indent_size_; i++) wrapped_buf_->sputc(' '); |
| 784 | } |
| 785 | |
| 786 | indent_next_line_ = false; |
| 787 | if (character == '\n') { |
| 788 | indent_next_line_ = true; |
| 789 | } |
| 790 | |
| 791 | return wrapped_buf_->sputc(character); |
| 792 | } |
| 793 | |
| 794 | private: |
| 795 | std::streambuf* wrapped_buf_; |
| 796 | int indent_size_; |
| 797 | bool indent_next_line_; |
| 798 | }; |
| 799 | |
| 800 | std::ostream* old_stream_; |
| 801 | std::streambuf* old_stream_buf_; |
| 802 | IndentedStreamBuf indented_buf_; |
| 803 | }; |
| 804 | |
Jakub Pawlowski | 2647452 | 2017-10-04 12:22:10 -0700 | [diff] [blame] | 805 | #endif |