Skip to content

Commit

Permalink
Merge pull request #2 from ayushsharma82/dev
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
ayushsharma82 authored Jul 5, 2024
2 parents 218a7ed + b83530c commit f593bfa
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ node_modules
.pio

# Arduino CLI
/examples/**/build
/examples/**/build

# Switch protection
/node_modules
/.next
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

<br/>
<br/>

## Features
Expand Down
9 changes: 9 additions & 0 deletions examples/AsyncDemo/AsyncDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ 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());
return true; // <-- return true to approve request, false to reject
});

// Start NetWizard
NW.autoConnect("NetWizard Demo", "");

Expand Down
9 changes: 9 additions & 0 deletions examples/Demo/Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ 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());
return true; // <-- return true to approve request, false to reject
});

// Start NetWizard
NW.autoConnect("NetWizard Demo", "");

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"platforms": ["espressif8266", "espressif32"]
}
],
"version": "1.0.1",
"version": "1.0.2",
"frameworks": "arduino",
"platforms": ["espressif32", "raspberrypi"]
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=NetWizard
version=1.0.1
version=1.0.2
author=Ayush Sharma
category=Communication
maintainer=Ayush Sharma <[email protected]>
Expand Down
13 changes: 13 additions & 0 deletions src/NetWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -221,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() {
Expand Down Expand Up @@ -356,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;
Expand Down
1 change: 1 addition & 0 deletions src/NetWizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class NetWizard {
// status
bool isConfigured();
NetWizardConnectionStatus getConnectionStatus();
NetWizardPortalState getPortalState();
const char* getSSID();
const char* getPassword();
void getBSSID(uint8_t* bssid);
Expand Down

0 comments on commit f593bfa

Please sign in to comment.