chmorgan / esphttpd-freertos

freertos example of libesphttpd for esp32 and esp8266
53 stars 14 forks source link

httpdFreertosStart shutdown/deinit #8

Closed Elektrik1 closed 5 years ago

Elektrik1 commented 5 years ago

Hello,

Can't find any documentation how to deinit httpd instance, it causes StoreProhibited error wen trying to esp_wifi_stop(); and esp_wifi_deinit(); after httpdFreertosStart was called, resulting in no possibility to turn off wifi dynamically with httpd server.

chmorgan commented 5 years ago

Sorry for the late response.

In include/libesphttpd/httpd.h, https://github.com/chmorgan/libesphttpd/blob/master/include/libesphttpd/httpd.h

You’ll find httpdShutdown() that you can use to stop the server thread. It is optional to save code space although I’m not sure that option actually does as the compiler should exclude it if you don’t call it.

Chris

On Sun, Aug 12, 2018 at 2:05 PM Julius notifications@github.com wrote:

Hello,

Can't find any documentation how to deinit httpd instance, it causes StoreProhibited error wen trying to esp_wifi_stop(); and esp_wifi_deinit(); after httpdFreertosStart was called, resulting in no possibility to turn off wifi dynamically with httpd server.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/esphttpd-freertos/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AKpIlQphvB2scytzayblCu7Mw41Zks5uQG5wgaJpZM4V5oX6 .

Elektrik1 commented 5 years ago

Thank you for your response.

It seems that there is some misalign with FreeRTOS/linux version of shutdown. I do use it on FreeRTOS (ESP32), and calling httpdShutdown(&httpdFreertosInstance); causes an error:

components/libesphttpd/include/libesphttpd/httpd.h:226:6: note: expected 'struct HttpdInstance ' but argument is of type 'HttpdFreertosInstance {aka struct < anonymous > }' void httpdShutdown(HttpdInstance pInstance); ^

am I missing something ?

Thank you.

chmorgan commented 5 years ago

Yep, you want this:

httpdShutdown(&httpdFreertosInstance.httpdInstance);

On Aug 17, 2018, at 8:11 PM, Julius notifications@github.com wrote:

Thank you for your response.

It seems that there is some misalign with FreeRTOS/linux version of shutdown. I do use it on FreeRTOS (ESP32), and calling httpdShutdown(&httpdFreertosInstance); causes an error:

components/libesphttpd/include/libesphttpd/httpd.h:226:6: note: expected 'struct HttpdInstance ' but argument is of type 'HttpdFreertosInstance {aka struct < anonymous > }' void httpdShutdown(HttpdInstance pInstance); ^

am I missing something ?

Thank you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chmorgan/esphttpd-freertos/issues/8#issuecomment-414016752, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AHj2UNkIxGCEkhhAoKBx4sm1-oAnks5uR1uvgaJpZM4V5oX6.

Elektrik1 commented 5 years ago

Thank you very much, work like a charm!

Have a nice day