-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATT_LoRaWAN_UBlox_GPS.h
124 lines (101 loc) · 3.67 KB
/
ATT_LoRaWAN_UBlox_GPS.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
/*
* Copyright (c) 2016 SODAQ. All rights reserved.
*
* This file is part of Sodaq_UBlox_GPS.
*
* Sodaq_UBlox_GPS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Sodaq_UBlox_GPS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Sodaq_UBlox_GPS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SODAQ_UBLOX_GPS_H
#define _SODAQ_UBLOX_GPS_H
#include <WString.h>
#include <stdint.h>
class Sodaq_UBlox_GPS
{
public:
Sodaq_UBlox_GPS();
void init();
void startScan();
bool tryScan(int nrTries);
void endScan();
uint32_t getScanStart();
String getDateTimeString();
double getLat() { return _lat; }
double getLon() { return _lon; }
double getAlt() { return _alt; }
double getSpeed() { return _speed; }
uint8_t getNumberOfSatellites() { return _numSatellites; }
uint16_t getYear() { return (uint16_t)_yy + 2000; } // 2016..
uint8_t getMonth() { return _MM; } // 1..
uint8_t getDay() { return _dd; } // 1..
uint8_t getHour() { return _hh; } // 0..
uint8_t getMinute() { return _mm; } // 0..
uint8_t getSecond() { return _ss; } // 0..
// Sets the optional "Diagnostics and Debug" stream.
void setDiag(Stream &stream) { _diagStream = &stream; }
void setDiag(Stream *stream) { _diagStream = stream; }
/* static */
// returns distance in meters between two positions, both specified
// as signed decimal-degrees latitude and longitude. Uses great-circle
// distance computation for hypothetical sphere of radius 6372795 meters.
// Because Earth is no exact sphere, rounding errors may be up to 0.5%.
// Courtesy of Maarten Lamers
static float distance_between (float lat1, float long1, float lat2, float long2);
private:
void on();
void off();
// Read one byte
uint8_t read();
bool readLine(uint32_t timeout = 10000);
bool parseLine(const char * line);
bool parseGPGGA(const String & line);
bool parseGPGSA(const String & line);
bool parseGPRMC(const String & line);
bool parseGPGSV(const String & line);
bool parseGPGLL(const String & line);
bool parseGPVTG(const String & line);
bool parseGPTXT(const String & line);
bool computeCrc(const char * line, bool do_logging=false);
uint8_t getHex2(const char * s, size_t index);
String num2String(int num, size_t width);
String getField(const String & data, int index);
double convertDegMinToDecDeg(const String & data);
void setDateTime(const String & date, const String & time);
void beginTransmission();
void endTransmission();
void resetValues();
// The (optional) stream to show debug information.
Stream * _diagStream;
uint8_t _addr;
uint8_t _numSatellites;
bool _seenLatLon;
bool _seenTime;
double _lat;
double _lon;
double _alt;
double _speed;
uint8_t _yy;
uint8_t _MM;
uint8_t _dd;
uint8_t _hh;
uint8_t _mm;
uint8_t _ss;
bool _trans_active;
static const char _fieldSep;
char * _inputBuffer;
size_t _inputBufferSize;
uint32_t _scanStart;
uint32_t _scanTimeout;
};
extern Sodaq_UBlox_GPS sodaq_gps;
#endif // _SODAQ_UBLOX_GPS_H