Hopefully done with everything in the location
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -431,7 +431,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
|
|||||||
float ilat = 0;
|
float ilat = 0;
|
||||||
float ilon = 0;
|
float ilon = 0;
|
||||||
float ispeed = 0;
|
float ispeed = 0;
|
||||||
int ialt = 0;
|
float ialt = 0;
|
||||||
int ivsat = 0;
|
int ivsat = 0;
|
||||||
int iusat = 0;
|
int iusat = 0;
|
||||||
float iaccuracy = 0;
|
float iaccuracy = 0;
|
||||||
@@ -473,7 +473,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
|
|||||||
if (lat != NULL) *lat = ilat;
|
if (lat != NULL) *lat = ilat;
|
||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (speed != NULL) *speed = ispeed;
|
if (speed != NULL) *speed = ispeed;
|
||||||
if (alt != NULL) *alt = ialt;
|
if (alt != NULL) *alt = static_cast<int>(ialt);
|
||||||
if (vsat != NULL) *vsat = ivsat;
|
if (vsat != NULL) *vsat = ivsat;
|
||||||
if (usat != NULL) *usat = iusat;
|
if (usat != NULL) *usat = iusat;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
|
@@ -440,18 +440,18 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
// TODO(?) Can 1 be returned
|
// TODO(?) Can 1 be returned
|
||||||
if (fixMode == 1 || fixMode == 2 || fixMode == 3) {
|
if (fixMode == 1 || fixMode == 2 || fixMode == 3) {
|
||||||
// init variables
|
// init variables
|
||||||
float ilat = 0;
|
float ilat = 0;
|
||||||
float ilon = 0;
|
float ilon = 0;
|
||||||
float ispeed = 0;
|
float ispeed = 0;
|
||||||
int ialt = 0;
|
float ialt = 0;
|
||||||
int ivsat = 0;
|
int ivsat = 0;
|
||||||
int iusat = 0;
|
int iusat = 0;
|
||||||
float iaccuracy = 0;
|
float iaccuracy = 0;
|
||||||
int iyear = 0;
|
int iyear = 0;
|
||||||
int imonth = 0;
|
int imonth = 0;
|
||||||
int iday = 0;
|
int iday = 0;
|
||||||
int ihour = 0;
|
int ihour = 0;
|
||||||
int imin = 0;
|
int imin = 0;
|
||||||
float secondWithSS = 0;
|
float secondWithSS = 0;
|
||||||
|
|
||||||
streamSkipUntil(','); // GPS satellite valid numbers
|
streamSkipUntil(','); // GPS satellite valid numbers
|
||||||
@@ -463,13 +463,13 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
streamSkipUntil(','); // E/W Indicator, E=east or W=west
|
streamSkipUntil(','); // E/W Indicator, E=east or W=west
|
||||||
|
|
||||||
// Date. Output format is ddmmyy
|
// Date. Output format is ddmmyy
|
||||||
iday = streamGetInt(static_cast<int8_t>(2)); // Two digit day
|
iday = streamGetInt(static_cast<int8_t>(2)); // Two digit day
|
||||||
imonth = streamGetInt(static_cast<int8_t>(2)); // Two digit month
|
imonth = streamGetInt(static_cast<int8_t>(2)); // Two digit month
|
||||||
iyear = streamGetInt(','); // Two digit year
|
iyear = streamGetInt(','); // Two digit year
|
||||||
|
|
||||||
// UTC Time. Output format is hhmmss.s
|
// UTC Time. Output format is hhmmss.s
|
||||||
ihour = streamGetInt(static_cast<int8_t>(2)); // Two digit hour
|
ihour = streamGetInt(static_cast<int8_t>(2)); // Two digit hour
|
||||||
imin = streamGetInt(static_cast<int8_t>(2)); // Two digit minute
|
imin = streamGetInt(static_cast<int8_t>(2)); // Two digit minute
|
||||||
secondWithSS = streamGetFloat(','); // 4 digit second with subseconds
|
secondWithSS = streamGetFloat(','); // 4 digit second with subseconds
|
||||||
|
|
||||||
ialt = streamGetFloat(','); // MSL Altitude. Unit is meters
|
ialt = streamGetFloat(','); // MSL Altitude. Unit is meters
|
||||||
@@ -485,7 +485,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
if (lat != NULL) *lat = ilat;
|
if (lat != NULL) *lat = ilat;
|
||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (speed != NULL) *speed = ispeed;
|
if (speed != NULL) *speed = ispeed;
|
||||||
if (alt != NULL) *alt = ialt;
|
if (alt != NULL) *alt = static_cast<int>(ialt);
|
||||||
if (vsat != NULL) *vsat = ivsat;
|
if (vsat != NULL) *vsat = ivsat;
|
||||||
if (usat != NULL) *usat = iusat;
|
if (usat != NULL) *usat = iusat;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
|
@@ -63,7 +63,7 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> {
|
|||||||
float ilat = 0;
|
float ilat = 0;
|
||||||
float ilon = 0;
|
float ilon = 0;
|
||||||
float ispeed = 0;
|
float ispeed = 0;
|
||||||
int ialt = 0;
|
float ialt = 0;
|
||||||
int ivsat = 0;
|
int ivsat = 0;
|
||||||
int iusat = 0;
|
int iusat = 0;
|
||||||
float iaccuracy = 0;
|
float iaccuracy = 0;
|
||||||
@@ -105,7 +105,7 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> {
|
|||||||
if (lat != NULL) *lat = ilat;
|
if (lat != NULL) *lat = ilat;
|
||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (speed != NULL) *speed = ispeed;
|
if (speed != NULL) *speed = ispeed;
|
||||||
if (alt != NULL) *alt = ialt;
|
if (alt != NULL) *alt = static_cast<int>(ialt);
|
||||||
if (vsat != NULL) *vsat = ivsat;
|
if (vsat != NULL) *vsat = ivsat;
|
||||||
if (usat != NULL) *usat = iusat;
|
if (usat != NULL) *usat = iusat;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
|
@@ -428,7 +428,9 @@ class TinyGsmSaraR4
|
|||||||
* GSM/GPS/GNSS/GLONASS Location functions
|
* GSM/GPS/GNSS/GLONASS Location functions
|
||||||
* NOTE: u-blox modules use the same function to get location data from both
|
* NOTE: u-blox modules use the same function to get location data from both
|
||||||
* GSM tower triangulation and from dedicated GPS/GNSS/GLONASS receivers. The
|
* GSM tower triangulation and from dedicated GPS/GNSS/GLONASS receivers. The
|
||||||
* only difference in which sensor the data is requested from.
|
* only difference in which sensor the data is requested from. If a GNSS
|
||||||
|
* location is requested from a modem without a GNSS receiver installed on the
|
||||||
|
* I2C port, the GSM-based "Cell Locate" location will be returned instead.
|
||||||
*/
|
*/
|
||||||
protected:
|
protected:
|
||||||
bool enableGPSImpl() {
|
bool enableGPSImpl() {
|
||||||
@@ -475,11 +477,12 @@ class TinyGsmSaraR4
|
|||||||
return getUbloxLocationRaw(1);
|
return getUbloxLocationRaw(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon, float* speed = 0,
|
bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon,
|
||||||
int* alt = 0, int* vsat = 0, int* usat = 0,
|
float* speed = 0, int* alt = 0, int* vsat = 0,
|
||||||
float* accuracy = 0, int* year = 0, int* month = 0,
|
int* usat = 0, float* accuracy = 0,
|
||||||
int* day = 0, int* hour = 0, int* minute = 0,
|
int* year = 0, int* month = 0, int* day = 0,
|
||||||
int* second = 0) {
|
int* hour = 0, int* minute = 0,
|
||||||
|
int* second = 0) {
|
||||||
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
||||||
// <mode> - 2: single shot position
|
// <mode> - 2: single shot position
|
||||||
// <sensor> - 2: use cellular CellLocate location information
|
// <sensor> - 2: use cellular CellLocate location information
|
||||||
@@ -506,7 +509,7 @@ class TinyGsmSaraR4
|
|||||||
float ilat = 0;
|
float ilat = 0;
|
||||||
float ilon = 0;
|
float ilon = 0;
|
||||||
float ispeed = 0;
|
float ispeed = 0;
|
||||||
int ialt = 0;
|
float ialt = 0;
|
||||||
int iusat = 0;
|
int iusat = 0;
|
||||||
float iaccuracy = 0;
|
float iaccuracy = 0;
|
||||||
int iyear = 0;
|
int iyear = 0;
|
||||||
@@ -526,23 +529,26 @@ class TinyGsmSaraR4
|
|||||||
|
|
||||||
ilat = streamGetFloat(','); // Estimated latitude, in degrees
|
ilat = streamGetFloat(','); // Estimated latitude, in degrees
|
||||||
ilon = streamGetFloat(','); // Estimated longitude, in degrees
|
ilon = streamGetFloat(','); // Estimated longitude, in degrees
|
||||||
ialt = streamGetFloat(','); // Estimated altitude, in meters - only for
|
ialt = streamGetFloat(','); // Estimated altitude, in meters - only forGNSS
|
||||||
iaccuracy = streamGetFloat(
|
// positioning, 0 in case of CellLocate
|
||||||
','); // Maximum possible error, in meters (0 - 20000000)
|
if (ialt != 0) { // values not returned for CellLocate
|
||||||
ispeed = streamGetFloat(','); // Speed over ground m/s3
|
iaccuracy = streamGetFloat(','); // Maximum possible error, in meters
|
||||||
streamSkipUntil(','); // Course over ground in degree (0 deg - 360 deg)
|
ispeed = streamGetFloat(','); // Speed over ground m/s3
|
||||||
streamSkipUntil(','); // Vertical accuracy, in meters
|
streamSkipUntil(','); // Course over ground in degree (0 deg - 360 deg)
|
||||||
streamSkipUntil(','); // Sensor used for the position calculation
|
streamSkipUntil(','); // Vertical accuracy, in meters
|
||||||
iusat = streamGetInt(
|
streamSkipUntil(','); // Sensor used for the position calculation
|
||||||
','); // Number of satellite used to calculate the position
|
iusat = streamGetInt(','); // Number of satellite used
|
||||||
streamSkipUntil(','); // Antenna status
|
streamSkipUntil(','); // Antenna status
|
||||||
streamSkipUntil('\n'); // Jamming status
|
streamSkipUntil('\n'); // Jamming status
|
||||||
|
} else {
|
||||||
|
iaccuracy = streamGetFloat('\n'); // Maximum possible error, in meters
|
||||||
|
}
|
||||||
|
|
||||||
// Set pointers
|
// Set pointers
|
||||||
if (lat != NULL) *lat = ilat;
|
if (lat != NULL) *lat = ilat;
|
||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (speed != NULL) *speed = ispeed;
|
if (speed != NULL) *speed = ispeed;
|
||||||
if (alt != NULL) *alt = ialt;
|
if (alt != NULL) *alt = static_cast<int>(ialt);
|
||||||
if (vsat != NULL) *vsat = 0; // Number of satellites viewed not reported;
|
if (vsat != NULL) *vsat = 0; // Number of satellites viewed not reported;
|
||||||
if (usat != NULL) *usat = iusat;
|
if (usat != NULL) *usat = iusat;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
|
@@ -395,7 +395,9 @@ class TinyGsmUBLOX
|
|||||||
* GSM/GPS/GNSS/GLONASS Location functions
|
* GSM/GPS/GNSS/GLONASS Location functions
|
||||||
* NOTE: u-blox modules use the same function to get location data from both
|
* NOTE: u-blox modules use the same function to get location data from both
|
||||||
* GSM tower triangulation and from dedicated GPS/GNSS/GLONASS receivers. The
|
* GSM tower triangulation and from dedicated GPS/GNSS/GLONASS receivers. The
|
||||||
* only difference in which sensor the data is requested from.
|
* only difference in which sensor the data is requested from. If a GNSS
|
||||||
|
* location is requested from a modem without a GNSS receiver installed on the
|
||||||
|
* I2C port, the GSM-based "Cell Locate" location will be returned instead.
|
||||||
*/
|
*/
|
||||||
protected:
|
protected:
|
||||||
bool enableGPSImpl() {
|
bool enableGPSImpl() {
|
||||||
@@ -442,11 +444,12 @@ class TinyGsmUBLOX
|
|||||||
return getUbloxLocationRaw(1);
|
return getUbloxLocationRaw(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon, float* speed = 0,
|
bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon,
|
||||||
int* alt = 0, int* vsat = 0, int* usat = 0,
|
float* speed = 0, int* alt = 0, int* vsat = 0,
|
||||||
float* accuracy = 0, int* year = 0, int* month = 0,
|
int* usat = 0, float* accuracy = 0,
|
||||||
int* day = 0, int* hour = 0, int* minute = 0,
|
int* year = 0, int* month = 0, int* day = 0,
|
||||||
int* second = 0) {
|
int* hour = 0, int* minute = 0,
|
||||||
|
int* second = 0) {
|
||||||
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
||||||
// <mode> - 2: single shot position
|
// <mode> - 2: single shot position
|
||||||
// <sensor> - 2: use cellular CellLocate location information
|
// <sensor> - 2: use cellular CellLocate location information
|
||||||
@@ -473,7 +476,7 @@ class TinyGsmUBLOX
|
|||||||
float ilat = 0;
|
float ilat = 0;
|
||||||
float ilon = 0;
|
float ilon = 0;
|
||||||
float ispeed = 0;
|
float ispeed = 0;
|
||||||
int ialt = 0;
|
float ialt = 0;
|
||||||
int iusat = 0;
|
int iusat = 0;
|
||||||
float iaccuracy = 0;
|
float iaccuracy = 0;
|
||||||
int iyear = 0;
|
int iyear = 0;
|
||||||
@@ -493,23 +496,26 @@ class TinyGsmUBLOX
|
|||||||
|
|
||||||
ilat = streamGetFloat(','); // Estimated latitude, in degrees
|
ilat = streamGetFloat(','); // Estimated latitude, in degrees
|
||||||
ilon = streamGetFloat(','); // Estimated longitude, in degrees
|
ilon = streamGetFloat(','); // Estimated longitude, in degrees
|
||||||
ialt = streamGetFloat(','); // Estimated altitude, in meters - only for
|
ialt = streamGetFloat(','); // Estimated altitude, in meters - only forGNSS
|
||||||
iaccuracy = streamGetFloat(
|
// positioning, 0 in case of CellLocate
|
||||||
','); // Maximum possible error, in meters (0 - 20000000)
|
if (ialt != 0) { // values not returned for CellLocate
|
||||||
ispeed = streamGetFloat(','); // Speed over ground m/s3
|
iaccuracy = streamGetFloat(','); // Maximum possible error, in meters
|
||||||
streamSkipUntil(','); // Course over ground in degree (0 deg - 360 deg)
|
ispeed = streamGetFloat(','); // Speed over ground m/s3
|
||||||
streamSkipUntil(','); // Vertical accuracy, in meters
|
streamSkipUntil(','); // Course over ground in degree (0 deg - 360 deg)
|
||||||
streamSkipUntil(','); // Sensor used for the position calculation
|
streamSkipUntil(','); // Vertical accuracy, in meters
|
||||||
iusat = streamGetInt(
|
streamSkipUntil(','); // Sensor used for the position calculation
|
||||||
','); // Number of satellite used to calculate the position
|
iusat = streamGetInt(','); // Number of satellite used
|
||||||
streamSkipUntil(','); // Antenna status
|
streamSkipUntil(','); // Antenna status
|
||||||
streamSkipUntil('\n'); // Jamming status
|
streamSkipUntil('\n'); // Jamming status
|
||||||
|
} else {
|
||||||
|
iaccuracy = streamGetFloat('\n'); // Maximum possible error, in meters
|
||||||
|
}
|
||||||
|
|
||||||
// Set pointers
|
// Set pointers
|
||||||
if (lat != NULL) *lat = ilat;
|
if (lat != NULL) *lat = ilat;
|
||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (speed != NULL) *speed = ispeed;
|
if (speed != NULL) *speed = ispeed;
|
||||||
if (alt != NULL) *alt = ialt;
|
if (alt != NULL) *alt = static_cast<int>(ialt);
|
||||||
if (vsat != NULL) *vsat = 0; // Number of satellites viewed not reported;
|
if (vsat != NULL) *vsat = 0; // Number of satellites viewed not reported;
|
||||||
if (usat != NULL) *usat = iusat;
|
if (usat != NULL) *usat = iusat;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
|
@@ -122,7 +122,7 @@ class TinyGsmGSMLocation {
|
|||||||
if (lon != NULL) *lon = ilon;
|
if (lon != NULL) *lon = ilon;
|
||||||
if (accuracy != NULL) *accuracy = iaccuracy;
|
if (accuracy != NULL) *accuracy = iaccuracy;
|
||||||
if (iyear < 2000) iyear += 2000;
|
if (iyear < 2000) iyear += 2000;
|
||||||
if (year != NULL) *year = iyear;
|
if (year != NULL) *year = iyear;
|
||||||
if (month != NULL) *month = imonth;
|
if (month != NULL) *month = imonth;
|
||||||
if (day != NULL) *day = iday;
|
if (day != NULL) *day = iday;
|
||||||
if (hour != NULL) *hour = ihour;
|
if (hour != NULL) *hour = ihour;
|
||||||
|
@@ -274,7 +274,8 @@ class TinyGsmModem {
|
|||||||
size_t bytesRead = thisModem().stream.readBytesUntil(
|
size_t bytesRead = thisModem().stream.readBytesUntil(
|
||||||
lastChar, buf, static_cast<size_t>(6));
|
lastChar, buf, static_cast<size_t>(6));
|
||||||
if (bytesRead) {
|
if (bytesRead) {
|
||||||
int16_t res = atoi(buf);
|
buf[bytesRead] = '\0';
|
||||||
|
int16_t res = atoi(buf);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return -9999;
|
return -9999;
|
||||||
@@ -282,8 +283,9 @@ class TinyGsmModem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float inline streamGetFloat(int8_t numChars) {
|
float inline streamGetFloat(int8_t numChars) {
|
||||||
char buf[12];
|
char buf[16];
|
||||||
size_t bytesRead = thisModem().stream.readBytes(buf, numChars);
|
size_t bytesRead = thisModem().stream.readBytes(buf, numChars);
|
||||||
|
DBG("### bytesRead:", bytesRead);
|
||||||
if (bytesRead) {
|
if (bytesRead) {
|
||||||
buf[numChars] = '\0';
|
buf[numChars] = '\0';
|
||||||
int16_t res = atof(buf);
|
int16_t res = atof(buf);
|
||||||
@@ -296,11 +298,13 @@ class TinyGsmModem {
|
|||||||
template <class T>
|
template <class T>
|
||||||
// calling with template only to prevent promotion of char to int
|
// calling with template only to prevent promotion of char to int
|
||||||
float inline streamGetFloat(T lastChar) {
|
float inline streamGetFloat(T lastChar) {
|
||||||
char buf[12];
|
char buf[16];
|
||||||
size_t bytesRead = thisModem().stream.readBytesUntil(
|
size_t bytesRead = thisModem().stream.readBytesUntil(
|
||||||
lastChar, buf, static_cast<size_t>(12));
|
lastChar, buf, static_cast<size_t>(16));
|
||||||
|
DBG("### TEMPL bytesRead:", bytesRead);
|
||||||
if (bytesRead) {
|
if (bytesRead) {
|
||||||
float res = atof(buf);
|
buf[bytesRead] = '\0';
|
||||||
|
float res = atof(buf);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return static_cast<float>(-9999);
|
return static_cast<float>(-9999);
|
||||||
|
Reference in New Issue
Block a user