publish restart reasons
This commit is contained in:
@@ -45,4 +45,6 @@
|
||||
#define mqtt_topic_uptime "/maintenance/uptime"
|
||||
#define mqtt_topic_wifi_rssi "/maintenance/wifiRssi"
|
||||
#define mqtt_topic_log "/maintenance/log"
|
||||
#define mqtt_topic_freeheap "/maintenance/freeHeap"
|
||||
#define mqtt_topic_freeheap "/maintenance/freeHeap"
|
||||
#define mqtt_topic_restart_reason_fw "/maintenance/restartReasonNukiHub"
|
||||
#define mqtt_topic_restart_reason_esp "/maintenance/restartReasonNukiEsp"
|
||||
@@ -175,7 +175,7 @@ void Network::initialize()
|
||||
_preferences->putInt(preference_network_timeout, _networkTimeout);
|
||||
}
|
||||
|
||||
_publishFreeHeap = _preferences->getBool(preference_publish_heap);
|
||||
_publishDebugInfo = _preferences->getBool(preference_publish_debug_info);
|
||||
}
|
||||
|
||||
bool Network::update()
|
||||
@@ -257,9 +257,11 @@ bool Network::update()
|
||||
if(_lastMaintenanceTs == 0 || (ts - _lastMaintenanceTs) > 30000)
|
||||
{
|
||||
publishULong(_maintenancePathPrefix, mqtt_topic_uptime, ts / 1000 / 60);
|
||||
if(_publishFreeHeap)
|
||||
if(_publishDebugInfo)
|
||||
{
|
||||
publishUInt(_maintenancePathPrefix, mqtt_topic_freeheap, esp_get_free_heap_size());
|
||||
publishString(_maintenancePathPrefix, mqtt_topic_restart_reason_fw, getRestartReason().c_str());
|
||||
publishString(_maintenancePathPrefix, mqtt_topic_restart_reason_esp, getEspRestartReason().c_str());
|
||||
}
|
||||
_lastMaintenanceTs = ts;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
char* _presenceCsv = nullptr;
|
||||
bool _restartOnDisconnect = false;
|
||||
bool _firstConnect = true;
|
||||
bool _publishFreeHeap = false;
|
||||
bool _publishDebugInfo = false;
|
||||
std::vector<String> _subscribedTopics;
|
||||
std::map<String, String> _initTopics;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define preference_cred_password "crdpass"
|
||||
#define preference_publish_authdata "pubauth"
|
||||
#define preference_gpio_locking_enabled "gpiolck"
|
||||
#define preference_publish_heap "pubheap"
|
||||
#define preference_publish_debug_info "pubdbg"
|
||||
#define preference_presence_detection_timeout "prdtimeout"
|
||||
#define preference_has_mac_saved "hasmac"
|
||||
#define preference_has_mac_byte_0 "macb0"
|
||||
@@ -49,7 +49,7 @@ class DebugPreferences
|
||||
private:
|
||||
std::vector<char*> _keys =
|
||||
{
|
||||
preference_started_before, preference_deviceId, preference_mqtt_broker, preference_mqtt_broker_port, preference_mqtt_user, preference_mqtt_password, preference_mqtt_log_enabled, preference_lock_enabled, preference_mqtt_lock_path, preference_opener_enabled, preference_mqtt_opener_path, preference_max_keypad_code_count, preference_mqtt_ca, preference_mqtt_crt, preference_mqtt_key, preference_mqtt_hass_discovery, preference_network_hardware, preference_network_hardware_gpio, preference_rssi_publish_interval, preference_hostname, preference_network_timeout, preference_restart_on_disconnect, preference_restart_timer, preference_restart_ble_beacon_lost, preference_query_interval_lockstate, preference_query_interval_battery, preference_query_interval_keypad, preference_keypad_control_enabled, preference_register_as_app, preference_command_nr_of_retries, preference_command_retry_delay, preference_cred_user, preference_cred_password, preference_publish_authdata, preference_gpio_locking_enabled, preference_publish_heap, preference_presence_detection_timeout, preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2,
|
||||
preference_started_before, preference_deviceId, preference_mqtt_broker, preference_mqtt_broker_port, preference_mqtt_user, preference_mqtt_password, preference_mqtt_log_enabled, preference_lock_enabled, preference_mqtt_lock_path, preference_opener_enabled, preference_mqtt_opener_path, preference_max_keypad_code_count, preference_mqtt_ca, preference_mqtt_crt, preference_mqtt_key, preference_mqtt_hass_discovery, preference_network_hardware, preference_network_hardware_gpio, preference_rssi_publish_interval, preference_hostname, preference_network_timeout, preference_restart_on_disconnect, preference_restart_timer, preference_restart_ble_beacon_lost, preference_query_interval_lockstate, preference_query_interval_battery, preference_query_interval_keypad, preference_keypad_control_enabled, preference_register_as_app, preference_command_nr_of_retries, preference_command_retry_delay, preference_cred_user, preference_cred_password, preference_publish_authdata, preference_gpio_locking_enabled, preference_publish_debug_info, preference_presence_detection_timeout, preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2,
|
||||
};
|
||||
std::vector<char*> _redact =
|
||||
{
|
||||
@@ -59,9 +59,9 @@ private:
|
||||
};
|
||||
std::vector<char*> _boolPrefs =
|
||||
{
|
||||
preference_started_before, preference_mqtt_log_enabled, preference_lock_enabled, preference_opener_enabled,
|
||||
preference_restart_on_disconnect, preference_keypad_control_enabled, preference_register_as_app,
|
||||
preference_publish_authdata, preference_gpio_locking_enabled, preference_has_mac_saved, preference_publish_heap
|
||||
preference_started_before, preference_mqtt_log_enabled, preference_lock_enabled, preference_opener_enabled,
|
||||
preference_restart_on_disconnect, preference_keypad_control_enabled, preference_register_as_app,
|
||||
preference_publish_authdata, preference_gpio_locking_enabled, preference_has_mac_saved, preference_publish_debug_info
|
||||
};
|
||||
|
||||
const bool isRedacted(const char* key) const
|
||||
|
||||
@@ -13,7 +13,7 @@ enum class RestartReason
|
||||
ConfigurationUpdated,
|
||||
RestartTimer,
|
||||
OTATimeout,
|
||||
DeviceUnpaired
|
||||
DeviceUnpaired,
|
||||
};
|
||||
|
||||
#define RESTART_REASON_VALID_DETECT 0xa00ab00bc00bd00d;
|
||||
@@ -28,7 +28,7 @@ inline static void restartEsp(RestartReason reason)
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
inline static String getRestartReasion()
|
||||
inline static String getRestartReason()
|
||||
{
|
||||
uint64_t cmp = RESTART_REASON_VALID_DETECT;
|
||||
if(restartReasonValid != cmp)
|
||||
@@ -65,4 +65,36 @@ inline static String getRestartReasion()
|
||||
default:
|
||||
return "Unknown: " + restartReason;
|
||||
}
|
||||
}
|
||||
|
||||
inline static String getEspRestartReason()
|
||||
{
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
switch(reason)
|
||||
{
|
||||
case esp_reset_reason_t::ESP_RST_UNKNOWN:
|
||||
return "ESP_RST_UNKNOWN: Reset reason can not be determined.";
|
||||
case esp_reset_reason_t::ESP_RST_POWERON:
|
||||
return "ESP_RST_POWERON: Reset due to power-on event.";
|
||||
case esp_reset_reason_t::ESP_RST_EXT:
|
||||
return "ESP_RST_EXT: Reset by external pin";
|
||||
case esp_reset_reason_t::ESP_RST_SW:
|
||||
return "ESP_RST_SW: Software reset via esp_restart.";
|
||||
case esp_reset_reason_t::ESP_RST_PANIC:
|
||||
return "ESP_RST_PANIC: Software reset due to exception/panic.";
|
||||
case esp_reset_reason_t::ESP_RST_INT_WDT:
|
||||
return "ESP_RST_INT_WDT: Reset (software or hardware) due to interrupt watchdog";
|
||||
case esp_reset_reason_t::ESP_RST_TASK_WDT:
|
||||
return "ESP_RST_TASK_WDT: Reset due to task watchdog.";
|
||||
case esp_reset_reason_t::ESP_RST_WDT:
|
||||
return "ESP_RST_WDT: Reset due to other watchdogs.";
|
||||
case esp_reset_reason_t::ESP_RST_DEEPSLEEP:
|
||||
return "ESP_RST_DEEPSLEEP: Reset after exiting deep sleep mode.";
|
||||
case esp_reset_reason_t::ESP_RST_BROWNOUT:
|
||||
return "ESP_RST_BROWNOUT: Brownout reset (software or hardware)";
|
||||
case esp_reset_reason_t::ESP_RST_SDIO:
|
||||
return "ESP_RST_SDIO: Reset over SDIO.";
|
||||
default:
|
||||
return "Unknown: " + (int)reason;
|
||||
}
|
||||
}
|
||||
@@ -168,8 +168,8 @@ void WebCfgServer::initialize()
|
||||
buildInfoHtml(response);
|
||||
_server.send(200, "text/html", response);
|
||||
});
|
||||
_server.on("/heapon", [&]() {
|
||||
_preferences->putBool(preference_publish_heap, true);
|
||||
_server.on("/debugon", [&]() {
|
||||
_preferences->putBool(preference_publish_debug_info, true);
|
||||
|
||||
String response = "";
|
||||
buildConfirmHtml(response, "OK");
|
||||
@@ -179,8 +179,8 @@ void WebCfgServer::initialize()
|
||||
waitAndProcess(true, 1000);
|
||||
restartEsp(RestartReason::ConfigurationUpdated);
|
||||
});
|
||||
_server.on("/heapoff", [&]() {
|
||||
_preferences->putBool(preference_publish_heap, false);
|
||||
_server.on("/debugoff", [&]() {
|
||||
_preferences->putBool(preference_publish_debug_info, false);
|
||||
|
||||
String response = "";
|
||||
buildConfirmHtml(response, "OK");
|
||||
@@ -765,12 +765,12 @@ void WebCfgServer::buildInfoHtml(String &response)
|
||||
response.concat("\n");
|
||||
|
||||
response.concat("Restart reason FW: ");
|
||||
response.concat(getRestartReasion());
|
||||
response.concat(getRestartReason());
|
||||
response.concat("\n");
|
||||
|
||||
// response.concat("Restart reason ESP: ");
|
||||
// response.concat(getRestartReasion());
|
||||
// response.concat("\n");
|
||||
response.concat("Restart reason ESP: ");
|
||||
response.concat(getEspRestartReason());
|
||||
response.concat("\n");
|
||||
|
||||
response.concat("</pre> </BODY></HTML>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user