这段代码试试看
#include <WiFiManager.h>
#include <ESP8266HTTPClient.h>
WiFiManager wiFiManager;
WiFiManagerParameter wiFiManagerParameter;
const char* ssid = "aaa";
const char* password = "12345678";
const char* custom_radio_str = "<br/><label for='customfieldid'>Custom Field Label</label><input type='radio' name='customfieldid' value='1' checked> One<br><input type='radio' name='customfieldid' value='2'> Two<br><input type='radio' name='customfieldid' value='3'> Three";
std::vector<const char *> menu = {"wifi","info","param","sep","restart","exit"};
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
Serial.setDebugOutput(true);
delay(3000);
new (&wiFiManagerParameter) WiFiManagerParameter(custom_radio_str);
wiFiManager.addParameter(&wiFiManagerParameter);
wiFiManager.setSaveParamsCallback(saveParamCallback);
wiFiManager.setMenu(menu);
wiFiManager.setClass("invert");
wiFiManager.setConfigPortalTimeout(120);
if(wiFiManager.autoConnect(ssid,password))
{
Serial.println("connected...yeey :");
}
else
{
Serial.println("Failed to connect or hit timeout");
}
randomSeed(micros());
}
void loop() {
while(WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
delay(3000);
}
//**************************显示参数
void saveParamCallback()
{
//Serial.println("[CALLBACK] saveParamCallback fired");
//Serial.println("PARAM customfieldid = " + getParam("customfieldid"));
}
#include <WiFiManager.h>
#include <ESP8266HTTPClient.h>
WiFiManager wiFiManager;
WiFiManagerParameter wiFiManagerParameter;
const char* ssid = "aaa";
const char* password = "12345678";
const char* custom_radio_str = "<br/><label for='customfieldid'>Custom Field Label</label><input type='radio' name='customfieldid' value='1' checked> One<br><input type='radio' name='customfieldid' value='2'> Two<br><input type='radio' name='customfieldid' value='3'> Three";
std::vector<const char *> menu = {"wifi","info","param","sep","restart","exit"};
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
Serial.setDebugOutput(true);
delay(3000);
new (&wiFiManagerParameter) WiFiManagerParameter(custom_radio_str);
wiFiManager.addParameter(&wiFiManagerParameter);
wiFiManager.setSaveParamsCallback(saveParamCallback);
wiFiManager.setMenu(menu);
wiFiManager.setClass("invert");
wiFiManager.setConfigPortalTimeout(120);
if(wiFiManager.autoConnect(ssid,password))
{
Serial.println("connected...yeey :");
}
else
{
Serial.println("Failed to connect or hit timeout");
}
randomSeed(micros());
}
void loop() {
while(WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
delay(3000);
}
//**************************显示参数
void saveParamCallback()
{
//Serial.println("[CALLBACK] saveParamCallback fired");
//Serial.println("PARAM customfieldid = " + getParam("customfieldid"));
}