Skip to content

Commit

Permalink
patch to avoid connection breaks because slow tcp processing
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiam committed Feb 15, 2021
1 parent dc024a7 commit c5c0daf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions HCPBridge/extra_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from distutils import dir_util
Import("env")
dir_util.copy_tree("patch",".")
1 change: 1 addition & 0 deletions HCPBridge/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ framework = arduino
lib_deps =
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
bblanchon/ArduinoJson@^6.17.2
extra_scripts = pre:extra_script.py
12 changes: 9 additions & 3 deletions HCPBridge/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ HCIEmulator emulator(&RS485);
// webserver on port 80
AsyncWebServer server(80);

// called by ESPAsyncTCP-esphome:SyncClient.cpp (see patch) instead of delay to avoid connection breaks
void DelayHandler(void){
emulator.poll();
}

// switch GPIO4 und GPIO2 sync to the lamp
void onStatusChanged(const SHCIState& state){
Expand All @@ -57,6 +61,8 @@ void switchLamp(bool on){
}
}



// setup mcu
void setup(){

Expand All @@ -71,7 +77,7 @@ void setup(){
WiFi.begin(ssid, password);
WiFi.setAutoReconnect(true);
while (WiFi.status() != WL_CONNECTED) {
emulator.poll();
emulator.poll();
}

// setup http server
Expand Down Expand Up @@ -158,6 +164,6 @@ void setup(){
}

// mainloop
void loop(){
emulator.poll();
void loop(){
emulator.poll();
}

0 comments on commit c5c0daf

Please sign in to comment.