Skip to content

Commit

Permalink
Don't disable mqtt by default on error
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Nov 28, 2024
1 parent 9f7d8ce commit 8755c80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct
char *topic;
uint32_t qosLevel;
bool retain_will;
bool disable_on_error;
} settings_mqtt_t;

typedef struct
Expand Down
7 changes: 5 additions & 2 deletions src/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ void mqtt_thread()
osDelayTask(MQTT_CLIENT_DEFAULT_TIMEOUT);
if (++errors > 10)
{
TRACE_INFO("Too many errors, disabling MQTT\r\n");
errors = 0;
settings_set_bool("mqtt.enabled", false);
if (get_settings()->mqtt.disable_on_error)
{
TRACE_INFO("Too many errors, disabling MQTT\r\n");
settings_set_bool("mqtt.enabled", false);
}
}
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ static void option_map_init(uint8_t settingsId)
OPTION_STRING("mqtt.topic", &settings->mqtt.topic, "teddyCloud", "Topic prefix", "Topic prefix", LEVEL_DETAIL)
OPTION_UNSIGNED("mqtt.qosLevel", &settings->mqtt.qosLevel, 0, 0, 2, "QoS level", "QoS level", LEVEL_DETAIL)
OPTION_BOOL("mqtt.retain_will", &settings->mqtt.retain_will, TRUE, "Retain last will", "Retain last will message", LEVEL_DETAIL)
OPTION_BOOL("mqtt.disable_on_error", &settings->mqtt.disable_on_error, FALSE, "Disable MQTT on error", "Disable MQTT if there were to many errors", LEVEL_DETAIL)

OPTION_TREE_DESC("hass", "Home Assistant", LEVEL_DETAIL)
OPTION_STRING("hass.name", &settings->hass.name, "teddyCloud - Server", "Home Assistant name", "Home Assistant name", LEVEL_DETAIL)
Expand Down

0 comments on commit 8755c80

Please sign in to comment.