Skip to content

fix(gps and sensor): fix extended uptime failures in GPS and sensor code - #2074

Closed
NickDunklee wants to merge 4 commits into
meshcore-dev:devfrom
NickDunklee:t1000e-fixes
Closed

fix(gps and sensor): fix extended uptime failures in GPS and sensor code#2074
NickDunklee wants to merge 4 commits into
meshcore-dev:devfrom
NickDunklee:t1000e-fixes

Conversation

@NickDunklee

@NickDunklee NickDunklee commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Updated to cover all GPS code paths that have the same variable math problems.

This covers fixing GPS looping bugs and also a divide by zero potential crash in the t1000-e. Was originally an attempt to help fix t1000-e uptime, and figured might as well fix the math in all the rest in the same go. If preferred, I can break out the t1000-e sensor fix into its own PR so this is just GPS stuff.

  • Fix millis() wraparound (49-day) in GPS sensor loop() and MicroNMEALocationProvider::loop() by switching from absolute comparison (millis() > next_) to elapsed-time math ((uint32_t)(millis() - last_) >= interval) with uint32_t timestamps; previous pattern could stall GPS updates and time sync for up to ~24 days after 49-day-wraparound
  • Fix divide-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 so it doesn't run out of bounds

- 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
@NickDunklee
NickDunklee changed the base branch from main to dev March 17, 2026 17:16
@NickDunklee

Copy link
Copy Markdown
Contributor Author

Just note, haven't had a t1000e failure since this change.

@NickDunklee NickDunklee changed the title fix(t1000-e): fix extended uptime failures in GPS and sensor code fix(gps and sensor): fix extended uptime failures in GPS and sensor code Jun 25, 2026
@NickDunklee

NickDunklee commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

#2937 fixes the GPS bug as well, so closing. Huzzah! 🎉 I'll check the other code vs 1.17.0 and open another PR if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant