1 /******************************************************************************
2  *
3  *  Copyright (C) 2011-2012 Broadcom Corporation
4  *  Copyright (C) 2017 ST Microelectronics S.A.
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at:
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  ******************************************************************************/
19 /******************************************************************************
20  * Decode NFC packets and print them to ADB log.
21  * If protocol decoder is not present, then decode packets into hex numbers.
22  ******************************************************************************/
23 
24 extern "C" {
25 
26 #include <cutils/properties.h>
27 #include <log/log.h>
28 
29 #define DISP_NCI ProtoDispAdapterDisplayNciPacket
30 
31 extern unsigned char hal_trace_level;
32 extern int GetNumValue(const char* name, void* p_value, unsigned long len);
33 extern int GetByteArrayValue(const char* name, char* pValue, long bufflen,
34                              long* len);
35 extern int GetStrValue(const char* name, char* pValue, unsigned long l);
36 
37 /* #######################
38  * Set the logging level
39  * ######################## */
40 #define STESE_TRACE_LEVEL_NONE 0x00
41 #define STESE_TRACE_LEVEL_ERROR 0x01
42 #define STESE_TRACE_LEVEL_WARNING 0x02
43 #define STESE_TRACE_LEVEL_DEBUG 0x03
44 #define STESE_TRACE_LEVEL_VERBOSE 0x04
45 
46 #define STLOG_HAL_V(...)                                \
47   {                                                     \
48     if (hal_trace_level >= STESE_TRACE_LEVEL_VERBOSE)   \
49       LOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); \
50   }
51 #define STLOG_HAL_D(...)                                \
52   {                                                     \
53     if (hal_trace_level >= STESE_TRACE_LEVEL_DEBUG)     \
54       LOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); \
55   }
56 #define STLOG_HAL_W(...)                               \
57   {                                                    \
58     if (hal_trace_level >= STESE_TRACE_LEVEL_WARNING)  \
59       LOG_PRI(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); \
60   }
61 #define STLOG_HAL_E(...)                                \
62   {                                                     \
63     if (hal_trace_level >= STESE_TRACE_LEVEL_ERROR)     \
64       LOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); \
65   }
66 /*******************************************************************************
67 **
68 ** Function:        InitializeSTLogLevel
69 **
70 ** Description:     Initialize and get global logging level from
71 **                  Android property nfc.app_log_level.
72 **
73 ** Returns:         Global log level:
74 **                  STNFC_TRACE_LEVEL_NONE    0     * No trace messages to be
75 **                                                     generated
76 **                  STNFC_TRACE_LEVEL_ERROR   1     * Error condition trace
77 **                                                     messages
78 **                  STNFC_TRACE_LEVEL_WARNING 2     * Warning condition trace
79 **                                                     messages
80 **                  STNFC_TRACE_LEVEL_DEBUG   3     * Debug messages (general)
81 **
82 *******************************************************************************/
83 unsigned char InitializeSTLogLevel();
84 
85 void DispHal(const char* title, const void* data, size_t length);
86 };
87