Developer World
Spresense Arduino Library v3.2.0-77d75a4
GNSS.h
Go to the documentation of this file.
1/*
2 * GNSS.h - GNSS include file for the Spresense SDK
3 * Copyright 2018, 2023 Sony Semiconductor Solutions Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef Gnss_h
21#define Gnss_h
22
23#include <Stream.h>
24#include <GNSSPositionData.h>
25
46 FixInvalid = 1,
47 Fix2D,
48 Fix3D
49};
50
63};
64
70 PrintNone = 0,
71 PrintError,
72 PrintWarning,
73 PrintInfo,
74};
75
85};
86
92 GPS = (1U << 0),
93 GLONASS = (1U << 1),
94 SBAS = (1U << 2),
95 QZ_L1CA = (1U << 3),
96 QZ_L1S = (1U << 5),
97 BEIDOU = (1U << 6),
98 GALILEO = (1U << 7),
99 UNKNOWN = 0,
100};
101
107 SpInterval_10Hz = 100,
108 SpInterval_8Hz = 125,
109 SpInterval_5Hz = 200,
110 SpInterval_4Hz = 250,
111 SpInterval_2Hz = 500,
112 SpInterval_1Hz = 1000,
113};
114
125public:
126 unsigned short year;
127 unsigned char month;
128 unsigned char day;
129 unsigned char hour;
130 unsigned char minute;
131 unsigned char sec;
132 unsigned long usec;
133};
134
142public:
143 unsigned short type;
145 unsigned char svid;
146 unsigned char elevation;
147 signed short azimuth;
148 float sigLevel;
149};
150
158public:
160 unsigned char type;
161 unsigned char numSatellites;
162 unsigned char posFixMode;
163 unsigned char posDataExist;
164 unsigned char numSatellitesCalcPos;
165 unsigned short satelliteType;
166 unsigned short posSatelliteType;
167 double latitude;
168 double longitude;
169 double altitude;
170 float velocity;
171 float direction;
172 float pdop;
173 float hdop;
174 float vdop;
175 float tdop;
185 int isSatelliteType(unsigned long index, SpSatelliteType sattype);
186
191 int isSatelliteTypeGps(unsigned long index) { return isSatelliteType(index, GPS); }
192
197 int isSatelliteTypeGlonass(unsigned long index) { return isSatelliteType(index, GLONASS); }
198
206 SpSatelliteType getSatelliteType(unsigned long index);
207
214 unsigned char getSatelliteId(unsigned long index);
215
222 unsigned char getSatelliteElevation(unsigned long index);
223
230 signed short getSatelliteAzimuth(unsigned long index);
231
238 float getSatelliteSignalLevel(unsigned long index);
239};
240
248{
249public:
250 friend SpNavData;
251
256
261
268 int begin(void);
269
277 int begin(Stream& debugOut) { DebugOut = debugOut; return begin(); }
278
284 int end(void);
285
294
300 int stop(void);
301
308 int isUpdate(void);
309
319 int waitUpdate(long timeout = -1);
320
332 void getNavData(SpNavData *navData);
333
334 /*
335 * Get position data size.
336 */
337 unsigned long getPositionDataSize(void);
338
339 /*
340 * Get position data.
341 */
342 unsigned long getPositionData(char *pBinaryBuffer);
343 unsigned long getPositionData(GnssPositionData *pData);
344#ifdef CONFIG_CXD56_GNSS_ADDON
345 unsigned long getPositionData(GnssPositionData2 *pData);
346#endif
347
357 int setPosition(double latitude, double longitude, double altitude = 0);
358
366 int setTime(SpGnssTime *time);
367
374 int setInterval(long interval = 1);
375
383
392
403
411
416 int isGps(void) { return isSelecting(GPS); }
417
422 int useGps(void) { return select(GPS); }
423
428 int unuseGps(void) { return deselect(GPS); }
429
434 int isGlonass(void) { return isSelecting(GLONASS); }
435
440 int useGlonass(void) { return select(GLONASS); }
441
446 int unuseGlonass(void) { return deselect(GLONASS); }
447
455
460 int saveEphemeris(void);
461
467
472 void* getDCReport(void);
473
478 void start1PPS(void);
479
484 void stop1PPS(void);
485
486protected:
487 int fd_; /* file descriptor */
488 unsigned long SatelliteSystem; /* satellite type */
489 SpNavData NavData; /* copy pos data */
490
491 unsigned long inquireSatelliteType(void);
492
493 /* Debug Print */
494 static Stream& DebugOut;
495 static SpPrintLevel DebugPrintLevel;
496 inline static void printMessage(SpPrintLevel level, const char* str)
497 {
498 if (level <= DebugPrintLevel)
499 DebugOut.print(str);
500 }
501};
502
503#ifdef CONFIG_CXD56_GNSS_ADDON
504class SpGnssAddon : public SpGnss {
505public:
506 int begin(void);
507 int begin(Stream& debugOut) { DebugOut = debugOut; return begin(); }
508};
509#endif
510
513#endif // Gnss_h
Time acquired from the satellite at the time of positioning.
Definition: GNSS.h:124
unsigned char minute
Definition: GNSS.h:130
unsigned char hour
Definition: GNSS.h:129
unsigned char sec
Definition: GNSS.h:131
unsigned short year
Definition: GNSS.h:126
unsigned char month
Definition: GNSS.h:127
unsigned long usec
Definition: GNSS.h:132
unsigned char day
Definition: GNSS.h:128
GNSS controller.
Definition: GNSS.h:248
int setInterval(long interval=1)
Set the pos interval time.
int unuseGlonass(void)
[Obsolete] Unuse Glonass for positioning
Definition: GNSS.h:446
int setInterval(SpIntervalFreq interval)
Set the pos interval time.
int removeEphemeris(void)
Remove the backup data stored in the Flash.
int end(void)
Inactivate GNSS device.
int isSelecting(SpSatelliteType sattype)
Returns whether the specified satellite system is selecting.
int useGps(void)
[Obsolete] Use GPS for positioning
Definition: GNSS.h:422
int begin(void)
Activate GNSS device.
SpGnss()
Create SpGnss object.
int setTime(SpGnssTime *time)
Set the current time for hot start.
int setPosition(double latitude, double longitude, double altitude=0)
Set the current position for hot start.
int saveEphemeris(void)
Save the data stored in the backup RAM to Flash.
int begin(Stream &debugOut)
Activate GNSS device.
Definition: GNSS.h:277
int waitUpdate(long timeout=-1)
Wait for position information to be updated.
int isUpdate(void)
Check position information is updated and return immediately.
void setDebugMode(SpPrintLevel level)
Set debug mode.
int unuseGps(void)
[Obsolete] Unuse GPS for positioning
Definition: GNSS.h:428
void * getDCReport(void)
Get the QZQSM DC report data.
void start1PPS(void)
Start 1PPS output.
int isGlonass(void)
[Obsolete] Returns whether Glonass is used as satellite system
Definition: GNSS.h:434
int isGps(void)
[Obsolete] Returns whether GPS is used as satellite system
Definition: GNSS.h:416
~SpGnss()
Destroy SpGnss object.
int useGlonass(void)
[Obsolete] Use Glonass for positioning
Definition: GNSS.h:440
int select(SpSatelliteType sattype)
Add specified satellite system to selection for positioning.
void stop1PPS(void)
Stop 1PPS output.
void getNavData(SpNavData *navData)
Get updated positioning information from GNSS.
int stop(void)
Stop positioning.
int deselect(SpSatelliteType sattype)
Remove specified satellite system to selection for positioning.
int start(SpStartMode mode=HOT_START)
Start positioning.
GNSS positioning data.
Definition: GNSS.h:157
int isSatelliteTypeGlonass(unsigned long index)
[Obsolete] Check if the specified satellite is Glonass
Definition: GNSS.h:197
unsigned char posFixMode
Definition: GNSS.h:162
unsigned char getSatelliteElevation(unsigned long index)
Get satellite elevation.
SpSatelliteType getSatelliteType(unsigned long index)
Get satellite type.
unsigned short satelliteType
Definition: GNSS.h:165
double longitude
Definition: GNSS.h:168
double altitude
Definition: GNSS.h:169
SpGnssTime time
Definition: GNSS.h:159
float direction
Definition: GNSS.h:171
float hdop
Definition: GNSS.h:173
int isSatelliteType(unsigned long index, SpSatelliteType sattype)
Check if the specified satellite is GPS.
unsigned char type
Definition: GNSS.h:160
unsigned short posSatelliteType
Definition: GNSS.h:166
float pdop
Definition: GNSS.h:172
float getSatelliteSignalLevel(unsigned long index)
Get satellite signal level(C/N)
SpSatellite satellite[24]
Definition: GNSS.h:176
float tdop
Definition: GNSS.h:175
unsigned char getSatelliteId(unsigned long index)
Get satellite ID(SVID)
int isSatelliteTypeGps(unsigned long index)
[Obsolete] Check if the specified satellite is GPS
Definition: GNSS.h:191
float vdop
Definition: GNSS.h:174
unsigned char posDataExist
Definition: GNSS.h:163
float velocity
Definition: GNSS.h:170
unsigned char numSatellites
Definition: GNSS.h:161
unsigned char numSatellitesCalcPos
Definition: GNSS.h:164
signed short getSatelliteAzimuth(unsigned long index)
Get satellite azimuth.
double latitude
Definition: GNSS.h:167
Satellite information using positioning.
Definition: GNSS.h:141
unsigned char svid
Definition: GNSS.h:145
signed short azimuth
Definition: GNSS.h:147
float sigLevel
Definition: GNSS.h:148
unsigned short type
Definition: GNSS.h:143
unsigned char elevation
Definition: GNSS.h:146
SpPvtType
Set the GNSS positioning type.
Definition: GNSS.h:80
SpStartMode
Mode to set to GNSS at the start of positioning.
Definition: GNSS.h:59
SpSatelliteType
Satellite system type.
Definition: GNSS.h:91
SpIntervalFreq
Interval frequency.
Definition: GNSS.h:106
SpPrintLevel
Set the debug log output level.
Definition: GNSS.h:69
SpFixMode
status of pos fix
Definition: GNSS.h:45
@ SpPvtTypeReserv
Definition: GNSS.h:83
@ SpPvtTypeUsers
Definition: GNSS.h:84
@ SpPvtTypeNone
Definition: GNSS.h:81
@ SpPvtTypeGnss
Definition: GNSS.h:82
@ WARM_START
Definition: GNSS.h:61
@ HOT_START
Definition: GNSS.h:62
@ COLD_START
Definition: GNSS.h:60
Definition: GNSSPositionData.h:26