FYSETC / FYSETC-SD-WIFI

This repository contains the infomation of FYSETC SD-WIFI module
44 stars 16 forks source link

Time between connecting to wifi and starting the webDAV server #3

Open Sineos opened 3 years ago

Sineos commented 3 years ago

I have the issue that I need to reboot sometimes multiple times for the firmware to successfully start the webDAV server. From the terminal output it is always the same:

  1. Initial WIFI connection is shown as failure
  2. M53 also says Wifi not connected
  3. In my router and the access point the SD-WIFI is shown as successfully connected
  4. Sometimes another M53 will show success and the webDAV is started. Sometimes only (multiple) reboots will help

For me it looks like that some timeout fire too soon and are not giving the WIFI connection enough time to "settle"

TuguanLing commented 3 years ago

Hello, unstable wifi connection is generally a signal problem, this module is a weak signal caused by an on-board antenna, you can try some ways to enhance the signal, or enhance your router signal, this problem may be improved.

Sineos commented 3 years ago

Hello, unstable wifi connection is generally a signal problem, this module is a weak signal caused by an on-board antenna, you can try some ways to enhance the signal, or enhance your router signal, this problem may be improved.

Thanks for your advice and you are totally right. I know these ESP beasts pretty well, since I have around 8 ESPs as various IOT devices in my home. Further I have 3 enterprise level access point distributed, providing a pretty good WIFI coverage.

The point is:

I made following changes and since then never had a single failure to connect and start the webDAV server:

diff --git a/network.cpp b/network.cpp
index 6db1083..2cce0b2 100644
--- a/network.cpp
+++ b/network.cpp
@@ -31,6 +31,7 @@ bool Network::start() {
   while(WiFi.status() != WL_CONNECTED) {
     //blink();
     SERIAL_ECHO(".");
+    delay(100);
     timeout++;
     if(timeout++ > WIFI_CONNECT_TIMEOUT/100) {
       SERIAL_ECHOLN("");
@@ -38,7 +39,7 @@ bool Network::start() {
       return false;
     }
     else
-      delay(100);
+      delay(1000);
   }

   SERIAL_ECHOLN("");
diff --git a/network.h b/network.h
index 1757897..9e17774 100644
--- a/network.h
+++ b/network.h
@@ -4,7 +4,7 @@
 #define HOSTNAME               "FYSETC"
 #define SERVER_PORT            80

-#define WIFI_CONNECT_TIMEOUT 30000UL
+#define WIFI_CONNECT_TIMEOUT 80000UL

 class Network {
 public:

I would assume the critical change is increasing the delay from 100 to 1000