Set and flashing default credentials #348
Answered
by
Hieromon
SmartVolt
asked this question in
How can I?
-
Hi, and thank you for this great project!
|
Beta Was this translation helpful? Give feedback.
Answered by
Hieromon
Apr 6, 2021
Replies: 1 comment
-
You can use the AutoConnect::onDetect function to see if the access point started because AutoConnect::begin with the default credentials failed. #include <Arduino.h>
#include <WiFi.h> // For ESP8266, needs to change to ESP8266WiFi.h
#include <WebServer.h> // For ESP8266, needs to change to ESP8266WebServer.h
#include <AutoConnect.h>
const char* initialSsid = "yourNetworkName";
const char* initialPassword = "yourNetworkPass";
AutoConnect portal;
// Callback function at an AP start
bool startAP(IPAddress& ip) {
Serial.println("Setting Access Point Mode because initial credential is wrong..");
Serial.println("AP started, IP:" + ip.toString());
return true;
}
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
portal.onDetect(startAP); // When the AP start is detected, the startCP function is executed.
portal.begin(initialSsid, initialPassword); // Specify the default SSID and password. If the default value does not match the AP you wish, the access point will start.
}
void loop() {
portal.handleClient();
} NOTE: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Hieromon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the AutoConnect::onDetect function to see if the access point started because AutoConnect::begin with the default credentials failed.
More information for the onDetect API can be found in Captive portal start detection section of the documentation.