scottchiefbaker / ESP-WebOTA

Simple web based Over-the-Air (OTA) updates for ESP based projects
MIT License
283 stars 38 forks source link

Use WebOTA in FreeRTOS ? #18

Open Pigi-102 opened 1 year ago

Pigi-102 commented 1 year ago

That's not an issue but a question. I've used your code in several projects and would like to use it also on a new one I've borrowed around ( an energy monitor for the house ). Difference this time is that the project use FreeRTOS and works with tasks and not the usual loop. I was wondering if you or someone has never thougth to use this code in a FreeRTOS environment.

Thanks for your code and thanks for your time :)

scottchiefbaker commented 11 months ago

I have zero experience with FreeRTOS but I'd be open to pull requests.

ryancasler commented 10 months ago

I know this is an old issue but I have done this through creating a task to initialize the webOTA that contains a while loop that runs the webota.handle method as well. Something like this:

TaskHandle_t webota;
xTaskCreatePinnedToCore(handleWebOTA, "WebOTA", 10000, NULL, 1, &webota, 0);

void handleWebOTA(void* parameters){
  webota.init(8080, "/update");
  while(1){
    webota.handle();
  }
}

I thought I would run into heap problems since the task is not large enough to handle the whole sketch but it works just fine. I think only because webota resets the board as soon as it is done updating. I've been using this method for a while without issue.