mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Add support for fixing GPS_BAUDRATE
If GPS_BAUDRATE is set in variant.h, the deployer knows something we don't about the GPS. Used especially when the GPS is soldered to a board in a commercial product :) If we see that, we don't try other baud rates at all.
This commit is contained in:
parent
e65b0efb82
commit
3b265f5392
@ -207,6 +207,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef GPS_BAUDRATE
|
||||
#define GPS_BAUDRATE 9600
|
||||
#define GPS_BAUDRATE_FIXED 0
|
||||
#else
|
||||
#define GPS_BAUDRATE_FIXED 1
|
||||
#endif
|
||||
|
||||
/* Step #2: follow with defines common to the architecture;
|
||||
|
@ -413,6 +413,13 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setup the GPS based on the model detected.
|
||||
* We detect the GPS by cyling 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()
|
||||
{
|
||||
|
||||
@ -420,14 +427,17 @@ bool GPS::setup()
|
||||
int msglen = 0;
|
||||
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||
|
||||
// if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate.
|
||||
if (probeTries == 0 && speedSelect == 0 && GPS_BAUDRATE != serialSpeeds[speedSelect]) {
|
||||
speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds;
|
||||
if (speedSelect == 0) {
|
||||
speedSelect = std::find(rareSerialSpeeds, std::end(rareSerialSpeeds), GPS_BAUDRATE) - rareSerialSpeeds;
|
||||
probeTries = 1;
|
||||
}
|
||||
// if GPS_BAUDRATE is specified in variant, skip to the specified rate.
|
||||
if (GPS_BAUDRATE_FIXED) {
|
||||
gnssModel = probe(GPS_BAUDRATE);
|
||||
if (gnssModel == GNSS_MODEL_UNKNOWN && probeTries == 1) {
|
||||
LOG_WARN("GPS probe failed, setting to %d", GPS_BAUDRATE);
|
||||
return true;
|
||||
} else {
|
||||
++probeTries;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (probeTries == 0) {
|
||||
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
|
||||
gnssModel = probe(serialSpeeds[speedSelect]);
|
||||
@ -447,9 +457,10 @@ bool GPS::setup()
|
||||
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
gnssModel = GNSS_MODEL_UNKNOWN;
|
||||
}
|
||||
|
@ -76,9 +76,8 @@ class GPS : private concurrency::OSThread
|
||||
uint8_t fixType = 0; // fix type from GPGSA
|
||||
#endif
|
||||
private:
|
||||
|
||||
const int serialSpeeds[6] = {9600, 115200, 38400};
|
||||
const int rareSerialSpeeds[6] = {4800, 57600, GPS_BAUDRATE};
|
||||
const int serialSpeeds[3] = {9600, 115200, 38400};
|
||||
const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
|
||||
|
||||
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
|
||||
uint32_t rx_gpio = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user