Skip to content

Commit 3070eb3

Browse files
Merge pull request #37 from ayushsharma82/dev
v1.2.2
2 parents 86df629 + 0aadbdd commit 3070eb3

9 files changed

Lines changed: 1021 additions & 830 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,30 @@ on:
2121
- "docs/*"
2222

2323
jobs:
24+
check-directives:
25+
name: Check Preprocessor Directives
26+
runs-on: ubuntu-latest
27+
env:
28+
HEADER_FILE: src/NetWizard.h
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
32+
- name: Check NETWIZARD_USE_ASYNC_WEBSERVER
33+
env:
34+
DIRECTIVE: NETWIZARD_USE_ASYNC_WEBSERVER
35+
EXPECTED_VALUE: 0
36+
run: |
37+
if [ ! -f "$HEADER_FILE" ]; then
38+
echo "$HEADER_FILE not found!" && exit 1
39+
fi
40+
if ! grep -Eq "#define[[:space:]]+$DIRECTIVE[[:space:]]+$EXPECTED_VALUE([[:space:]]+|$)" "$HEADER_FILE"; then
41+
echo "$DIRECTIVE is not set to $EXPECTED_VALUE!" && exit 1
42+
fi
43+
echo "Preprocessor directive is correctly set to $EXPECTED_VALUE."
44+
2445
arduino:
2546
name: Arduino - ${{ matrix.name }}
47+
needs: check-directives
2648
runs-on: ubuntu-latest
2749
strategy:
2850
fail-fast: false
@@ -73,25 +95,25 @@ jobs:
7395

7496
- name: Install AsyncTCP (ESP32)
7597
if: ${{ matrix.core == 'esp32:esp32' }}
76-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.3.5
98+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.4.10
7799

78100
- name: Install ESPAsyncTCP (ESP8266)
79101
if: ${{ matrix.core == 'esp8266:esp8266' }}
80102
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncTCP#v2.0.0
81103

82104
- name: Install RPAsyncTCP (RP2040)
83105
if: ${{ matrix.core == 'rp2040:rp2040' }}
84-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ayushsharma82/RPAsyncTCP#v1.3.1
106+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ayushsharma82/RPAsyncTCP#v1.3.2
85107

86108
- name: Install ESPAsyncWebServer
87-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncWebServer#v3.7.2
109+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncWebServer#v3.9.6
88110

89111
- name: Install ArduinoJson
90-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/bblanchon/ArduinoJson#v7.3.0
112+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/bblanchon/ArduinoJson#v7.4.2
91113

92114
- name: Install Preferences
93115
if: ${{ matrix.core == 'esp8266:esp8266' || matrix.core == 'rp2040:rp2040' }}
94-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/vshymanskyy/Preferences#v2.1.0
116+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/vshymanskyy/Preferences#v2.2.2
95117

96118
- name: Build Demo
97119
run: arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/Demo/Demo.ino"
@@ -106,6 +128,7 @@ jobs:
106128

107129
platformio:
108130
name: PlatformIO - ${{ matrix.name }}
131+
needs: check-directives
109132
runs-on: ubuntu-latest
110133
strategy:
111134
fail-fast: false

