Преглед на файлове

Revert "yield to other app-level processes during longpoll"

This reverts commit 23ec90c961e5875da72d80090940cc426762dc8d.

Unfortunatley this caused problems with sniffing. Probably some radio code that doesn't handle the threadedness
Chris Mullins преди 8 години
родител
ревизия
d5c8951464
променени са 3 файла, в които са добавени 11 реда и са изтрити 26 реда
  1. 0 8
      lib/WebServer/MiLightHttpServer.cpp
  2. 0 3
      lib/WebServer/MiLightHttpServer.h
  3. 11 15
      src/main.cpp

+ 0 - 8
lib/WebServer/MiLightHttpServer.cpp

@@ -129,10 +129,6 @@ void MiLightHttpServer::applySettings(Settings& settings) {
 void MiLightHttpServer::onSettingsSaved(SettingsSavedHandler handler) {
   this->settingsSavedHandler = handler;
 }
-
-void MiLightHttpServer::onLongPollLoop(LongPollLoopFn fn) {
-  this->longPollLoopFn = fn;
-}
   
 void MiLightHttpServer::handleAbout() {
   DynamicJsonBuffer buffer;
@@ -246,10 +242,6 @@ void MiLightHttpServer::handleListenGateway(const UrlTokenBindings* bindings) {
       available = true;
     }
     
-    if (this->longPollLoopFn) {
-      longPollLoopFn();
-    }
-    
     yield();
   }
   

+ 0 - 3
lib/WebServer/MiLightHttpServer.h

@@ -8,7 +8,6 @@
 #define MAX_DOWNLOAD_ATTEMPTS 3
 
 typedef std::function<void(void)> SettingsSavedHandler;
-typedef std::function<void(void)> LongPollLoopFn;
 
 const char DEFAULT_INDEX_PAGE[] PROGMEM
   = "Web app not installed. Click <a href=\"/download_update/web\">here</a> to attempt to download it from GitHub.";
@@ -26,7 +25,6 @@ public:
   void begin();
   void handleClient();
   void onSettingsSaved(SettingsSavedHandler handler);
-  void onLongPollLoop(LongPollLoopFn);
   
 protected:
   ESP8266WebServer::THandlerFunction handleServeFile(
@@ -53,7 +51,6 @@ protected:
   Settings& settings;
   MiLightClient*& milightClient;
   SettingsSavedHandler settingsSavedHandler;
-  LongPollLoopFn longPollLoopFn;
   
 };
 

+ 11 - 15
src/main.cpp

@@ -77,19 +77,6 @@ bool shouldRestart() {
   return settings.getAutoRestartPeriod()*60*1000 < millis();
 }
 
-void handleLoop() {
-  if (udpServers) {
-    for (size_t i = 0; i < settings.numGatewayConfigs; i++) {
-      udpServers[i]->handleClient();
-    }
-  }
-  
-  if (shouldRestart()) {
-    Serial.println("Auto-restart triggered. Restarting...");
-    ESP.restart();
-  }
-}
-
 void setup() {
   Serial.begin(9600);
   wifiManager.autoConnect();
@@ -99,11 +86,20 @@ void setup() {
   
   httpServer = new MiLightHttpServer(settings, milightClient);
   httpServer->onSettingsSaved(applySettings);
-  httpServer->onLongPollLoop(handleLoop);
   httpServer->begin();
 }
 
 void loop() {
   httpServer->handleClient();
-  handleLoop();
+  
+  if (udpServers) {
+    for (size_t i = 0; i < settings.numGatewayConfigs; i++) {
+      udpServers[i]->handleClient();
+    }
+  }
+  
+  if (shouldRestart()) {
+    Serial.println("Auto-restart triggered. Restarting...");
+    ESP.restart();
+  }
 }