Skip to main content
added 20 characters in body
Source Link

put your server declaraition outside the constructor and call a class callback :

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

// Function to create AccessPoint to get ssid and password
int Device::getWifiCredentials() {
server.begin();
    
    // define callbacks
    server.on("/", std::bind(&Device::handleRoot, this); // initial page

    server.on("/ssid", std::bind(&Device::handleCredentials, this); // catch response from initial page

    // wait for credentials to be delivered
    server.handleClient();

    while( WiFi.status() != WL_CONNECTED){
        Serial.print(".");
        delay(500);
    }

    return ACTION_SUCCESSFUL;
}

put your server declaraition outside the constructor and call a class callback :

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

// Function to create AccessPoint to get ssid and password
int Device::getWifiCredentials() {
server.begin();
    
    // define callbacks
    server.on("/", &Device::handleRoot, this); // initial page

    server.on("/ssid", &Device::handleCredentials, this); // catch response from initial page

    // wait for credentials to be delivered
    server.handleClient();

    while( WiFi.status() != WL_CONNECTED){
        Serial.print(".");
        delay(500);
    }

    return ACTION_SUCCESSFUL;
}

put your server declaraition outside the constructor and call a class callback :

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

// Function to create AccessPoint to get ssid and password
int Device::getWifiCredentials() {
server.begin();
    
    // define callbacks
    server.on("/", std::bind(&Device::handleRoot, this); // initial page

    server.on("/ssid", std::bind(&Device::handleCredentials, this); // catch response from initial page

    // wait for credentials to be delivered
    server.handleClient();

    while( WiFi.status() != WL_CONNECTED){
        Serial.print(".");
        delay(500);
    }

    return ACTION_SUCCESSFUL;
}
Source Link

put your server declaraition outside the constructor and call a class callback :

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

// Function to create AccessPoint to get ssid and password
int Device::getWifiCredentials() {
server.begin();
    
    // define callbacks
    server.on("/", &Device::handleRoot, this); // initial page

    server.on("/ssid", &Device::handleCredentials, this); // catch response from initial page

    // wait for credentials to be delivered
    server.handleClient();

    while( WiFi.status() != WL_CONNECTED){
        Serial.print(".");
        delay(500);
    }

    return ACTION_SUCCESSFUL;
}