Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Firmware/GPAD_API/GPAD_API/GPAD_API.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1800,12 +1800,24 @@ void loop()
{
#if defined HMWK || defined KRAKE

if (!client.loop())
{
debugSerial.print(mqtt_broker_name);
debugSerial.print(" lost MQTT at: ");
debugSerial.println(millis());
reconnect();
const bool wasConnected = client.connected();
if (!client.loop())
{
debugSerial.print(mqtt_broker_name);
debugSerial.print(" lost MQTT at: ");
debugSerial.println(millis());
if (wasConnected && !running_menu)
{
showMqttStatusLCD(false);
playAlarmLevel(problem);
Comment on lines +1810 to +1813
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show disconnect warning after menu closes

When MQTT drops while running_menu is true, this guard skips showMqttStatusLCD(false) on the first disconnect iteration; on subsequent iterations wasConnected is already false, so the warning can never be shown after the user exits the menu. In that scenario the LCD returns to normal alarm text (restoreAlarmLevel) even though the data is stale, and it stays that way until reconnection succeeds, which defeats the disconnect-alert behavior this change introduces.

Useful? React with 👍 / 👎.

}
reconnect();
if (client.connected() && !running_menu)
{
annunciateAlarmLevel(&debugSerial);
}
}
}

if (wifiResetRequestedAtMs != 0 && (millis() - wifiResetRequestedAtMs) > 750)
Expand Down
20 changes: 20 additions & 0 deletions Firmware/GPAD_API/GPAD_API/GPAD_HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,26 @@ void clearLCD(void)
lcd.clear();
}

void showMqttStatusLCD(bool connected)
{
lcd.init();
lcd.clear();
if (connected)
{
lcd.noBacklight();
return;
}
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("MQTT DISCONNECTED ");
lcd.setCursor(0, 1);
lcd.print("Alarm status stale ");
lcd.setCursor(0, 2);
lcd.print("Reconnecting... ");
lcd.setCursor(0, 3);
lcd.print(" ");
}

// Splash a message so we can tell the LCD is working
void splashLCD(wifi_mode_t wifiMode, IPAddress &deviceIp)
{
Expand Down
1 change: 1 addition & 0 deletions Firmware/GPAD_API/GPAD_API/GPAD_HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ void restoreAlarmLevel(Stream *serialport);
void unchanged_anunicateAlarmLevel(Stream *serialport);
void annunciateAlarmLevel(Stream *serialport);
void clearLCD(void);
void showMqttStatusLCD(bool connected);
void splashLCD(wifi_mode_t wifiMode, IPAddress &deviceIp);

void interpretBuffer(char *buf, int rlen, Stream *serialport, PubSubClient *client);
Expand Down