A little help here please.
This wifi manager has options for what to do at first run if no stored wifi credentials are found.
The AP_NONE option far as I can tell should allow code in the loop to continue running while AP portal is open but it doesn't. Please let me know what I'm missing.
thanks. Sketch and links to header and source files:
https://github.com/smurf0969/WiFiConnec ... iConnect.h
https://github.com/smurf0969/WiFiConnec ... nnect.cpp
[Codebox]
#include "WiFiConnect.h"
#include <WiFiClient.h>
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266HTTPClient.h>
#else
#include <HTTPClient.h>
#endif
WiFiConnect wc;
// For internet connection
WiFiClient client;
HTTPClient http;
const int pin18=18;
void configModeCallback(WiFiConnect *mWiFiConnect) {
Serial.println("Entering Access Point");
}
void startWiFi(boolean showParams = false) {
wc.setDebug(true);
/* Set our callbacks */
wc.setAPCallback(configModeCallback);
//wc.resetSettings(); //helper to remove the stored wifi connection, comment out after first upload and re upload
/*
AP_NONE = Continue executing code
AP_LOOP = Trap in a continuous loop - Device is useless
AP_RESET = Restart the chip
AP_WAIT = Trap in a continuous loop with captive portal until we have a working WiFi connection
*/
if (!wc.autoConnect()) { // try to connect to wifi
/* We could also use button etc. to trigger the portal on demand within main loop */
wc.startConfigurationPortal(AP_NONE);//if not connected show the configuration portal
}
}
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100);
}
Serial.println("....");
Serial.println("....");
delay (5000);
startWiFi();
pinMode(pin18, OUTPUT);
}
void loop() {
digitalWrite(pin18, HIGH);
delay(500);
digitalWrite(pin18, LOW);
delay(500);
delay(100);
Serial.println("Testing with connection to internet...");
http.begin(client, "http://ftp.mirrorservice.org/sites/arch ... om/ubuntu/");
int httpCode = http.GET();
if (httpCode > 0)
{
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if (httpCode == HTTP_CODE_OK)
{
Serial.println("HTTP_CODE_OK");
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
// Wifi Dies? Start Portal Again
if (WiFi.status() != WL_CONNECTED) {
if (!wc.autoConnect()) wc.startConfigurationPortal(AP_NONE);
}
delay (20000);
}
[/Codebox]
WifiManager preventing loop code from executing
-
PRO_GRAMMAR
- Posts: 5
- Joined: Sun Jan 15, 2023 7:20 pm
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- ESP32-S31
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- ESP32-S31 中文讨论版
- 喵伴 中文讨论版
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: Google [Bot] and 1 guest
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.
Information
Espressif ESP32 ... Available now!