docs/flow-diagram.mmd

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
flowchart TD
2+
Start(["User Sketch Starts"]) --> Init["Create NetWizard instance<br/>NW = NetWizard(&server)"]
3+
Init --> Config["Optional Setup:<br/>setStrategy, setHostname,<br/>setAuthentication, addParameters,<br/>register callbacks"]
4+
Config --> AC["autoConnect(apSSID, apPass)"]
5+
6+
AC --> LoadCreds["Load saved WiFi credentials<br/>from NVS / Preferences"]
7+
LoadCreds --> HasCreds{"Saved credentials<br/>exist?"}
8+
9+
HasCreds -- Yes --> TryConnect["Connect to saved WiFi<br/>with retry up to connectTimeout"]
10+
TryConnect --> Connected{"Connected?"}
11+
Connected -- Yes --> Done["WiFi Connected"]
12+
Connected -- No --> NeedPortal["Start Captive Portal"]
13+
14+
HasCreds -- No --> NeedPortal
15+
16+
NeedPortal --> PortalStart["Start Captive Portal<br/>WiFi AP+STA mode<br/>DNS Server + HTTP Server + WiFi Scan"]
17+
18+
subgraph Portal["Captive Portal Active"]
19+
direction TB
20+
PortalUI["User opens portal webpage<br/>192.168.4.1"]
21+
PortalUI --> SelectWiFi["Selects WiFi network<br/>+ enters password + config params"]
22+
SelectWiFi --> Submit["Submits via /netwizard/save"]
23+
Submit --> TryNew["Portal tries connecting<br/>to submitted credentials"]
24+
TryNew --> NewResult{"Connected?"}
25+
NewResult -- Yes --> SaveCreds["Save credentials to NVS<br/>State = SUCCESS"]
26+
NewResult -- No / Timeout --> RetryOrFail["State = TIMEOUT<br/>User can try again"]
27+
RetryOrFail --> PortalUI
28+
end
29+
30+
PortalStart --> Portal
31+
32+
subgraph Strategy["Execution Strategy"]
33+
direction LR
34+
Blocking["BLOCKING<br/>Waits here until<br/>portal completes"]
35+
NonBlocking["NON_BLOCKING<br/>Returns immediately"]
36+
end
37+
38+
PortalStart --> Strategy
39+
40+
SaveCreds --> StopPortal["Stop Portal<br/>Stop DNS + HTTP + SoftAP"]
41+
StopPortal --> Reconnect{"Has saved<br/>credentials?"}
42+
Reconnect -- Yes --> STAMode["Switch to STA mode<br/>Connect to saved WiFi"]
43+
Reconnect -- No --> Off["Turn WiFi off"]
44+
STAMode --> Done
45+
Off --> Idle["Idle - No WiFi"]
46+
47+
Done --> MainLoop(["loop - must be called repeatedly"])
48+
Idle --> MainLoop
49+
50+
MainLoop --> M1["Process DNS + HTTP requests"]
51+
M1 --> M2["Update WiFi connection status"]
52+
M2 --> M3["Run portal state machine<br/>if portal is active"]
53+
M3 --> M4["Check portal timeout<br/>Default: 5 minutes"]
54+
M4 --> M5["Fire status/state<br/>change callbacks"]
55+
M5 --> MainLoop
56+
57+
classDef green fill:#4CAF50,stroke:#388E3C,color:#fff
58+
classDef blue fill:#2196F3,stroke:#1565C0,color:#fff
59+
classDef orange fill:#FF9800,stroke:#E65100,color:#fff
60+
classDef purple fill:#9C27B0,stroke:#6A1B9A,color:#fff
61+
classDef red fill:#f44336,stroke:#c62828,color:#fff
62+
63+
class Done,SaveCreds green
64+
class PortalStart,Portal blue
65+
class TryConnect,TryNew orange
66+
class MainLoop purple
67+
class RetryOrFail,Off red

docs/flow-diagram.svg

Lines changed: 67 additions & 0 deletions
Loading

library.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
"name": "NetWizard",
33
"keywords": "NetWizard, wifi, manager, esp, captive, portal",
44
"description": "An easy-to-use yet powerful WiFi manager and captive portal library for wireless microcontrollers.",
5-
"repository":
6-
{
5+
"repository": {
76
"type": "git",
87
"url": "https://github.com/ayushsharma82/NetWizard.git"
98
},
10-
"authors":
11-
[
9+
"authors": [
1210
{
1311
"name": "Ayush Sharma",
1412
"email": "asrocks5@gmail.com",
@@ -19,23 +17,23 @@
1917
{
2018
"owner": "bblanchon",
2119
"name": "ArduinoJson",
22-
"version": "^7.3.1",
20+
"version": "^7.4.2",
2321
"platforms": ["espressif8266", "espressif32", "raspberrypi"]
2422
},
2523
{
2624
"owner": "ESP32Async",
2725
"name": "ESPAsyncWebServer",
28-
"version": "^3.7.2",
26+
"version": "^3.9.6",
2927
"platforms": ["espressif8266", "espressif32", "raspberrypi"]
3028
},
3129
{
3230
"owner": "vshymanskyy",
3331
"name": "Preferences",
34-
"version": "^2.1.0",
32+
"version": "^2.2.2",
3533
"platforms": ["espressif8266", "raspberrypi"]
3634
}
3735
],
38-
"version": "1.2.1",
36+
"version": "1.2.2",
3937
"frameworks": "arduino",
4038
"platforms": ["espressif32", "raspberrypi"]
4139
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=NetWizard
2-
version=1.2.1
2+
version=1.2.2
33
author=Ayush Sharma
44
category=Communication
55
maintainer=Ayush Sharma <asrocks5@gmail.com>

0 commit comments

Comments
 (0)