Commit b5ebb6f
committed
Fix millis() wraparound handling in timer comparisons
Fixes potential scheduler failures after ~49.7 days of continuous
uptime when millis() wraps around from 2^32-1 to 0.
Changed time comparisons from:
if (millis() >= targetTime)
to:
if ((int32_t)(millis() - targetTime) >= 0)
This uses signed subtraction to correctly handle wraparound,
matching the approach from MeshCore 1.14 commit 011edd3c.
Affected timers:
- pendingAdvertTime: scheduled ADVERT beacon after time sync
- tempRadioExpireTime: temporary radio parameter expiration
- rebootTime: delayed reboot from CLI command
Without this fix, scheduled events would get stuck and never
trigger after millis() wraparound, as the target time would
appear to be in the far future.1 parent df1ebf1 commit b5ebb6f
2 files changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2104 | 2104 | | |
2105 | 2105 | | |
2106 | 2106 | | |
2107 | | - | |
| 2107 | + | |
| 2108 | + | |
2108 | 2109 | | |
2109 | 2110 | | |
2110 | 2111 | | |
| |||
3241 | 3242 | | |
3242 | 3243 | | |
3243 | 3244 | | |
3244 | | - | |
| 3245 | + | |
| 3246 | + | |
3245 | 3247 | | |
3246 | 3248 | | |
3247 | 3249 | | |
| |||
3258 | 3260 | | |
3259 | 3261 | | |
3260 | 3262 | | |
3261 | | - | |
| 3263 | + | |
| 3264 | + | |
3262 | 3265 | | |
3263 | 3266 | | |
3264 | 3267 | | |
| |||
0 commit comments