Update Tasks

This commit is contained in:
iranl
2024-05-26 19:25:45 +02:00
parent 699d9a148a
commit acad87b308
15 changed files with 416 additions and 265 deletions

View File

@@ -116,12 +116,12 @@ void setupTasks()
{
// configMAX_PRIORITIES is 25
xTaskCreatePinnedToCore(networkTask, "ntw", preferences->getInt(preference_task_size_network, 12288), NULL, 3, &networkTaskHandle, 1);
xTaskCreatePinnedToCore(nukiTask, "nuki", preferences->getInt(preference_task_size_nuki, 8192), NULL, 2, &nukiTaskHandle, 1);
xTaskCreatePinnedToCore(networkTask, "ntw", preferences->getInt(preference_task_size_network, NETWORK_TASK_SIZE), NULL, 3, &networkTaskHandle, 1);
xTaskCreatePinnedToCore(nukiTask, "nuki", preferences->getInt(preference_task_size_nuki, NUKI_TASK_SIZE), NULL, 2, &nukiTaskHandle, 1);
if(preferences->getInt(preference_presence_detection_timeout) >= 0)
{
xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", preferences->getInt(preference_task_size_pd, 1024), NULL, 5, &presenceDetectionTaskHandle, 1);
xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", preferences->getInt(preference_task_size_pd, PD_TASK_SIZE), NULL, 5, &presenceDetectionTaskHandle, 1);
}
}
@@ -265,6 +265,27 @@ void setup()
initializeRestartReason();
if(preferences->getBool(preference_enable_bootloop_reset, false) &&
(esp_reset_reason() == esp_reset_reason_t::ESP_RST_PANIC ||
esp_reset_reason() == esp_reset_reason_t::ESP_RST_INT_WDT ||
esp_reset_reason() == esp_reset_reason_t::ESP_RST_TASK_WDT ||
esp_reset_reason() == esp_reset_reason_t::ESP_RST_WDT))
{
preferences->putInt(preference_bootloop_counter, preferences->getInt(preference_bootloop_counter, 0) + 1);
Log->println(F("Bootloop counter incremented"));
if(preferences->getInt(preference_bootloop_counter) == 10)
{
preferences->putInt(preference_buffer_size, CHAR_BUFFER_SIZE);
preferences->putInt(preference_task_size_network, NETWORK_TASK_SIZE);
preferences->putInt(preference_task_size_nuki, NUKI_TASK_SIZE);
preferences->putInt(preference_task_size_pd, PD_TASK_SIZE);
preferences->putInt(preference_authlog_max_entries, MAX_AUTHLOG);
preferences->putInt(preference_keypad_max_entries, MAX_KEYPAD);
preferences->putInt(preference_timecontrol_max_entries, MAX_TIMECONTROL);
preferences->putInt(preference_bootloop_counter, 0);
}
}
uint32_t devIdOpener = preferences->getUInt(preference_device_id_opener);
@@ -275,8 +296,10 @@ void setup()
{
deviceIdOpener->assignId(deviceIdLock->get());
}
char16_t buffer_size = preferences->getInt(preference_buffer_size, 4096);
CharBuffer::initialize();
CharBuffer::initialize(buffer_size);
if(preferences->getInt(preference_restart_timer) != 0)
{
@@ -292,15 +315,15 @@ void setup()
openerEnabled = preferences->getBool(preference_opener_enabled);
const String mqttLockPath = preferences->getString(preference_mqtt_lock_path);
network = new Network(preferences, gpio, mqttLockPath, CharBuffer::get(), CHAR_BUFFER_SIZE);
network = new Network(preferences, gpio, mqttLockPath, CharBuffer::get(), buffer_size);
network->initialize();
networkLock = new NetworkLock(network, preferences, CharBuffer::get(), CHAR_BUFFER_SIZE);
networkLock = new NetworkLock(network, preferences, CharBuffer::get(), buffer_size);
networkLock->initialize();
if(openerEnabled)
{
networkOpener = new NetworkOpener(network, preferences, CharBuffer::get(), CHAR_BUFFER_SIZE);
networkOpener = new NetworkOpener(network, preferences, CharBuffer::get(), buffer_size);
networkOpener->initialize();
}