From badcee518ed81a7581cbc0c49fdfd94f4f541b32 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 7 Feb 2020 16:58:44 -0500 Subject: [PATCH] Adjust ublox gsm location Signed-off-by: Sara Damiano --- examples/AllFunctions/AllFunctions.ino | 4 ++-- src/TinyGsmClientUBLOX.h | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/AllFunctions/AllFunctions.ino b/examples/AllFunctions/AllFunctions.ino index 7313a6d..7ba2045 100644 --- a/examples/AllFunctions/AllFunctions.ino +++ b/examples/AllFunctions/AllFunctions.ino @@ -126,7 +126,7 @@ void setup() { // Set GSM module baud rate TinyGsmAutoBaud(SerialAT,GSM_AUTOBAUD_MIN,GSM_AUTOBAUD_MAX); - //SerialAT.begin(9600); + //SerialAT.begin(115200); delay(3000); } @@ -174,7 +174,7 @@ void loop() { #endif DBG("Waiting for network..."); - if (!modem.waitForNetwork()) { + if (!modem.waitForNetwork(600000L)) { delay(10000); return; } diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 29d634f..4a8a375 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -390,8 +390,19 @@ class TinyGsmUBLOX */ protected: String getGsmLocationImpl() { - sendAT(GF("+ULOC=2,3,0,120,1")); - if (waitResponse(30000L, GF(GSM_NL "+UULOC:")) != 1) { return ""; } + // AT+ULOC=,,,, + // - 2: single shot position + // - 2: use cellular CellLocate® location information + // - 0: standard (single-hypothesis) response + // - Timeout period in seconds + // - Target accuracy in meters (1 - 999999) + sendAT(GF("+ULOC=2,2,0,120,1")); + // wait for first "OK" + if (waitResponse(10000L) != 1) { + return ""; + } + // wait for the final result - wait full timeout time + if (waitResponse(120000L, GF(GSM_NL "+UULOC:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim();