File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,3 +16,6 @@ lib_deps =
1616 adafruit/Adafruit BMP280 Library@^2.6.8
1717 adafruit/Adafruit AHTX0@^2.0.5
1818 claws/BH1750@^1.3.0
19+ monitor_speed = 115200
20+ upload_speed = 921600
21+
Original file line number Diff line number Diff line change @@ -60,21 +60,29 @@ void isolate_all_rtc_gpio()
6060
6161/* *
6262 * Establishes a WiFi connection using credentials from env.h
63- *
64- * @note This function will block indefinitely if WiFi connection fails
65- * TODO(FIX): this surely shouldn't be implemented this way
66- * TODO(FIX): we should FIX it ASAP as it already caused issues
6763 */
6864void connect_to_wifi ()
6965{
7066 serial_log (" Connecting to WiFi..." );
7167 WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
72- while (WiFi.status () != WL_CONNECTED) {
68+ for (int i = 0 ; i < 20 ; i++) {
69+ if (WiFi.status () == WL_CONNECTED) {
70+ serial_log (" \n WiFi connected!" );
71+ serial_log (WiFi.localIP ().toString ());
72+ return ;
73+ }
74+ if (WiFi.status () == WL_NO_SSID_AVAIL) {
75+ Serial.println (" SSID not found!" );
76+ Serial.println (" Entering deep sleep for 5 minutes." );
77+ esp_sleep_enable_timer_wakeup (300000000 );
78+ esp_deep_sleep_start ();
79+ }
7380 delay (500 );
7481 serial_log (" ." );
7582 }
76- serial_log (" \n WiFi connected!" );
77- serial_log (WiFi.localIP ().toString ());
83+
84+ Serial.println (" Response: " + String (WiFi.status ()));
85+ ESP.restart ();
7886}
7987
8088/* *
You can’t perform that action at this time.
0 commit comments