mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
fix(t1000-e): fix extended uptime failures in GPS and sensor code
- Fix millis() wraparound (49-day) in T1000SensorManager::loop() and MicroNMEALocationProvider::loop() by switching from absolute comparison (millis() > next_*) to elapsed-time arithmetic ((uint32_t)(millis() - last_*) >= interval) with uint32_t timestamps; previous pattern could stall GPS updates and time sync for up to ~24 days after wraparound - Fix division-by-zero crash in get_heater_temperature() when ntc_volt == 0 (open circuit or bad ADC read); now returns 0.0f safely - Fix out-of-bounds array access in get_heater_temperature(): loop exit at i == 0 caused ntc_res2[i-1] / ntc_temp2[i-1] at index -1; loop exhaustion at i == 136 caused ntc_res2[136] one-past-end read; clamped i to [1, 135] with early-exit returns for edge temperatures and guarded interpolation denominator against zero
This commit is contained in:
parent
792f299986
commit
a8b3fc5ce3
3 changed files with 23 additions and 12 deletions
|
|
@ -162,18 +162,18 @@ bool T1000SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP&
|
|||
}
|
||||
|
||||
void T1000SensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
static uint32_t last_gps_update = 0;
|
||||
constexpr uint32_t GPS_UPDATE_INTERVAL_MS = 1000;
|
||||
|
||||
_nmea->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if ((uint32_t)(millis() - last_gps_update) >= GPS_UPDATE_INTERVAL_MS) {
|
||||
if (gps_active && _nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
last_gps_update = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue