This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Releases v1.1.1 1. Clean-up all compiler warnings possible. 2. Add Table of Contents 3. Modify Version String
- Loading branch information
1 parent
98d6397
commit edfaa5e
Showing
7 changed files
with
878 additions
and
113 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
examples/ConfigOnDRD_ESP32_minimal/ConfigOnDRD_ESP32_minimal.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**************************************************************************************************************************** | ||
Async_ConfigOnDoubleReset_minimal.ino | ||
For ESP8266 / ESP32 boards | ||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager | ||
Licensed under MIT license | ||
*****************************************************************************************************************************/ | ||
#if defined(ESP32) | ||
#define USE_SPIFFS true | ||
#define ESP_DRD_USE_EEPROM true | ||
#else | ||
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. | ||
#endif | ||
#include <ESP_WiFiManager.h> //https://github.com/khoih-prog/ESP_WiFiManager | ||
#define DRD_TIMEOUT 10 | ||
#define DRD_ADDRESS 0 | ||
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector | ||
DoubleResetDetector* drd; | ||
const int PIN_LED = 2; | ||
bool initialConfig = false; | ||
|
||
void setup() { | ||
pinMode(PIN_LED, OUTPUT); | ||
Serial.begin(115200); while (!Serial); delay(200); | ||
Serial.print(F("\nStarting ConfigOnDoubleReset_minimal on ")); Serial.println(ARDUINO_BOARD); | ||
Serial.println(ESP_WIFIMANAGER_VERSION); | ||
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS); | ||
if (drd->detectDoubleReset()) { Serial.println(F("DRD")); initialConfig = true; } | ||
ESP_WiFiManager ESP_wifiManager("ConfigOnDoubleReset"); | ||
if (ESP_wifiManager.WiFi_SSID() == "") { Serial.println(F("No AP credentials")); initialConfig = true; } | ||
if (initialConfig) { | ||
Serial.println(F("Starting Config Portal")); digitalWrite(PIN_LED, HIGH); | ||
if (!ESP_wifiManager.startConfigPortal()) { Serial.println(F("Not connected to WiFi")); } | ||
else { Serial.println(F("connected")); } | ||
} | ||
else { WiFi.mode(WIFI_STA); WiFi.begin(); } | ||
unsigned long startedAt = millis(); | ||
digitalWrite(PIN_LED, LOW); Serial.print(F("After waiting ")); | ||
int connRes = WiFi.waitForConnectResult(); | ||
float waited = (millis() - startedAt); | ||
Serial.print(waited / 1000); Serial.print(F(" secs , Connection result is ")); Serial.println(connRes); | ||
if (WiFi.status() != WL_CONNECTED) { Serial.println(F("Failed to connect")); } | ||
else { Serial.print(F("Local IP: ")); Serial.println(WiFi.localIP()); } | ||
} | ||
void loop() { drd->loop(); } |
44 changes: 44 additions & 0 deletions
44
examples/ConfigOnDRD_ESP8266_minimal/ConfigOnDRD_ESP8266_minimal.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**************************************************************************************************************************** | ||
Async_ConfigOnDoubleReset_minimal.ino | ||
For ESP8266 / ESP32 boards | ||
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager | ||
Licensed under MIT license | ||
*****************************************************************************************************************************/ | ||
#if defined(ESP8266) | ||
#define USE_LITTLEFS true | ||
#define ESP_DRD_USE_LITTLEFS true | ||
#else | ||
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. | ||
#endif | ||
#include <ESP_WiFiManager.h> //https://github.com/khoih-prog/ESP_WiFiManager | ||
#define DRD_TIMEOUT 10 | ||
#define DRD_ADDRESS 0 | ||
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector | ||
DoubleResetDetector* drd; | ||
const int PIN_LED = 2; | ||
bool initialConfig = false; | ||
|
||
void setup() { | ||
pinMode(PIN_LED, OUTPUT); | ||
Serial.begin(115200); while (!Serial); delay(200); | ||
Serial.print(F("\nStarting ConfigOnDoubleReset_minimal on ")); Serial.println(ARDUINO_BOARD); | ||
Serial.println(ESP_WIFIMANAGER_VERSION); | ||
if (WiFi.SSID() == "") { Serial.println(F("No AP credentials")); initialConfig = true; } | ||
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS); | ||
if (drd->detectDoubleReset()) { Serial.println(F("DRD")); initialConfig = true; } | ||
if (initialConfig) { | ||
Serial.println(F("Starting Config Portal")); digitalWrite(PIN_LED, LOW); | ||
ESP_WiFiManager ESP_wifiManager("ConfigOnDoubleReset"); | ||
ESP_wifiManager.setConfigPortalTimeout(0); | ||
if (!ESP_wifiManager.startConfigPortal()) { Serial.println(F("Not connected to WiFi")); } | ||
else { Serial.println(F("connected")); } | ||
} | ||
digitalWrite(PIN_LED, HIGH); Serial.print(F("After waiting ")); //WiFi.mode(WIFI_STA); | ||
unsigned long startedAt = millis(); | ||
int connRes = WiFi.waitForConnectResult(); | ||
float waited = (millis() - startedAt); | ||
Serial.print(waited / 1000); Serial.print(F(" secs , Connection result is ")); Serial.println(connRes); | ||
if (WiFi.status() != WL_CONNECTED) { Serial.println(F("Failed to connect")); } | ||
else { Serial.print(F("Local IP: ")); Serial.println(WiFi.localIP()); } | ||
} | ||
void loop() { drd->loop(); } |
Oops, something went wrong.