Skip to content

Commit ddef44c

Browse files
author
mariuste
committed
Add error JSON files and update WiFi connection logic in main.cpp
1 parent 4ca1338 commit ddef44c

6 files changed

Lines changed: 287 additions & 30 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"cmake" :
3+
{
4+
"generator" :
5+
{
6+
"multiConfig" : false,
7+
"name" : "Unix Makefiles"
8+
},
9+
"paths" :
10+
{
11+
"cmake" : "/opt/homebrew/bin/cmake",
12+
"cpack" : "/opt/homebrew/bin/cpack",
13+
"ctest" : "/opt/homebrew/bin/ctest",
14+
"root" : "/opt/homebrew/share/cmake"
15+
},
16+
"version" :
17+
{
18+
"isDirty" : false,
19+
"major" : 4,
20+
"minor" : 3,
21+
"patch" : 2,
22+
"string" : "4.3.2",
23+
"suffix" : ""
24+
}
25+
},
26+
"objects" : [],
27+
"reply" :
28+
{
29+
"client-vscode" :
30+
{
31+
"query.json" :
32+
{
33+
"requests" :
34+
[
35+
{
36+
"kind" : "cache",
37+
"version" : 2
38+
},
39+
{
40+
"kind" : "codemodel",
41+
"version" : 2
42+
},
43+
{
44+
"kind" : "toolchains",
45+
"version" : 1
46+
},
47+
{
48+
"kind" : "cmakeFiles",
49+
"version" : 1
50+
}
51+
],
52+
"responses" :
53+
[
54+
{
55+
"error" : "no buildsystem generated"
56+
},
57+
{
58+
"error" : "no buildsystem generated"
59+
},
60+
{
61+
"error" : "no buildsystem generated"
62+
},
63+
{
64+
"error" : "no buildsystem generated"
65+
}
66+
]
67+
}
68+
}
69+
}
70+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"cmake" :
3+
{
4+
"generator" :
5+
{
6+
"multiConfig" : false,
7+
"name" : "Unix Makefiles"
8+
},
9+
"paths" :
10+
{
11+
"cmake" : "/opt/homebrew/bin/cmake",
12+
"cpack" : "/opt/homebrew/bin/cpack",
13+
"ctest" : "/opt/homebrew/bin/ctest",
14+
"root" : "/opt/homebrew/share/cmake"
15+
},
16+
"version" :
17+
{
18+
"isDirty" : false,
19+
"major" : 4,
20+
"minor" : 3,
21+
"patch" : 2,
22+
"string" : "4.3.2",
23+
"suffix" : ""
24+
}
25+
},
26+
"objects" : [],
27+
"reply" :
28+
{
29+
"client-vscode" :
30+
{
31+
"query.json" :
32+
{
33+
"requests" :
34+
[
35+
{
36+
"kind" : "cache",
37+
"version" : 2
38+
},
39+
{
40+
"kind" : "codemodel",
41+
"version" : 2
42+
},
43+
{
44+
"kind" : "toolchains",
45+
"version" : 1
46+
},
47+
{
48+
"kind" : "cmakeFiles",
49+
"version" : 1
50+
}
51+
],
52+
"responses" :
53+
[
54+
{
55+
"error" : "no buildsystem generated"
56+
},
57+
{
58+
"error" : "no buildsystem generated"
59+
},
60+
{
61+
"error" : "no buildsystem generated"
62+
},
63+
{
64+
"error" : "no buildsystem generated"
65+
}
66+
]
67+
}
68+
}
69+
}
70+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"cmake" :
3+
{
4+
"generator" :
5+
{
6+
"multiConfig" : false,
7+
"name" : "Unix Makefiles"
8+
},
9+
"paths" :
10+
{
11+
"cmake" : "/opt/homebrew/bin/cmake",
12+
"cpack" : "/opt/homebrew/bin/cpack",
13+
"ctest" : "/opt/homebrew/bin/ctest",
14+
"root" : "/opt/homebrew/share/cmake"
15+
},
16+
"version" :
17+
{
18+
"isDirty" : false,
19+
"major" : 4,
20+
"minor" : 3,
21+
"patch" : 2,
22+
"string" : "4.3.2",
23+
"suffix" : ""
24+
}
25+
},
26+
"objects" : [],
27+
"reply" :
28+
{
29+
"client-vscode" :
30+
{
31+
"query.json" :
32+
{
33+
"requests" :
34+
[
35+
{
36+
"kind" : "cache",
37+
"version" : 2
38+
},
39+
{
40+
"kind" : "codemodel",
41+
"version" : 2
42+
},
43+
{
44+
"kind" : "toolchains",
45+
"version" : 1
46+
},
47+
{
48+
"kind" : "cmakeFiles",
49+
"version" : 1
50+
}
51+
],
52+
"responses" :
53+
[
54+
{
55+
"error" : "no buildsystem generated"
56+
},
57+
{
58+
"error" : "no buildsystem generated"
59+
},
60+
{
61+
"error" : "no buildsystem generated"
62+
},
63+
{
64+
"error" : "no buildsystem generated"
65+
}
66+
]
67+
}
68+
}
69+
}
70+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"cmake" :
3+
{
4+
"generator" :
5+
{
6+
"multiConfig" : false,
7+
"name" : "Unix Makefiles"
8+
},
9+
"paths" :
10+
{
11+
"cmake" : "/opt/homebrew/bin/cmake",
12+
"cpack" : "/opt/homebrew/bin/cpack",
13+
"ctest" : "/opt/homebrew/bin/ctest",
14+
"root" : "/opt/homebrew/share/cmake"
15+
},
16+
"version" :
17+
{
18+
"isDirty" : false,
19+
"major" : 4,
20+
"minor" : 3,
21+
"patch" : 2,
22+
"string" : "4.3.2",
23+
"suffix" : ""
24+
}
25+
},
26+
"objects" : [],
27+
"reply" :
28+
{
29+
"client-vscode" :
30+
{
31+
"query.json" :
32+
{
33+
"requests" :
34+
[
35+
{
36+
"kind" : "cache",
37+
"version" : 2
38+
},
39+
{
40+
"kind" : "codemodel",
41+
"version" : 2
42+
},
43+
{
44+
"kind" : "toolchains",
45+
"version" : 1
46+
},
47+
{
48+
"kind" : "cmakeFiles",
49+
"version" : 1
50+
}
51+
],
52+
"responses" :
53+
[
54+
{
55+
"error" : "no buildsystem generated"
56+
},
57+
{
58+
"error" : "no buildsystem generated"
59+
},
60+
{
61+
"error" : "no buildsystem generated"
62+
},
63+
{
64+
"error" : "no buildsystem generated"
65+
}
66+
]
67+
}
68+
}
69+
}
70+
}

