• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cutils/properties.h>
29 #include <log/log.h>
30 
31 #include "data_types.h"
32 
33 #define DISP_NCI ProtoDispAdapterDisplayNciPacket
34 #define HAL_LOG_TAG "StNfcHal"
35 
36 extern unsigned char hal_trace_level;
37 extern unsigned char hal_conf_trace_level;
38 extern int GetNumValue(const char* name, void* p_value, unsigned long len);
39 extern int GetByteArrayValue(const char* name, char* pValue, long bufflen,
40                              long* len);
41 extern int GetStrValue(const char* name, char* pValue, unsigned long l);
42 
43 /* #######################
44  * Set the log module name in .conf file
45  * ########################## */
46 #define NAME_STNFC_HAL_LOGLEVEL "STNFC_HAL_LOGLEVEL"
47 #define NAME_CE_ON_SWITCH_OFF_STATE "CE_ON_SWITCH_OFF_STATE"
48 #define NAME_STNFC_FW_PATH_STORAGE "STNFC_FW_PATH_STORAGE"
49 #define NAME_STNFC_FW_BIN_NAME "STNFC_FW_BIN_NAME"
50 #define NAME_STNFC_FW_CONF_NAME "STNFC_FW_CONF_NAME"
51 #define NAME_STNFC_FW_BIN_NAME "STNFC_FW_BIN_NAME"
52 #define NAME_STNFC_FW_DEBUG_ENABLED "STNFC_FW_DEBUG_ENABLED"
53 #define NAME_CORE_CONF_PROP "CORE_CONF_PROP"
54 #define NAME_STNFC_CONTROL_CLK "STNFC_CONTROL_CLK"
55 #define NAME_STNFC_UWB_LIB_NAME "STNFC_UWB_LIB_NAME"
56 #define NAME_STNFC_ACTIVERW_TIMER "STNFC_ACTIVERW_TIMER"
57 #define NAME_STNFC_FW_SWP_LOG_SIZE "STNFC_FW_SWP_LOG_SIZE"
58 #define NAME_STNFC_FW_RF_LOG_SIZE "STNFC_FW_RF_LOG_SIZE"
59 #define NAME_STNFC_REMOTE_FIELD_TIMER "STNFC_REMOTE_FIELD_TIMER"
60 
61 /* #######################
62  * Set the logging level
63  * ######################## */
64 #define STNFC_TRACE_LEVEL_NONE 0x00
65 #define STNFC_TRACE_LEVEL_ERROR 0x01
66 #define STNFC_TRACE_LEVEL_WARNING 0x02
67 #define STNFC_TRACE_LEVEL_DEBUG 0x03
68 #define STNFC_TRACE_LEVEL_VERBOSE 0x04
69 #define STNFC_TRACE_LEVEL_MASK 0x0F
70 #define STNFC_TRACE_FLAG_PRIVACY 0x10
71 
72 #define STLOG_HAL_V(...)                                      \
73   {                                                           \
74     if ((hal_trace_level & STNFC_TRACE_LEVEL_MASK) >=         \
75         STNFC_TRACE_LEVEL_VERBOSE)                            \
76       LOG_PRI(ANDROID_LOG_VERBOSE, HAL_LOG_TAG, __VA_ARGS__); \
77   }
78 #define STLOG_HAL_D(...)                                                       \
79   {                                                                            \
80     if ((hal_trace_level & STNFC_TRACE_LEVEL_MASK) >= STNFC_TRACE_LEVEL_DEBUG) \
81       LOG_PRI(ANDROID_LOG_DEBUG, HAL_LOG_TAG, __VA_ARGS__);                    \
82   }
83 #define STLOG_HAL_W(...)                                   \
84   {                                                        \
85     if ((hal_trace_level & STNFC_TRACE_LEVEL_MASK) >=      \
86         STNFC_TRACE_LEVEL_WARNING)                         \
87       LOG_PRI(ANDROID_LOG_WARN, HAL_LOG_TAG, __VA_ARGS__); \
88   }
89 #define STLOG_HAL_E(...)                                                       \
90   {                                                                            \
91     if ((hal_trace_level & STNFC_TRACE_LEVEL_MASK) >= STNFC_TRACE_LEVEL_ERROR) \
92       LOG_PRI(ANDROID_LOG_ERROR, HAL_LOG_TAG, __VA_ARGS__);                    \
93   }
94 /*******************************************************************************
95 **
96 ** Function:        InitializeSTLogLevel
97 **
98 ** Description:     Initialize and get global logging level from
99 **                  Android property nfc.app_log_level.
100 **
101 ** Returns:         Global log level:
102 **                  STNFC_TRACE_LEVEL_NONE    0     * No trace messages to be
103 **                                                     generated
104 **                  STNFC_TRACE_LEVEL_ERROR   1     * Error condition trace
105 **                                                     messages
106 **                  STNFC_TRACE_LEVEL_WARNING 2     * Warning condition trace
107 **                                                     messages
108 **                  STNFC_TRACE_LEVEL_DEBUG   3     * Debug messages (general)
109 **
110 *******************************************************************************/
111 unsigned char InitializeSTLogLevel();
112 
113 void DispHal(const char* title, const void* data, size_t length);
114 
115 void deInitializeHalLog();
116 
117 #ifdef __cplusplus
118 };
119 #endif
120