mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-21 20:51:00 +00:00
add logic for GPS single acquisition on bootup fixed-position
This commit is contained in:
parent
c628c70db2
commit
54b4b67e5c
@ -21,7 +21,8 @@ GPS *gps;
|
|||||||
/// only init that port once.
|
/// only init that port once.
|
||||||
static bool didSerialInit;
|
static bool didSerialInit;
|
||||||
|
|
||||||
bool GPS::getACK(uint8_t c, uint8_t i) {
|
bool GPS::getACK(uint8_t c, uint8_t i)
|
||||||
|
{
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
uint8_t ack = 0;
|
uint8_t ack = 0;
|
||||||
const uint8_t ackP[2] = {c, i};
|
const uint8_t ackP[2] = {c, i};
|
||||||
@ -50,8 +51,7 @@ bool GPS::getACK(uint8_t c, uint8_t i) {
|
|||||||
b = _serial_gps->read();
|
b = _serial_gps->read();
|
||||||
if (b == buf[ack]) {
|
if (b == buf[ack]) {
|
||||||
ack++;
|
ack++;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ack = 0;
|
ack = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,8 +178,8 @@ if (!config.position.tx_gpio)
|
|||||||
* t-beam-s3-core uses the same L76K GNSS module as t-echo.
|
* t-beam-s3-core uses the same L76K GNSS module as t-echo.
|
||||||
* Unlike t-echo, L76K uses 9600 baud rate for communication by default.
|
* Unlike t-echo, L76K uses 9600 baud rate for communication by default.
|
||||||
* */
|
* */
|
||||||
// _serial_gps->begin(9600); //The baud rate of 9600 has been initialized at the beginning of setupGPS, this line is the redundant part
|
// _serial_gps->begin(9600); //The baud rate of 9600 has been initialized at the beginning of setupGPS, this line
|
||||||
// delay(250);
|
// is the redundant part delay(250);
|
||||||
|
|
||||||
// Initialize the L76K Chip, use GPS + GLONASS
|
// Initialize the L76K Chip, use GPS + GLONASS
|
||||||
_serial_gps->write("$PCAS04,5*1C\r\n");
|
_serial_gps->write("$PCAS04,5*1C\r\n");
|
||||||
@ -210,7 +210,8 @@ if (!config.position.tx_gpio)
|
|||||||
// ublox-M10S can be compatible with UBLOX traditional protocol, so the following sentence settings are also valid
|
// ublox-M10S can be compatible with UBLOX traditional protocol, so the following sentence settings are also valid
|
||||||
|
|
||||||
// disable GGL
|
// disable GGL
|
||||||
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x05, 0x3A};
|
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01,
|
||||||
|
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x05, 0x3A};
|
||||||
_serial_gps->write(_message_GGL, sizeof(_message_GGL));
|
_serial_gps->write(_message_GGL, sizeof(_message_GGL));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to disable NMEA GGL.\n");
|
LOG_WARN("Unable to disable NMEA GGL.\n");
|
||||||
@ -218,7 +219,8 @@ if (!config.position.tx_gpio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// disable GSA
|
// disable GSA
|
||||||
byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x06, 0x41};
|
byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02,
|
||||||
|
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x06, 0x41};
|
||||||
_serial_gps->write(_message_GSA, sizeof(_message_GSA));
|
_serial_gps->write(_message_GSA, sizeof(_message_GSA));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to disable NMEA GSA.\n");
|
LOG_WARN("Unable to disable NMEA GSA.\n");
|
||||||
@ -226,7 +228,8 @@ if (!config.position.tx_gpio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// disable GSV
|
// disable GSV
|
||||||
byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x07, 0x48};
|
byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03,
|
||||||
|
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x07, 0x48};
|
||||||
_serial_gps->write(_message_GSV, sizeof(_message_GSV));
|
_serial_gps->write(_message_GSV, sizeof(_message_GSV));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to disable NMEA GSV.\n");
|
LOG_WARN("Unable to disable NMEA GSV.\n");
|
||||||
@ -234,7 +237,8 @@ if (!config.position.tx_gpio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// disable VTG
|
// disable VTG
|
||||||
byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x56};
|
byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05,
|
||||||
|
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x56};
|
||||||
_serial_gps->write(_message_VTG, sizeof(_message_VTG));
|
_serial_gps->write(_message_VTG, sizeof(_message_VTG));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to disable NMEA VTG.\n");
|
LOG_WARN("Unable to disable NMEA VTG.\n");
|
||||||
@ -242,7 +246,8 @@ if (!config.position.tx_gpio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// enable RMC
|
// enable RMC
|
||||||
byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x54};
|
byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x54};
|
||||||
_serial_gps->write(_message_RMC, sizeof(_message_RMC));
|
_serial_gps->write(_message_RMC, sizeof(_message_RMC));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to enable NMEA RMC.\n");
|
LOG_WARN("Unable to enable NMEA RMC.\n");
|
||||||
@ -250,7 +255,8 @@ if (!config.position.tx_gpio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// enable GGA
|
// enable GGA
|
||||||
byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x38};
|
byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x38};
|
||||||
_serial_gps->write(_message_GGA, sizeof(_message_GGA));
|
_serial_gps->write(_message_GGA, sizeof(_message_GGA));
|
||||||
if (!getACK(0x06, 0x01)) {
|
if (!getACK(0x06, 0x01)) {
|
||||||
LOG_WARN("Unable to enable NMEA GGA.\n");
|
LOG_WARN("Unable to enable NMEA GGA.\n");
|
||||||
@ -289,7 +295,7 @@ if(config.position.gps_enabled){
|
|||||||
notifyDeepSleepObserver.observe(¬ifyDeepSleep);
|
notifyDeepSleepObserver.observe(¬ifyDeepSleep);
|
||||||
notifyGPSSleepObserver.observe(¬ifyGPSSleep);
|
notifyGPSSleepObserver.observe(¬ifyGPSSleep);
|
||||||
}
|
}
|
||||||
if (config.position.gps_enabled==false) {
|
if (config.position.gps_enabled == false && config.position.fixed_position == false) {
|
||||||
setAwake(false);
|
setAwake(false);
|
||||||
doGPSpowersave(false);
|
doGPSpowersave(false);
|
||||||
}
|
}
|
||||||
@ -396,7 +402,8 @@ uint32_t GPS::getSleepTime() const
|
|||||||
uint32_t t = config.position.gps_update_interval;
|
uint32_t t = config.position.gps_update_interval;
|
||||||
bool gps_enabled = config.position.gps_enabled;
|
bool gps_enabled = config.position.gps_enabled;
|
||||||
|
|
||||||
if (!gps_enabled)
|
// We'll not need the GPS thread to wake up again after first acq. with fixed position.
|
||||||
|
if (!gps_enabled || config.position.fixed_position)
|
||||||
t = UINT32_MAX; // Sleep forever now
|
t = UINT32_MAX; // Sleep forever now
|
||||||
|
|
||||||
if (t == UINT32_MAX)
|
if (t == UINT32_MAX)
|
||||||
@ -492,6 +499,14 @@ int32_t GPS::runOnce()
|
|||||||
// If state has changed do a publish
|
// If state has changed do a publish
|
||||||
publishUpdate();
|
publishUpdate();
|
||||||
|
|
||||||
|
if (!(fixeddelayCtr >= 20) && config.position.fixed_position && hasValidLocation) {
|
||||||
|
fixeddelayCtr++;
|
||||||
|
// LOG_DEBUG("Our delay counter is %d\n", fixeddelayCtr);
|
||||||
|
if (fixeddelayCtr >= 20) {
|
||||||
|
doGPSpowersave(false);
|
||||||
|
forceWake(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 9600bps is approx 1 byte per msec, so considering our buffer size we never need to wake more often than 200ms
|
// 9600bps is approx 1 byte per msec, so considering our buffer size we never need to wake more often than 200ms
|
||||||
// if not awake we can run super infrquently (once every 5 secs?) to see if we need to wake.
|
// if not awake we can run super infrquently (once every 5 secs?) to see if we need to wake.
|
||||||
return isAwake ? GPS_THREAD_INTERVAL : 5000;
|
return isAwake ? GPS_THREAD_INTERVAL : 5000;
|
||||||
@ -574,7 +589,6 @@ GnssModel_t GPS::probe()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0E, 0x30};
|
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0E, 0x30};
|
||||||
_serial_gps->write(cfg_rate, sizeof(cfg_rate));
|
_serial_gps->write(cfg_rate, sizeof(cfg_rate));
|
||||||
// Check that the returned response class and message ID are correct
|
// Check that the returned response class and message ID are correct
|
||||||
@ -662,8 +676,7 @@ GPS *createGps()
|
|||||||
new_gps->setup();
|
new_gps->setup();
|
||||||
return new_gps;
|
return new_gps;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
GPS *new_gps = new NMEAGPS();
|
GPS *new_gps = new NMEAGPS();
|
||||||
new_gps->setup();
|
new_gps->setup();
|
||||||
return new_gps;
|
return new_gps;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
|
|
||||||
|
|
||||||
struct uBloxGnssModelInfo {
|
struct uBloxGnssModelInfo {
|
||||||
char swVersion[30];
|
char swVersion[30];
|
||||||
char hwVersion[10];
|
char hwVersion[10];
|
||||||
@ -169,6 +168,9 @@ class GPS : private concurrency::OSThread
|
|||||||
|
|
||||||
int getAck(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID);
|
int getAck(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID);
|
||||||
|
|
||||||
|
// delay counter to allow more sats before fixed position stops GPS thread
|
||||||
|
uint8_t fixeddelayCtr = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GnssModel_t gnssModel = GNSS_MODEL_UNKONW;
|
GnssModel_t gnssModel = GNSS_MODEL_UNKONW;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user