firmware/projects/RFID_BOX_legacy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.vscode/c_cpp_properties.json
44
.vscode/launch.json
55
.vscode/ipch
6+
include/secret.h

firmware/projects/RFID_BOX_legacy/src/main.cpp

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ void setup() {
155155

156156
delay(1000); // wait for pullups to get active
157157

158-
WiFi.mode(WIFI_STA);
159-
WiFi.setAutoReconnect(true);
160-
WiFi.persistent(false);
161-
connectToWiFi(true);
158+
connectToWiFi();
162159

163160
#ifdef OTA_ENABLED
164161
ArduinoOTA.setHostname(OTA_HOSTNAME);
@@ -308,39 +305,18 @@ void setLED_ryg(bool led_red, bool led_yellow, bool led_green) {
308305
/**
309306
* @brief Connects the ESP32 to the WiFi network.
310307
*/
311-
void connectToWiFi(bool waitForConnection) {
312-
unsigned long now = millis();
313-
if (!waitForConnection && (now - lastWiFiReconnectAttemptMs < WIFI_RECONNECT_INTERVAL_MS)) {
314-
return;
315-
}
316-
317-
lastWiFiReconnectAttemptMs = now;
318-
if (!wifiConnectionStarted) {
319-
Log.notice("[WiFi] Connecting to %s ...\n", WIFI_SSID);
320-
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
321-
wifiConnectionStarted = true;
322-
} else {
323-
Log.notice("[WiFi] Reconnect attempt to %s ...\n", WIFI_SSID);
324-
WiFi.reconnect();
325-
}
326-
327-
if (!waitForConnection) {
328-
return;
329-
}
330-
308+
void connectToWiFi() {
309+
Log.notice("[WiFi] Connecting to %s ...\n", WIFI_SSID);
310+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
331311
int retries = 0;
332-
while (WiFi.status() != WL_CONNECTED && retries < 10) {
312+
while (WiFi.status() != WL_CONNECTED && retries < 30) {
333313
delay(1000);
334314
retries++;
335-
Serial.print(".");
315+
Log.notice(".[WiFi] status=%d\n", static_cast<int>(WiFi.status()));
336316
}
337317

338318
if (WiFi.status() == WL_CONNECTED) {
339-
wifiWasConnected = true;
340319
Log.notice("\n[WiFi] Connected. IP: %s\n", WiFi.localIP().toString().c_str());
341-
} else {
342-
wifiWasConnected = false;
343-
Log.warning("\n[WiFi] Initial connect timeout, continuing offline.\n");
344320
}
345321
}
346322

0 commit comments

Comments
 (0)