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 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include "data_types.h"
29 #include <log/log.h>
30 #include <cutils/properties.h>
31 
32 #define DISP_NCI ProtoDispAdapterDisplayNciPacket
33 #define HAL_LOG_TAG "StNfcHal"
34 
35 extern unsigned char hal_trace_level;
36 extern int GetNumValue(const char* name, void* p_value, unsigned long len);
37 
38 /* #######################
39 * Set the log module name in .conf file
40 * ########################## */
41 #define NAME_STNFC_HAL_LOGLEVEL "STNFC_HAL_LOGLEVEL"
42 
43 /* #######################
44 * Set the logging level
45 * ######################## */
46 #define STNFC_TRACE_LEVEL_NONE    0x00
47 #define STNFC_TRACE_LEVEL_ERROR   0x01
48 #define STNFC_TRACE_LEVEL_WARNING 0x02
49 #define STNFC_TRACE_LEVEL_DEBUG   0x03
50 #define STNFC_TRACE_LEVEL_VERBOSE 0x04
51 
52 #define STLOG_HAL_V(...)                                       \
53   {                                                              \
54     if (hal_trace_level >= STNFC_TRACE_LEVEL_VERBOSE)  \
55       LOG_PRI(ANDROID_LOG_DEBUG, HAL_LOG_TAG, __VA_ARGS__); \
56   }
57 #define STLOG_HAL_D(...)                                       \
58   {                                                              \
59     if (hal_trace_level >= STNFC_TRACE_LEVEL_DEBUG)  \
60       LOG_PRI(ANDROID_LOG_DEBUG, HAL_LOG_TAG, __VA_ARGS__); \
61   }
62 #define STLOG_HAL_W(...)                                      \
63   {                                                             \
64     if (hal_trace_level >= STNFC_TRACE_LEVEL_WARNING)  \
65       LOG_PRI(ANDROID_LOG_WARN, HAL_LOG_TAG, __VA_ARGS__); \
66   }
67 #define STLOG_HAL_E(...)                                       \
68   {                                                              \
69     if (hal_trace_level >= STNFC_TRACE_LEVEL_ERROR)  \
70       LOG_PRI(ANDROID_LOG_ERROR, HAL_LOG_TAG, __VA_ARGS__); \
71   }
72 /*******************************************************************************
73 **
74 ** Function:        InitializeSTLogLevel
75 **
76 ** Description:     Initialize and get global logging level from
77 **                  Android property nfc.app_log_level.
78 **
79 ** Returns:         Global log level:
80 **                  STNFC_TRACE_LEVEL_NONE    0     * No trace messages to be
81 **                                                     generated
82 **                  STNFC_TRACE_LEVEL_ERROR   1     * Error condition trace
83 **                                                     messages
84 **                  STNFC_TRACE_LEVEL_WARNING 2     * Warning condition trace
85 **                                                     messages
86 **                  STNFC_TRACE_LEVEL_DEBUG   3     * Debug messages (general)
87 **
88 *******************************************************************************/
89 unsigned char InitializeSTLogLevel()  ;
90 
91 void DispHal(const char* title, const void* data, size_t length);
92 
93 #ifdef __cplusplus
94 };
95 #endif
96