allow to publish free heap
This commit is contained in:
@@ -173,6 +173,8 @@ void Network::initialize()
|
|||||||
_networkTimeout = -1;
|
_networkTimeout = -1;
|
||||||
_preferences->putInt(preference_network_timeout, _networkTimeout);
|
_preferences->putInt(preference_network_timeout, _networkTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_publishFreeHeap = _preferences->getBool(preference_publish_heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Network::update()
|
bool Network::update()
|
||||||
@@ -254,7 +256,10 @@ bool Network::update()
|
|||||||
if(_lastMaintenanceTs == 0 || (ts - _lastMaintenanceTs) > 30000)
|
if(_lastMaintenanceTs == 0 || (ts - _lastMaintenanceTs) > 30000)
|
||||||
{
|
{
|
||||||
publishULong(_maintenancePathPrefix, mqtt_topic_uptime, ts / 1000 / 60);
|
publishULong(_maintenancePathPrefix, mqtt_topic_uptime, ts / 1000 / 60);
|
||||||
// publishUInt(_maintenancePathPrefix, mqtt_topic_freeheap, esp_get_free_heap_size());
|
if(_publishFreeHeap)
|
||||||
|
{
|
||||||
|
publishUInt(_maintenancePathPrefix, mqtt_topic_freeheap, esp_get_free_heap_size());
|
||||||
|
}
|
||||||
_lastMaintenanceTs = ts;
|
_lastMaintenanceTs = ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ private:
|
|||||||
char* _presenceCsv = nullptr;
|
char* _presenceCsv = nullptr;
|
||||||
bool _restartOnDisconnect = false;
|
bool _restartOnDisconnect = false;
|
||||||
bool _firstConnect = true;
|
bool _firstConnect = true;
|
||||||
|
bool _publishFreeHeap = false;
|
||||||
std::vector<String> _subscribedTopics;
|
std::vector<String> _subscribedTopics;
|
||||||
std::map<String, String> _initTopics;
|
std::map<String, String> _initTopics;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#define preference_cred_password "crdpass"
|
#define preference_cred_password "crdpass"
|
||||||
#define preference_publish_authdata "pubauth"
|
#define preference_publish_authdata "pubauth"
|
||||||
#define preference_gpio_locking_enabled "gpiolck"
|
#define preference_gpio_locking_enabled "gpiolck"
|
||||||
|
#define preference_publish_heap "pubheap"
|
||||||
#define preference_presence_detection_timeout "prdtimeout"
|
#define preference_presence_detection_timeout "prdtimeout"
|
||||||
#define preference_has_mac_saved "hasmac"
|
#define preference_has_mac_saved "hasmac"
|
||||||
#define preference_has_mac_byte_0 "macb0"
|
#define preference_has_mac_byte_0 "macb0"
|
||||||
@@ -48,7 +49,7 @@ class DebugPreferences
|
|||||||
private:
|
private:
|
||||||
std::vector<char*> _keys =
|
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_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_heap, 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 =
|
std::vector<char*> _redact =
|
||||||
{
|
{
|
||||||
@@ -60,7 +61,7 @@ private:
|
|||||||
{
|
{
|
||||||
preference_started_before, preference_mqtt_log_enabled, preference_lock_enabled, preference_opener_enabled,
|
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_restart_on_disconnect, preference_keypad_control_enabled, preference_register_as_app,
|
||||||
preference_publish_authdata, preference_gpio_locking_enabled, preference_has_mac_saved,
|
preference_publish_authdata, preference_gpio_locking_enabled, preference_has_mac_saved, preference_publish_heap
|
||||||
};
|
};
|
||||||
|
|
||||||
const bool isRedacted(const char* key) const
|
const bool isRedacted(const char* key) const
|
||||||
|
|||||||
@@ -167,13 +167,35 @@ void WebCfgServer::initialize()
|
|||||||
buildInfoHtml(response);
|
buildInfoHtml(response);
|
||||||
_server.send(200, "text/html", response);
|
_server.send(200, "text/html", response);
|
||||||
});
|
});
|
||||||
|
_server.on("/heapon", [&]() {
|
||||||
|
_preferences->putBool(preference_publish_heap, true);
|
||||||
|
|
||||||
|
String response = "";
|
||||||
|
buildConfirmHtml(response, "OK");
|
||||||
|
_server.send(200, "text/html", response);
|
||||||
|
Log->println(F("Restarting"));
|
||||||
|
|
||||||
|
waitAndProcess(true, 1000);
|
||||||
|
ESP.restart();
|
||||||
|
});
|
||||||
|
_server.on("/heapoff", [&]() {
|
||||||
|
_preferences->putBool(preference_publish_heap, false);
|
||||||
|
|
||||||
|
String response = "";
|
||||||
|
buildConfirmHtml(response, "OK");
|
||||||
|
_server.send(200, "text/html", response);
|
||||||
|
Log->println(F("Restarting"));
|
||||||
|
|
||||||
|
waitAndProcess(true, 1000);
|
||||||
|
ESP.restart();
|
||||||
|
});
|
||||||
|
|
||||||
_server.begin();
|
_server.begin();
|
||||||
|
|
||||||
_network->setKeepAliveCallback([&]()
|
_network->setKeepAliveCallback([&]()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebCfgServer::processArgs(String& message)
|
bool WebCfgServer::processArgs(String& message)
|
||||||
|
|||||||
Reference in New Issue
Block a user