Allocate the DNSServer and ESP8266WebServer on the heap at begin() time and free them when autoConnect() terminates.

This reduces the likelihood of a stack overflow when WifiManager is instantiated in setup(),
and lowers memory usage (after wifi is connected) when it's instantiated globally.
This commit is contained in:
Christopher Pascoe
2015-12-13 16:03:13 -08:00
parent e36f7959c7
commit d3274bc5b9
2 changed files with 80 additions and 84 deletions
+3 -3
View File
@@ -18,7 +18,7 @@
//#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <memory>
class WiFiManager
{
@@ -56,8 +56,8 @@ public:
int serverLoop();
private:
DNSServer dnsServer;
ESP8266WebServer server;
std::unique_ptr<DNSServer> dnsServer;
std::unique_ptr<ESP8266WebServer> server;
const int WM_DONE = 0;
const int WM_WAIT = 10;