-
-
Save kasperkamperman/7de1a5dd579fcc8823786d2eb70887c0 to your computer and use it in GitHub Desktop.
in one file
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
#include "application.h" | |
SYSTEM_THREAD(ENABLED); | |
class WiFiManager { | |
public: | |
WiFiManager(); | |
virtual ~WiFiManager(); | |
void setup(); | |
void loop(); | |
static void handle_ap(WiFiAccessPoint* wap, WiFiManager* self); | |
void next(WiFiAccessPoint& ap); | |
}; | |
WiFiManager::WiFiManager() { | |
} | |
WiFiManager::~WiFiManager() { | |
}// | |
void WiFiManager::setup() { | |
//Serial.println("hi"); | |
} | |
void WiFiManager::loop() { | |
//delay(1000); | |
WiFi.scan(handle_ap, this); | |
//bool check = isStoredSSIDAvailable(); | |
//if(check) Serial.println("checked"); | |
delay(1000); | |
} | |
// This is the callback passed to WiFi.scan() | |
// It makes the call on the `self` instance - to go from a static | |
// member function to an instance member function. | |
void WiFiManager::handle_ap(WiFiAccessPoint* wap, WiFiManager* self) | |
{ | |
self->next(*wap); | |
} | |
void WiFiManager::next(WiFiAccessPoint& ap) | |
{ | |
Serial.print("SSID: "); | |
Serial.println(ap.ssid); | |
} | |
WiFiManager wifiManager; | |
void setup() { | |
Serial.begin(57600); | |
wifiManager.setup(); | |
// adding a delay to the end of setup solves the crash. | |
delay(800); | |
} | |
void loop() { | |
wifiManager.loop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment