Add accuracy to GPS output, implent it for ublox
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "TinyGsmBattery.tpp"
|
||||
#include "TinyGsmGPRS.tpp"
|
||||
#include "TinyGsmGPS.tpp"
|
||||
#include "TinyGsmGSMLocation.tpp"
|
||||
#include "TinyGsmModem.tpp"
|
||||
#include "TinyGsmSMS.tpp"
|
||||
@@ -46,6 +47,7 @@ class TinyGsmSaraR4
|
||||
public TinyGsmSSL<TinyGsmSaraR4>,
|
||||
public TinyGsmBattery<TinyGsmSaraR4>,
|
||||
public TinyGsmGSMLocation<TinyGsmSaraR4>,
|
||||
public TinyGsmGPS<TinyGsmSaraR4>,
|
||||
public TinyGsmSMS<TinyGsmSaraR4>,
|
||||
public TinyGsmTemperature<TinyGsmSaraR4>,
|
||||
public TinyGsmTime<TinyGsmSaraR4> {
|
||||
@@ -56,6 +58,7 @@ class TinyGsmSaraR4
|
||||
friend class TinyGsmSSL<TinyGsmSaraR4>;
|
||||
friend class TinyGsmBattery<TinyGsmSaraR4>;
|
||||
friend class TinyGsmGSMLocation<TinyGsmSaraR4>;
|
||||
friend class TinyGsmGPS<TinyGsmSaraR4>;
|
||||
friend class TinyGsmSMS<TinyGsmSaraR4>;
|
||||
friend class TinyGsmTemperature<TinyGsmSaraR4>;
|
||||
friend class TinyGsmTime<TinyGsmSaraR4>;
|
||||
@@ -422,17 +425,40 @@ class TinyGsmSaraR4
|
||||
size_t len) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||
|
||||
/*
|
||||
* Location functions
|
||||
* GSM/GPS/GNSS/GLONASS Location functions
|
||||
* 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
|
||||
* only difference in which sensor the data is requested from.
|
||||
*/
|
||||
protected:
|
||||
String getGsmLocationRawImpl() {
|
||||
bool enableGPSImpl() {
|
||||
// AT+UGPS=<mode>[,<aid_mode>[,<GNSS_systems>]]
|
||||
// <mode> - 0: GNSS receiver powered off, 1: on
|
||||
// <aid_mode> - 0: no aiding (default)
|
||||
// <GNSS_systems> - 3: GPS + SBAS (default)
|
||||
sendAT(GF("+UGPS=1,0,3"));
|
||||
if (waitResponse(10000L, GF(GSM_NL "+UGPS:")) != 1) { return false; }
|
||||
return waitResponse(10000L) == 1;
|
||||
}
|
||||
bool disableGPSImpl() {
|
||||
sendAT(GF("+UGPS=0"));
|
||||
if (waitResponse(10000L, GF(GSM_NL "+UGPS:")) != 1) { return false; }
|
||||
return waitResponse(10000L) == 1;
|
||||
}
|
||||
String getUbloxLocationRaw(int8_t sensor) {
|
||||
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
||||
// <mode> - 2: single shot position
|
||||
// <sensor> - 2: use cellular CellLocate® location information
|
||||
// <sensor> - 0: use the last fix in the internal database and stop the GNSS
|
||||
// receiver
|
||||
// - 1: use the GNSS receiver for localization
|
||||
// - 2: use cellular CellLocate® location information
|
||||
// - 3: ?? use the combined GNSS receiver and CellLocate® service
|
||||
// information ?? - Docs show using sensor 3 and it's
|
||||
// documented for the +UTIME command but not for +ULOC
|
||||
// <response_type> - 0: standard (single-hypothesis) response
|
||||
// <timeout> - Timeout period in seconds
|
||||
// <accuracy> - Target accuracy in meters (1 - 999999)
|
||||
sendAT(GF("+ULOC=2,2,0,120,1"));
|
||||
sendAT(GF("+ULOC=2,"), sensor, GF(",0,120,1"));
|
||||
// wait for first "OK"
|
||||
if (waitResponse(10000L) != 1) { return ""; }
|
||||
// wait for the final result - wait full timeout time
|
||||
@@ -442,21 +468,35 @@ class TinyGsmSaraR4
|
||||
res.trim();
|
||||
return res;
|
||||
}
|
||||
String getGsmLocationRawImpl() {
|
||||
return getUbloxLocationRaw(2);
|
||||
}
|
||||
String getGPSrawImpl() {
|
||||
return getUbloxLocationRaw(1);
|
||||
}
|
||||
|
||||
bool getGsmLocationImpl(float* lat, float* lon, float* accuracy = 0,
|
||||
int* year = 0, int* month = 0, int* day = 0,
|
||||
int* hour = 0, int* minute = 0, int* second = 0) {
|
||||
bool getUbloxLocation(int8_t sensor, float* lat, float* lon, float* speed = 0,
|
||||
int* alt = 0, int* vsat = 0, int* usat = 0,
|
||||
float* accuracy = 0, int* year = 0, int* month = 0,
|
||||
int* day = 0, int* hour = 0, int* minute = 0,
|
||||
int* second = 0) {
|
||||
// AT+ULOC=<mode>,<sensor>,<response_type>,<timeout>,<accuracy>
|
||||
// <mode> - 2: single shot position
|
||||
// <sensor> - 2: use cellular CellLocate® location information
|
||||
// - 0: use the last fix in the internal database and stop the GNSS
|
||||
// receiver
|
||||
// - 1: use the GNSS receiver for localization
|
||||
// - 3: ?? use the combined GNSS receiver and CellLocate® service
|
||||
// information ?? - Docs show using sensor 3 and it's documented
|
||||
// for the +UTIME command but not for +ULOC
|
||||
// <response_type> - 0: standard (single-hypothesis) response
|
||||
// <timeout> - Timeout period in seconds
|
||||
// <accuracy> - Target accuracy in meters (1 - 999999)
|
||||
sendAT(GF("+ULOC=2,2,0,120,1"));
|
||||
sendAT(GF("+ULOC=2,"), sensor, GF(",0,120,1"));
|
||||
// wait for first "OK"
|
||||
if (waitResponse(10000L) != 1) { return false; }
|
||||
// wait for the final result - wait full timeout time
|
||||
if (waitResponse(120000L, GF(GSM_NL "+UULOC:")) != 1) { return false; }
|
||||
if (waitResponse(120000L, GF(GSM_NL "+UULOC: ")) != 1) { return false; }
|
||||
|
||||
// +UULOC: <date>, <time>, <lat>, <long>, <alt>, <uncertainty>, <speed>,
|
||||
// <direction>, <vertical_acc>, <sensor_used>, <SV_used>, <antenna_status>,
|
||||
@@ -498,14 +538,20 @@ class TinyGsmSaraR4
|
||||
|
||||
*lat = streamGetFloat(','); // Estimated latitude, in degrees
|
||||
*lon = streamGetFloat(','); // Estimated longitude, in degrees
|
||||
if (alt != NULL)
|
||||
*alt = streamGetFloat(','); // Estimated altitude, in meters - only for
|
||||
// GNSS positioning, 0 in case of CellLocate
|
||||
if (accuracy != NULL) {
|
||||
*accuracy = streamGetInt(',');
|
||||
} // Maximum possible error, in meters (0 - 20000000)
|
||||
streamSkipUntil(','); // Speed over ground m/s3
|
||||
*accuracy = streamGetFloat(',');
|
||||
} // Maximum possible error, in meters (0 - 20000000)
|
||||
if (speed != NULL) *speed = streamGetFloat(','); // Speed over ground m/s3
|
||||
streamSkipUntil(','); // Course over ground in degree (0 deg - 360 deg)
|
||||
streamSkipUntil(','); // Vertical accuracy, in meters
|
||||
streamSkipUntil(','); // Sensor used for the position calculation
|
||||
streamSkipUntil(','); // Number of satellite used to calculate the position
|
||||
if (usat != NULL)
|
||||
*usat = streamGetInt(
|
||||
','); // Number of satellite used to calculate the position
|
||||
streamSkipUntil(','); // Antenna status
|
||||
streamSkipUntil('\n'); // Jamming status
|
||||
|
||||
@@ -514,12 +560,19 @@ class TinyGsmSaraR4
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPS location functions
|
||||
*/
|
||||
protected:
|
||||
// No functions of this type supported
|
||||
bool getGsmLocationImpl(float* lat, float* lon, float* accuracy = 0,
|
||||
int* year = 0, int* month = 0, int* day = 0,
|
||||
int* hour = 0, int* minute = 0, int* second = 0) {
|
||||
return getUbloxLocation(2, lat, lon, 0, 0, 0, 0, accuracy, year, month, day,
|
||||
hour, minute, second);
|
||||
};
|
||||
bool getGPSImpl(float* lat, float* lon, float* speed = 0, int* alt = 0,
|
||||
int* vsat = 0, int* usat = 0, float* accuracy = 0,
|
||||
int* year = 0, int* month = 0, int* day = 0, int* hour = 0,
|
||||
int* minute = 0, int* second = 0) {
|
||||
return getUbloxLocation(1, lat, lon, speed, alt, vsat, usat, accuracy, year,
|
||||
month, day, hour, minute, second);
|
||||
}
|
||||
|
||||
/*
|
||||
* Time functions
|
||||
|
Reference in New Issue
Block a user