-
Notifications
You must be signed in to change notification settings - Fork 1
/
UbxCfgMsg.h
370 lines (302 loc) · 9.9 KB
/
UbxCfgMsg.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#ifndef __AUBXLIB_CFGMSG_H_
#define __AUBXLIB_CFGMSG_H_
#include "Arduino.h"
/* ****************************************************************************
UBX CFG class message definitions.
****************************************************************************/
/* ************************************************************************* */
struct UbxCfgMsgMTPayload {
unsigned short cfgMsgClsID = 0;
byte rate[6] = { 0 };
};
class UbxCfgMsgMT: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.cfgMsgClsID);
structToBuffer (buffer, 2, &pl.rate[0]);
structToBuffer (buffer, 3, &pl.rate[1]);
structToBuffer (buffer, 4, &pl.rate[2]);
structToBuffer (buffer, 5, &pl.rate[3]);
structToBuffer (buffer, 6, &pl.rate[4]);
structToBuffer (buffer, 7, &pl.rate[5]);
};
public:
UbxCfgMsgMTPayload pl;
UbxCfgMsgMT () {
h.msgClsID = UBX_CFG_MSG;
h.length = 8;
};
};
/* ************************************************************************* */
struct UbxCfgMsgPayload {
unsigned short cfgMsgClsID = 0;
byte rate = 0;
};
class UbxCfgMsg: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.cfgMsgClsID);
structToBuffer (buffer, 2, &pl.rate);
};
public:
UbxCfgMsgPayload pl;
UbxCfgMsg () {
h.msgClsID = UBX_CFG_MSG;
h.length = 3;
};
};
/* ************************************************************************* */
struct UbxCfgMsgPollReqPayload {
unsigned short cfgMsgClsID = 0;
};
class UbxCfgMsgPollReq: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.cfgMsgClsID);
};
public:
UbxCfgMsgPollReqPayload pl;
UbxCfgMsgPollReq () {
h.msgClsID = UBX_CFG_MSG;
h.length = 2;
};
};
/* ************************************************************************* */
struct UbxCfgCfgPayload {
byte clearMask [4] = { 0 };
byte saveMask [4] = { 0 };
byte loadMask [4] = { 0 };
byte deviceMask = 0; // optional field
};
class UbxCfgCfg: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
buffer[0] = pl.clearMask[0];
buffer[1] = pl.clearMask[1];
buffer[2] = pl.clearMask[2];
buffer[3] = pl.clearMask[3];
buffer[4] = pl.saveMask[0];
buffer[5] = pl.saveMask[1];
buffer[6] = pl.saveMask[2];
buffer[7] = pl.saveMask[3];
buffer[8] = pl.loadMask[0];
buffer[9] = pl.loadMask[1];
buffer[10] = pl.loadMask[2];
buffer[11] = pl.loadMask[3];
};
public:
UbxCfgCfgPayload pl;
UbxCfgCfg () {
h.msgClsID = UBX_CFG_CFG;
h.length = 12;
};
unsigned short toArrayWithDeviceMask (byte* buffer, unsigned short bLen) {
h.length = 13;
if ((buffer != NULL) && (bLen >= 8 + h.length)) {
headerToArray (buffer, bLen);
payloadToArray (buffer + 6, bLen - 6);
buffer[12] = pl.deviceMask;
checksumToArray (buffer, bLen);
h.length = 12; // reset length
return h.length + 1 + 8;
} else {
h.length = 12; // reset length
return 0;
}
};
};
/* ************************************************************************* */
struct UbxCfgNMEAPayload {
byte filter = 0;
byte version = 0;
byte numSV = 0;
byte flags = 0;
};
class UbxCfgNMEA: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.filter);
structToBuffer (buffer, 1, &pl.version);
structToBuffer (buffer, 2, &pl.numSV);
structToBuffer (buffer, 3, &pl.flags);
};
public:
UbxCfgNMEAPayload pl;
UbxCfgNMEA () {
h.msgClsID = UBX_CFG_NMEA;
h.length = 4;
};
UbxCfgNMEA (byte* buffer, unsigned short len) {
h.msgClsID = UBX_CFG_NMEA;
h.length = 4;
if (len == 12) {
bufferToStruct (buffer, 6, &pl.filter);
bufferToStruct (buffer, 7, &pl.version);
bufferToStruct (buffer, 8, &pl.numSV);
bufferToStruct (buffer, 9, &pl.flags);
bufferToChecksum (buffer, 10, &checksum);
valid = isChecksumValid (buffer, 2, h.length + 4, checksum);
}
};
};
/* ************************************************************************* */
struct UbxCfgRatePayload {
unsigned short measRate = 0;
unsigned short navRate = 0;
unsigned short timeRef = 0;
};
class UbxCfgRate: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.measRate);
structToBuffer (buffer, 2, &pl.navRate);
structToBuffer (buffer, 4, &pl.timeRef);
};
public:
UbxCfgRatePayload pl;
UbxCfgRate () {
h.msgClsID = UBX_CFG_RATE;
h.length = 6;
};
UbxCfgRate (byte* buffer, unsigned short len) {
h.msgClsID = UBX_CFG_RATE;
h.length = 6;
if (len == 14) {
bufferToStruct (buffer, 6, &pl.measRate);
bufferToStruct (buffer, 8, &pl.navRate);
bufferToStruct (buffer, 10, &pl.timeRef);
bufferToChecksum (buffer, 12, &checksum);
valid = isChecksumValid (buffer, 2, h.length + 4, checksum);
}
};
};
/* ************************************************************************* */
struct UbxCfgRXMPayload {
byte reserved1 = 8; // always set to 8!
byte lpMode = 0;
};
class UbxCfgRXM: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
buffer[0] = pl.reserved1;
buffer[1] = pl.lpMode;
};
public:
UbxCfgRXMPayload pl;
UbxCfgRXM () {
h.msgClsID = UBX_CFG_RXM;
h.length = 2;
};
UbxCfgRXM (byte* buffer, unsigned short len) {
h.msgClsID = UBX_CFG_RXM;
h.length = 2;
if (len == 10) {
bufferToStruct (buffer, 6, &pl.reserved1);
bufferToStruct (buffer, 7, &pl.lpMode);
bufferToChecksum (buffer, 8, &checksum);
valid = isChecksumValid (buffer, 2, h.length + 4, checksum);
}
};
};
/* ************************************************************************* */
struct UbxCfgSBASPayload {
byte mode = 0;
byte usage = 0;
byte maxSBAS = 0;
byte scanmode2 = 0;
byte scanmode1 [4] = { 0 };
};
class UbxCfgSBAS: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
buffer[0] = pl.mode;
buffer[1] = pl.usage;
buffer[2] = pl.maxSBAS;
buffer[3] = pl.scanmode2;
buffer[4] = pl.scanmode1[0];
buffer[5] = pl.scanmode1[1];
buffer[6] = pl.scanmode1[2];
buffer[7] = pl.scanmode1[3];
};
public:
UbxCfgSBASPayload pl;
UbxCfgSBAS () {
h.msgClsID = UBX_CFG_SBAS;
h.length = 8;
};
UbxCfgSBAS (byte* buffer, unsigned short len) {
h.msgClsID = UBX_CFG_SBAS;
h.length = 8;
if (len == 16) {
bufferToStruct (buffer, 6, &pl.mode);
bufferToStruct (buffer, 7, &pl.usage);
bufferToStruct (buffer, 8, &pl.maxSBAS);
bufferToStruct (buffer, 9, &pl.scanmode2);
bufferToStruct (buffer, 10, &pl.scanmode1[0]);
bufferToStruct (buffer, 11, &pl.scanmode1[1]);
bufferToStruct (buffer, 12, &pl.scanmode1[2]);
bufferToStruct (buffer, 13, &pl.scanmode1[3]);
bufferToChecksum (buffer, 14, &checksum);
valid = isChecksumValid (buffer, 2, h.length + 4, checksum);
}
};
};
/* ************************************************************************* */
struct UbxCfgPMPayload {
byte version = 0;
byte reserved1 = 0;
byte reserved2 = 0;
byte reserved3 = 0;
byte flags [4] = { 0 };
unsigned int updatePeriod = 0;
unsigned int searchPeriod = 0;
unsigned int gridOffset = 0;
unsigned short onTime = 0;
unsigned short minAcqTime = 0;
};
class UbxCfgPM: public UbxPacket {
private:
void payloadToArray (byte* buffer, unsigned short bLen) {
structToBuffer (buffer, 0, &pl.version);
structToBuffer (buffer, 1, &pl.reserved1);
structToBuffer (buffer, 2, &pl.reserved2);
structToBuffer (buffer, 3, &pl.reserved3);
structToBuffer (buffer, 4, &pl.flags[0]);
structToBuffer (buffer, 5, &pl.flags[1]);
structToBuffer (buffer, 6, &pl.flags[2]);
structToBuffer (buffer, 7, &pl.flags[3]);
structToBuffer (buffer, 8, &pl.updatePeriod);
structToBuffer (buffer, 12, &pl.searchPeriod);
structToBuffer (buffer, 16, &pl.gridOffset);
structToBuffer (buffer, 20, &pl.onTime);
structToBuffer (buffer, 22, &pl.minAcqTime);
};
public:
UbxCfgPMPayload pl;
UbxCfgPM () {
h.msgClsID = UBX_CFG_PM;
h.length = 24;
};
UbxCfgPM (byte* buffer, unsigned short len) {
h.msgClsID = UBX_CFG_PM;
h.length = 24;
if (len == 32) {
bufferToStruct (buffer, 6, &pl.version);
bufferToStruct (buffer, 7, &pl.reserved1);
bufferToStruct (buffer, 8, &pl.reserved2);
bufferToStruct (buffer, 9, &pl.reserved3);
bufferToStruct (buffer, 10, &pl.flags[0]);
bufferToStruct (buffer, 11, &pl.flags[1]);
bufferToStruct (buffer, 12, &pl.flags[2]);
bufferToStruct (buffer, 13, &pl.flags[3]);
bufferToStruct (buffer, 14, &pl.updatePeriod);
bufferToStruct (buffer, 18, &pl.searchPeriod);
bufferToStruct (buffer, 22, &pl.gridOffset);
bufferToStruct (buffer, 26, &pl.onTime);
bufferToStruct (buffer, 28, &pl.minAcqTime);
bufferToChecksum (buffer, 30, &checksum);
valid = isChecksumValid (buffer, 2, h.length + 4, checksum);
}
};
};
#endif