Fix MQTT connection loss and display freeze after extended uptime#1
Open
Copilot wants to merge 2 commits into
Open
Fix MQTT connection loss and display freeze after extended uptime#1Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…t, and display index underflow Agent-Logs-Url: https://github.com/calkoe/OpenFreqSensor/sessions/d13a5bb7-7836-4cde-a9c9-9ed47fd8bf0d Co-authored-by: calkoe <26646066+calkoe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/calkoe/OpenFreqSensor/sessions/d13a5bb7-7836-4cde-a9c9-9ed47fd8bf0d Co-authored-by: calkoe <26646066+calkoe@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
calkoe
April 18, 2026 19:31
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After weeks of uptime, the MQTT connection would permanently die and display refreshes would become extremely sluggish, requiring a reboot to recover. Root cause: multiple blocking operations in the reconnect path were starving
loop().Bugs fixed
networking.cppmqttClient.connect()call — the first call's result was silently discarded, causing two full blocking TCP/TLS handshakes on every reconnect attemptdelay(1000)inreconnectWiFi()— blocked the entireloop()for 1 second every 5 seconds whenever WiFi was lost; removed sinceWiFi.setAutoReconnect(true)was already setWiFiClientSecure— a failed MQTT connect could block for 10–30 s per attempt; capped at 5 s viaespClient.setTimeout(5)lastReconnectTryuninitialized — added explicit= 0in constructor initializer listdisplay_handler.cppuint16_tunderflow on alarm ring-buffer index —writeIndex - scrollPositionwraps to ~65534 whenscrollPosition > writeIndex, causing an out-of-bounds read onalarmHistory[]; fixed to(writeIndex - scrollPosition + MAX_ALARMS) % MAX_ALARMS