dismissing wifi to save power
Posted: Fri Feb 07, 2020 5:26 am
I have an application in which I want to very occasionally start up wifi to POST some data to a remote server. I can get things going and POST the message, but am having trouble with the tear-down phase. As I read the docs, the right steps and the order in which they should be called is:
esp_http_client_cleanup( client ); // dismiss the TCP stack
esp_wifi_disconnect() // break connection to AP
esp_wifi_stop() // shut down the wifi radio
esp_wifi_deinit() // release wifi resources
When I run this, I get an error from the system apparently during the call to esp_wifi_stop() that says:
"wifi: esp_wifi_connect 1145 wifi not start"
Interestingly, while I can find a declaration of esp_wifi_stop() in a header file, I can't find that function in an executable (.c) file, so I can't dig into the code myself.
But I'd be happy if someone can tell me the correct way to tear down tcp and wifi stacks and dismiss the resources without throwing an error, what to call and in what order.
esp_http_client_cleanup( client ); // dismiss the TCP stack
esp_wifi_disconnect() // break connection to AP
esp_wifi_stop() // shut down the wifi radio
esp_wifi_deinit() // release wifi resources
When I run this, I get an error from the system apparently during the call to esp_wifi_stop() that says:
"wifi: esp_wifi_connect 1145 wifi not start"
Interestingly, while I can find a declaration of esp_wifi_stop() in a header file, I can't find that function in an executable (.c) file, so I can't dig into the code myself.
But I'd be happy if someone can tell me the correct way to tear down tcp and wifi stacks and dismiss the resources without throwing an error, what to call and in what order.