Compare commits

..

No commits in common. "7e94417749747bd7dee6da3475b429420eb32b2b" and "59bdfd63e426f6fa87df2cc763f56ddedc1c7704" have entirely different histories.

5 changed files with 27 additions and 59 deletions

View File

@ -1,4 +0,0 @@
# Contributor Covenant Code of Conduct
The Meshtastic Firmware project is subject to the code of conduct for the parent project, which can be found here:
https://meshtastic.org/docs/legal/conduct/

View File

@ -207,9 +207,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GPS_BAUDRATE #ifndef GPS_BAUDRATE
#define GPS_BAUDRATE 9600 #define GPS_BAUDRATE 9600
#define GPS_BAUDRATE_FIXED 0
#else
#define GPS_BAUDRATE_FIXED 1
#endif #endif
/* Step #2: follow with defines common to the architecture; /* Step #2: follow with defines common to the architecture;

View File

@ -413,42 +413,30 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
return 0; return 0;
} }
/**
* @brief Setup the GPS based on the model detected.
* We detect the GPS by cycling through a set of baud rates, first common then rare.
* For each baud rate, we run GPS::Probe to send commands and match the responses
* to known GPS responses.
* @retval Whether setup reached the end of its potential to configure the GPS.
*/
bool GPS::setup() bool GPS::setup()
{ {
if (!didSerialInit) { if (!didSerialInit) {
int msglen = 0; int msglen = 0;
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) { if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
if (probeTries < 2) {
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]); // if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate.
gnssModel = probe(serialSpeeds[speedSelect]); if (speedSelect == 0 && probeTries == 2 && GPS_BAUDRATE != serialSpeeds[speedSelect]) {
if (gnssModel == GNSS_MODEL_UNKNOWN) { speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds;
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
speedSelect = 0;
++probeTries;
}
}
} }
// Rare Serial Speeds
if (probeTries == 2) { LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
LOG_DEBUG("Probing for GPS at %d", rareSerialSpeeds[speedSelect]); gnssModel = probe(serialSpeeds[speedSelect]);
gnssModel = probe(rareSerialSpeeds[speedSelect]); if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (gnssModel == GNSS_MODEL_UNKNOWN) { if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) { speedSelect = 0;
if (--probeTries == 0) {
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE); LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
return true; return true;
} }
} }
return false;
} }
return false;
} else { } else {
gnssModel = GNSS_MODEL_UNKNOWN; gnssModel = GNSS_MODEL_UNKNOWN;
} }
@ -687,8 +675,7 @@ bool GPS::setup()
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_DISABLE_SBAS_BBR, "disable SBAS M10 GPS BBR", 300); SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_DISABLE_SBAS_BBR, "disable SBAS M10 GPS BBR", 300);
delay(750); // will cause a receiver restart so wait a bit delay(750); // will cause a receiver restart so wait a bit
// Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic // Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic sleep.
// sleep.
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_ENABLE_NMEA_BBR, "enable messages for M10 GPS BBR", 300); SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_ENABLE_NMEA_BBR, "enable messages for M10 GPS BBR", 300);
delay(750); delay(750);
// Next enable wanted NMEA messages in RAM layer // Next enable wanted NMEA messages in RAM layer
@ -950,10 +937,10 @@ void GPS::down()
#endif #endif
if (softsleepSupported) { if (softsleepSupported) {
// How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than // How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than GPS_SOFTSLEEP?
// GPS_SOFTSLEEP? Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M // Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M and M10050
// and M10050 https://www.desmos.com/calculator/6gvjghoumr This is not particularly accurate, but probably an // https://www.desmos.com/calculator/6gvjghoumr
// improvement over a single, fixed threshold // This is not particularly accurate, but probably an impromevement over a single, fixed threshold
uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22)); uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22));
LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000); LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000);
@ -1306,12 +1293,10 @@ GPS *GPS::createGps()
if (!GPS_EN_ACTIVE) { // Need to invert the pin before hardware if (!GPS_EN_ACTIVE) { // Need to invert the pin before hardware
new GpioNotTransformer( new GpioNotTransformer(
virtPin, virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
} else { } else {
new GpioUnaryTransformer( new GpioUnaryTransformer(
virtPin, virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
} }
} }
@ -1419,8 +1404,8 @@ bool GPS::factoryReset()
_serial_gps->write("$PMTK104*37\r\n"); _serial_gps->write("$PMTK104*37\r\n");
// No PMTK_ACK for this command. // No PMTK_ACK for this command.
delay(100); delay(100);
// send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's // send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's UBLOX.
// UBLOX. Factory Reset // Factory Reset
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00, byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E}; 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
_serial_gps->write(_message_reset, sizeof(_message_reset)); _serial_gps->write(_message_reset, sizeof(_message_reset));
@ -1459,8 +1444,8 @@ bool GPS::lookForTime()
auto d = reader.date; auto d = reader.date;
if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed
/* Convert to unix time /* Convert to unix time
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970
1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
*/ */
struct tm t; struct tm t;
t.tm_sec = ti.second() + round(ti.age() / 1000); t.tm_sec = ti.second() + round(ti.age() / 1000);
@ -1693,9 +1678,7 @@ bool GPS::whileActive()
} }
} }
#ifdef GPS_DEBUG #ifdef GPS_DEBUG
if (debugmsg != "") { LOG_DEBUG(debugmsg.c_str());
LOG_DEBUG(debugmsg.c_str());
}
#endif #endif
return isValid; return isValid;
} }

View File

@ -76,21 +76,13 @@ class GPS : private concurrency::OSThread
uint8_t fixType = 0; // fix type from GPGSA uint8_t fixType = 0; // fix type from GPGSA
#endif #endif
private: private:
#if GPS_BAUDRATE_FIXED const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, GPS_BAUDRATE};
// if GPS_BAUDRATE is specified in variant, only try that.
const int serialSpeeds[1] = {GPS_BAUDRATE};
const int rareSerialSpeeds[1] = {GPS_BAUDRATE};
#else
const int serialSpeeds[3] = {9600, 115200, 38400};
const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
#endif
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0; uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
uint32_t rx_gpio = 0; uint32_t rx_gpio = 0;
uint32_t tx_gpio = 0; uint32_t tx_gpio = 0;
int speedSelect = 0; int speedSelect = 0;
int probeTries = 0; int probeTries = 2;
/** /**
* hasValidLocation - indicates that the position variables contain a complete * hasValidLocation - indicates that the position variables contain a complete

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 2 major = 2
minor = 5 minor = 5
build = 11 build = 10