Skip to content

Commit

Permalink
Merge branch 'master' into heltracker-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Aug 29, 2023
2 parents 4540260 + 2e3f762 commit af63f85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ bool GPS::setupGPS()
config.position.tx_gpio = GPS_TX_PIN;
#endif

//#define BAUD_RATE 115200
// ESP32 has a special set of parameters vs other arduino ports
// #define BAUD_RATE 115200
// ESP32 has a special set of parameters vs other arduino ports
#if defined(ARCH_ESP32)
if (config.position.rx_gpio) {
LOG_DEBUG("Using GPIO%d for GPS RX\n", config.position.rx_gpio);
Expand Down Expand Up @@ -267,7 +267,6 @@ bool GPS::setupGPS()
LOG_INFO("GNSS configured for GPS+SBAS+GLONASS. Pause for 0.75s before sending next command.\n");
// Documentation say, we need wait atleast 0.5s after reconfiguration of GNSS module, before sending next commands
delay(750);
return true;
}

// Enable interference resistance, because we are using LoRa, WiFi and Bluetooth on same board,
Expand Down Expand Up @@ -535,7 +534,8 @@ bool GPS::setupGPS()
_serial_gps->write(UBX_CFG_PMS, sizeof(UBX_CFG_PMS));
if (!getACK(0x06, 0x86)) {
LOG_WARN("Unable to enable powersaving for GPS.\n");
return true;
// T-beam doesn't support this mode.
// Don't bail from function early.
}

// We need save configuration to flash to make our config changes persistent
Expand Down Expand Up @@ -675,6 +675,7 @@ void GPS::setAwake(bool on)
if (isAwake != on) {
LOG_DEBUG("WANT GPS=%d\n", on);
if (on) {
clearBuffer(); // drop any old data waiting in the buffer
lastWakeStartMsec = millis();
wake();
} else {
Expand Down Expand Up @@ -858,7 +859,7 @@ GnssModel_t GPS::probe()
{
memset(&info, 0, sizeof(struct uBloxGnssModelInfo));
// return immediately if the model is set by the variant.h file
//#ifdef GPS_UBLOX (unless it's a ublox, because we might want to know the module info!
// #ifdef GPS_UBLOX (unless it's a ublox, because we might want to know the module info!
// return GNSS_MODEL_UBLOX; think about removing this macro and return)
#if defined(GPS_L76K)
return GNSS_MODEL_MTK;
Expand Down Expand Up @@ -891,7 +892,8 @@ 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, 0x00, 0x00};
UBXChecksum(cfg_rate, sizeof(cfg_rate));
_serial_gps->write(cfg_rate, sizeof(cfg_rate));
// Check that the returned response class and message ID are correct
if (!getAck(buffer, 384, 0x06, 0x08)) {
Expand Down
11 changes: 8 additions & 3 deletions src/modules/PositionModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
PositionModule *positionModule;

PositionModule::PositionModule()
: ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg), concurrency::OSThread(
"PositionModule")
: ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg),
concurrency::OSThread("PositionModule")
{
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
Expand Down Expand Up @@ -65,7 +65,7 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
meshtastic_MeshPacket *PositionModule::allocReply()
{
if (ignoreRequest) {
return NULL;
return nullptr;
}

meshtastic_NodeInfoLite *node = service.refreshLocalMeshNode(); // should guarantee there is now a position
Expand Down Expand Up @@ -142,6 +142,11 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha
service.cancelSending(prevPacketId);

meshtastic_MeshPacket *p = allocReply();
if (p == nullptr) {
LOG_WARN("allocReply returned a nullptr");
return;
}

p->to = dest;
p->decoded.want_response = wantReplies;
if (config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER)
Expand Down

0 comments on commit af63f85

Please sign in to comment.