• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __CSBLE_DBG_H
16 #define __CSBLE_DBG_H
17 /*chipsea_ohos proguard begin*/
18 #include "cs_proguard.h"
19 /*chipsea_ohos proguard end*/
20 
21 #include "al_rtos.h"
22 #include "dbg.h"
23 #include "wb_co_int.h"
24 
25 enum {
26     CSBLE_ERROR_LEVEL  = 0,
27     CSBLE_WARN_LEVEL   = 1,
28     CSBLE_NOTICE_LEVEL = 2,
29     CSBLE_INFO_LEVEL   = 3,
30     CSBLE_DEBUG_LEVEL  = 4,
31 };
32 
33 #define CSBLE_HCI_VAL                  BIT0
34 #define CSBLE_L2CAP_VAL                BIT1
35 #define CSBLE_GAP_VAL                  BIT2
36 #define CSBLE_GATT_VAL                 BIT3
37 #define CSBLE_ATT_VAL                  BIT4
38 #define CSBLE_SMP_VAL                  BIT5
39 #define CSBLE_APP_VAL                  BIT6
40 #define CSBLE_PRF_VAL                  BIT7
41 #define CSBLE_DBG_MASK                 (0xffffffff)
42 #define CSBLE_NON_DBG                  (0)
43 
44 #define CSBLE_TX_ACL_AREA              BIT0
45 #define CSBLE_TX_CMD_AREA              BIT1
46 #define CSBLE_RX_EVENT_AREA            BIT2
47 #define CSBLE_RX_ACL_AREA              BIT3
48 #define CSBLE_LTK_AREA                 BIT4
49 #define CSBLE_AREA_MASK                 (0xFFFFFFFF)
50 #define CSBLE_NONE_AREA                (0)
51 
52 #define TX_ACL                  (csble_dump_area & CSBLE_TX_ACL_AREA)
53 #define TX_CMD                  (csble_dump_area & CSBLE_TX_CMD_AREA)
54 #define RX_EVENT                (csble_dump_area & CSBLE_RX_EVENT_AREA)
55 #define RX_ACL                  (csble_dump_area & CSBLE_RX_ACL_AREA)
56 #define LTK                     (csble_dump_area & CSBLE_LTK_AREA)
57 
58 extern uint32_t csble_dbg_area;
59 extern uint32_t csble_dbg_level;
60 extern uint32_t csble_dump_area;
61 
62 char *csble_dbgarea(int dbg_flags);
63 void csble_set_dbgarea(uint32_t dbg_area);
64 void csble_set_dbgarea(uint32_t dbg_area);
65 void csble_set_dumparea(uint32_t dump_area);
66 uint32_t csble_get_dbgarea();
67 uint32_t csble_get_dbglevel();
68 uint32_t csble_get_dumparea();
69 
70 #ifdef CFG_DBG
71 #define CSBLE_DBG(area, level, fmt, ...) \
72         do { \
73             uint32_t dbg_area = CSBLE_##area##_VAL & csble_dbg_area; \
74             uint32_t dbg_level = CSBLE_##level##_LEVEL; \
75             if (dbg_area && (dbg_level <= csble_dbg_level)){ \
76                     const char *prefix = NULL; \
77                     prefix = csble_dbgarea(dbg_area); \
78                     dbg("%s<%s,%d>", prefix, __func__, __LINE__); \
79                     dbg(fmt, ##__VA_ARGS__); \
80                     dbg("\n");\
81             } \
82         } while (0)
83 #else /* CFG_DBG */
84 #define CSBLE_DBG(area, level, fmt, ...)
85 #endif /* CFG_DBG */
86 
87 #ifdef CFG_DBG
88 void csble_dbg_hex_dump(int area, const void *data, size_t size);
89 #define CSBLE_DUMP(area, data, len)\
90         do {\
91             if (area){\
92                 dbg("[BLE_DUMP]:<%s,%d>: (len:%d)\n", __func__, __LINE__,(int)len);\
93                 csble_dbg_hex_dump(area, data, len);\
94             }\
95         } while (0)
96 #else /* CFG_DBG */
97 #define CSBLE_DUMP(area, data, len)
98 #endif /* CFG_DBG */
99 
100 #endif /* __CSBLE_DBG_H */
101