-
Notifications
You must be signed in to change notification settings - Fork 3
/
ubx_log.h
executable file
·260 lines (218 loc) · 6.66 KB
/
ubx_log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*******************************************************************************
*
* Copyright (C) u-blox AG
* u-blox AG, Thalwil, Switzerland
*
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
*
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR U-BLOX MAKES ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*
*******************************************************************************
*
* Project: PE_ANS
*
******************************************************************************/
/*!
\file
\brief Interface for the logger
provide logging capabilities
*/
/*******************************************************************************
* $Id: ubx_log.h 64760 2013-01-11 15:26:11Z michael.ammann $
******************************************************************************/
#ifndef __UBX_LOG_H__
#define __UBX_LOG_H__
#define LOG_TAG "u-blox" //!< Tag for logging
#define LOG_NDEBUG 0
#include <cutils/log.h>
#ifdef SUPL_ENABLED
#include "ULP-PDU.h"
#include "PDU.h"
#endif
// macro names have changed since Android 4.0.3 (ALOGV() instead of LOGV() etc. in 4.0.9)
// see system/core/include/cutils/log.h
#ifndef LOGV
# define LOGV ALOGV
#endif
#ifndef LOGD
# define LOGD ALOGD
#endif
#ifndef LOGI
# define LOGI ALOGI
#endif
#ifndef LOGW
# define LOGW ALOGW
#endif
#ifndef LOGE
# define LOGE ALOGE
#endif
#define LOG_SPECIAL_BUFFER_COUNT 4
#if defined MALLOC_DEBUG
#define MC_MALLOC(size) debug_malloc(size)
#define MC_CALLOC(size,num) debug_calloc(size,num)
#define MC_FREE(data) debug_free(data)
inline void *debug_malloc(size_t size);
inline void *debug_calloc(size_t size, size_t num);
inline void debug_free(void *data);
#else
#define MC_MALLOC(size) malloc(size) //!< macro for debug malloc
#define MC_CALLOC(size,num) calloc(size,num) //!< macro for debug calloc
#define MC_FREE(data) free(data) //!< macro for debugging free
#endif
///////////////////////////////////////////////////////////////////////////////
// value to string conversion helpers
static const char* _strGpsPositionMode[] = {
"GPS_POSITION_MODE_STANDALONE",
"GPS_POSITION_MODE_MS_BASED",
"GPS_POSITION_MODE_MS_ASSISTED"
};
static const char*_strGpsPositionRecurrence[] = {
"GPS_POSITION_RECURRENCE_PERIODIC",
"GPS_POSITION_RECURRENCE_SINGLE"
};
static const char* _strGpsStatusValue[] = {
"GPS_STATUS_NONE",
"GPS_STATUS_SESSION_BEGIN",
"GPS_STATUS_SESSION_END",
"GPS_STATUS_ENGINE_ON",
"GPS_STATUS_ENGINE_OFF",
};
static const char* _xstrGpsLocationFlags[] = {
"GPS_LOCATION_HAS_LAT_LONG",
"GPS_LOCATION_HAS_ALTITUDE",
"GPS_LOCATION_HAS_SPEED",
"GPS_LOCATION_HAS_BEARING",
"GPS_LOCATION_HAS_ACCURACY",
};
static const char* _xstrGpsCapabilityFlags[] = {
"GPS_CAPABILITY_SCHEDULING",
"GPS_CAPABILITY_MSB",
"GPS_CAPABILITY_MSA",
"GPS_CAPABILITY_SINGLE_SHOT",
"GPS_CAPABILITY_ON_DEMAND_TIME",
};
static const char* _xstrGpsAidingData[] = {
"GPS_DELETE_EPHEMERIS",
"GPS_DELETE_ALMANAC",
"GPS_DELETE_POSITION",
"GPS_DELETE_TIME",
"GPS_DELETE_IONO",
"GPS_DELETE_UTC",
"GPS_DELETE_HEALTH",
"GPS_DELETE_SVDIR",
"GPS_DELETE_SVSTEER",
"GPS_DELETE_SADATA",
"GPS_DELETE_RTI",
NULL,
NULL,
NULL,
NULL,
"GPS_DELETE_CELLDB_INFO",
// "GPS_DELETE_ALL", 0xFFFF
};
static const char* _strAGpsType[] = {
NULL,
"AGPS_TYPE_SUPL",
"AGPS_TYPE_C2K",
};
static const char* _strAGpsSetIDType[] = {
"AGPS_SETID_TYPE_NONE",
"AGPS_SETID_TYPE_IMSI",
"AGPS_SETID_TYPE_MSISDN",
};
static const char* _strGpsNiType[] = {
NULL,
"GPS_NI_TYPE_VOICE",
"GPS_NI_TYPE_UMTS_SUPL",
"GPS_NI_TYPE_UMTS_CTRL_PLANE",
};
static const char* _xstrGpsNiNotifyFlags[] = {
"GPS_NI_NEED_NOTIFY",
"GPS_NI_NEED_VERIFY",
"GPS_NI_PRIVACY_OVERRIDE",
};
static const char* _strGpsUserResponseType[] = {
NULL,
"GPS_NI_RESPONSE_ACCEPT",
"GPS_NI_RESPONSE_DENY",
"GPS_NI_RESPONSE_NORESP",
};
static const char* _strGpsNiEncodingType[] = {
// "GPS_ENC_UNKNOWN", = -1
"GPS_ENC_NONE",
"GPS_ENC_SUPL_GSM_DEFAULT",
"GPS_ENC_SUPL_UTF8",
"GPS_ENC_SUPL_UCS2",
};
static const char* _strAGpsStatusValue[] = {
NULL,
"GPS_REQUEST_AGPS_DATA_CONN",
"GPS_RELEASE_AGPS_DATA_CONN",
"GPS_AGPS_DATA_CONNECTED",
"GPS_AGPS_DATA_CONN_DONE",
"GPS_AGPS_DATA_CONN_FAILED",
};
static const char* _strAGpsRefLocation[] = {
NULL,
"AGPS_REF_LOCATION_TYPE_GSM_CELLID",
"AGPS_REF_LOCATION_TYPE_UMTS_CELLID",
"AGPS_REF_LOCATION_TYPE_TYPE_MAC",
};
static const char* _strAgpsRilNetworkType[] = { // Network types for update_network_state "type" parameter
"AGPS_RIL_NETWORK_TYPE_MOBILE",
"AGPS_RIL_NETWORK_TYPE_WIFI",
"AGPS_RIL_NETWORK_TYPE_MOBILE_MMS",
"AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL",
"AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN",
"AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI",
"AGPS_RIL_NETWORK_TTYPE_WIMAX",
};
static const char* _xstrAgpsRilRequestSetId[] = {
"AGPS_RIL_REQUEST_SETID_IMSI",
"AGPS_RIL_REQUEST_SETID_MSISDN",
};
static const char* _xstrAgpsRilRequestRefLoc[] = {
"AGPS_RIL_REQUEST_REFLOC_CELLID",
"AGPS_RIL_REQUEST_REFLOC_MAC",
};
#define _LOOKUPSTR(v, t) _strLookup(v, _str##t, sizeof(_str##t)/sizeof(_str##t[0]) )
#define _LOOKUPSTRX(v, t) _strLookupX(v, _xstr##t, sizeof(_xstr##t)/sizeof(_xstr##t[0]) )
const char* _strLookup(unsigned int v, const char* const * l, unsigned int n);
const char* _strLookupX(unsigned int v, const char* const * l, unsigned int n);
#ifdef SUPL_ENABLED
///////////////////////////////////////////////////////////////////////////////
class CLog
{
public:
CLog(const char* name = "GPS.LOG", int max=64*1024, bool verbose = false);
~CLog();
void write(unsigned int code, const char* fmt, ...);
void txt(int code, const char* pTxt);
void writeFile(const char* pBuf, int len);
protected:
void open(const char* name, int max);
static const char* timestamp(char* buf = NULL);
char m_name[256];
int m_max;
bool m_verbose;
};
void logSupl(const struct ULP_PDU * pMsg, bool incoming);
void logRRLP(const PDU_t *pRrlpMsg, bool incoming);
extern CLog logGps;
extern CLog logAgps;
#define LOGGPS(code, ...) logGps.write(code, __VA_ARGS__)
#define LOGAGPS(code, ...) logApps.write(code, __VA_ARGS__)
#else
#define LOGGPS(code, ...)
#define LOGAGPS(code, ...)
#endif
#endif /* __UBX_LOG_H__ */