From f50d0459c7b71aa5f5c5295c65d7a01e85e98751 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 01:25:35 +0530 Subject: [PATCH 1/9] fix: ci --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d5b565..2099f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,10 +48,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # - name: Arduino Lint - # uses: arduino/arduino-lint-action@v1 - # with: - # library-manager: update + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + library-manager: update - name: Install arduino-cli run: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh From d947bf8fccfe13f2b50bc60019b422d5440b4439 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 01:26:08 +0530 Subject: [PATCH 2/9] chore: bump version --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 3852ba5..bb1683d 100644 --- a/library.json +++ b/library.json @@ -29,7 +29,7 @@ "platforms": ["espressif8266", "espressif32"] } ], - "version": "1.0.1", + "version": "1.0.2", "frameworks": "arduino", "platforms": ["espressif32", "raspberrypi"] } diff --git a/library.properties b/library.properties index e462ace..252ec69 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=NetWizard -version=1.0.1 +version=1.0.2 author=Ayush Sharma category=Communication maintainer=Ayush Sharma From e235a1871c991f3ce3e47e5faeba9151b9fd2d54 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 17:17:10 +0530 Subject: [PATCH 3/9] fix: add getPortalState --- src/NetWizard.cpp | 4 ++++ src/NetWizard.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/NetWizard.cpp b/src/NetWizard.cpp index 3960a58..e68aa23 100644 --- a/src/NetWizard.cpp +++ b/src/NetWizard.cpp @@ -171,6 +171,10 @@ NetWizardConnectionStatus NetWizard::getConnectionStatus() { return _nw.status; } +NetWizardPortalState NetWizard::getPortalState() { + return _nw.portal.state; +} + const char* NetWizard::getSSID() { return _nw.sta.ssid.c_str(); } diff --git a/src/NetWizard.h b/src/NetWizard.h index 1f0c583..2f4f3f7 100644 --- a/src/NetWizard.h +++ b/src/NetWizard.h @@ -160,6 +160,7 @@ class NetWizard { // status bool isConfigured(); NetWizardConnectionStatus getConnectionStatus(); + NetWizardPortalState getPortalState(); const char* getSSID(); const char* getPassword(); void getBSSID(uint8_t* bssid); From 339acab5435da37b3ec7e7f07d8b68315608d7c2 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 17:31:06 +0530 Subject: [PATCH 4/9] fix: reset function --- src/NetWizard.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NetWizard.cpp b/src/NetWizard.cpp index e68aa23..58b506b 100644 --- a/src/NetWizard.cpp +++ b/src/NetWizard.cpp @@ -225,6 +225,13 @@ void NetWizard::reset() { // disconnect from wifi _disconnect(); _nw.status = NetWizardConnectionStatus::DISCONNECTED; + + // stop captive portal + if (_nw.portal.active) { + // set exit flag + _nw.portal.exit.flag = true; + _nw.portal.exit.millis = millis(); + } } void NetWizard::loop() { From 0eeb2fbd097e9a1730f3e46140a34feabc168e45 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 17:34:23 +0530 Subject: [PATCH 5/9] fix: add missing onConfig callback in examples --- examples/AsyncDemo/AsyncDemo.ino | 8 ++++++++ examples/Demo/Demo.ino | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/AsyncDemo/AsyncDemo.ino b/examples/AsyncDemo/AsyncDemo.ino index aefe5e0..ec5550a 100644 --- a/examples/AsyncDemo/AsyncDemo.ino +++ b/examples/AsyncDemo/AsyncDemo.ino @@ -127,6 +127,14 @@ void setup(void) { Serial.printf("NW portal state changed: %s\n", state_str); }); + NW.onConfig([&]() { + Serial.println("NW onConfig Received"); + + // Print new parameter values + Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str()); + Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str()); + }); + // Start NetWizard NW.autoConnect("NetWizard Demo", ""); diff --git a/examples/Demo/Demo.ino b/examples/Demo/Demo.ino index 58ade81..30cf753 100644 --- a/examples/Demo/Demo.ino +++ b/examples/Demo/Demo.ino @@ -117,6 +117,14 @@ void setup(void) { Serial.printf("NW portal state changed: %s\n", state_str); }); + NW.onConfig([&]() { + Serial.println("NW onConfig Received"); + + // Print new parameter values + Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str()); + Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str()); + }); + // Start NetWizard NW.autoConnect("NetWizard Demo", ""); From c88fc12ae711583f2e95425a776d2db5ccc33561 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 4 Jul 2024 17:35:11 +0530 Subject: [PATCH 6/9] fix: onconfig callbacks --- examples/AsyncDemo/AsyncDemo.ino | 1 + examples/Demo/Demo.ino | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/AsyncDemo/AsyncDemo.ino b/examples/AsyncDemo/AsyncDemo.ino index ec5550a..e621a48 100644 --- a/examples/AsyncDemo/AsyncDemo.ino +++ b/examples/AsyncDemo/AsyncDemo.ino @@ -133,6 +133,7 @@ void setup(void) { // Print new parameter values Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str()); Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str()); + return true; // <-- return true to approve request, false to reject }); // Start NetWizard diff --git a/examples/Demo/Demo.ino b/examples/Demo/Demo.ino index 30cf753..6c3b73e 100644 --- a/examples/Demo/Demo.ino +++ b/examples/Demo/Demo.ino @@ -123,6 +123,7 @@ void setup(void) { // Print new parameter values Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str()); Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str()); + return true; // <-- return true to approve request, false to reject }); // Start NetWizard From 20c5b0a68eb934b2446c2c9a1b53848d00c758a5 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Fri, 5 Jul 2024 11:59:20 +0530 Subject: [PATCH 7/9] fix: readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5963888..f0b3e86 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ Additionally, NetWizard lets you create an custom configuration page of your choice which is shown at the time of setup. The possibilities are endless! -

## Features From 07f7d95bca37b1b1cfdab83d0b9e485a4eaa7ed9 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Fri, 5 Jul 2024 17:01:07 +0530 Subject: [PATCH 8/9] fix: gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cbc0236..37a2481 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,8 @@ node_modules .pio # Arduino CLI -/examples/**/build \ No newline at end of file +/examples/**/build + +# Switch protection +/node_modules +/.next \ No newline at end of file From b83530c3da8fe34705c4c0307724eeae79b7e647 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Fri, 5 Jul 2024 17:04:21 +0530 Subject: [PATCH 9/9] fix: missing hostname logic --- src/NetWizard.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NetWizard.cpp b/src/NetWizard.cpp index 58b506b..6b8e5c7 100644 --- a/src/NetWizard.cpp +++ b/src/NetWizard.cpp @@ -367,6 +367,8 @@ void NetWizard::removeParameter(NetWizardParameter* parameter) { } void NetWizard::_connect(const char* ssid, const char* password) { + // Set hostname + WiFi.setHostname(_nw.hostname.c_str()); // Connect to WiFi WiFi.begin(ssid, password); _nw.status = NetWizardConnectionStatus::CONNECTING;