Skip to content

Conversation

@runeharlyk
Copy link
Collaborator

Purpose

When updating firmware, making the device sleep or restarting, the server does not get the chance to respond as the request handling function never returns.
By wrapping the non-returning functionality in tasks, the server can respond with an OK status before eg. restarting.

esp_err_t UploadFirmwareService::uploadComplete(PsychicRequest *request)
{
(...)
    if (!request->_tempObject)
    {
        request->reply(200);
        RestartService::restartNow(); 
        return ESP_OK; // Before this could not be reached
    }
}

@theelims theelims merged commit f44de68 into main Dec 20, 2024
@theelims theelims deleted the task-isolation-restart-sleep branch December 20, 2024 08:58
leokeba pushed a commit to leokeba/ESP32-sveltekit that referenced this pull request Feb 8, 2025
…leep

Isolate non-returning functions in new tasks
leokeba pushed a commit to open-heliostat/spin-sequencer that referenced this pull request Feb 8, 2025
…leep

Isolate non-returning functions in new tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants