|
@ -9,8 +9,10 @@ |
|
|
#include <WiFiMulti.h> |
|
|
#include <WiFiMulti.h> |
|
|
#include <ESPmDNS.h> |
|
|
#include <ESPmDNS.h> |
|
|
#include <WiFiClient.h> |
|
|
#include <WiFiClient.h> |
|
|
|
|
|
#include <Preferences.h> |
|
|
|
|
|
|
|
|
// ToDo: check if https://github.com/me-no-dev/ESPAsyncWebServer/ becomes available
|
|
|
// ToDo: check if https://github.com/me-no-dev/ESPAsyncWebServer/ becomes available
|
|
|
|
|
|
// libwebsockets got ESP32 support in v2.2 !
|
|
|
|
|
|
|
|
|
#include "hardware.h" |
|
|
#include "hardware.h" |
|
|
#include "sound.h" |
|
|
#include "sound.h" |
|
@ -62,6 +64,41 @@ void Wifi::init() { |
|
|
MDNS.addService("http", "tcp", 80); |
|
|
MDNS.addService("http", "tcp", 80); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Wifi::init_softap() { |
|
|
|
|
|
// WiFi wifi;
|
|
|
|
|
|
// wifi.softAP("soundboard");
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* never used */ /*
|
|
|
|
|
|
void Wifi::readPreferences() { |
|
|
|
|
|
Preferences preferences; |
|
|
|
|
|
preferences.begin("sb_wifi", false); // namespace limited to 15 chars!
|
|
|
|
|
|
for(uint8_t i=0; true; i++) { |
|
|
|
|
|
char key[8]; |
|
|
|
|
|
sprintf(key, "ssid%d", i); |
|
|
|
|
|
String ssid = preferences.getString(key); // max 31
|
|
|
|
|
|
sprintf(key, "pass%d", i); |
|
|
|
|
|
String password = preferences.getString(key); // max 63
|
|
|
|
|
|
} |
|
|
|
|
|
preferences.end(); |
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
size_t Wifi::getStoredPassword(const char* ssid, char* value) { |
|
|
|
|
|
Preferences preferences; |
|
|
|
|
|
preferences.begin("sb_wifi-pwd", false); |
|
|
|
|
|
size_t len = preferences.getString(ssid, value, 64); |
|
|
|
|
|
preferences.end(); |
|
|
|
|
|
return len; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
size_t Wifi::setStoredPassword(const char* ssid, char* value) { |
|
|
|
|
|
Preferences preferences; |
|
|
|
|
|
preferences.begin("sb_wifi-pwd", false); |
|
|
|
|
|
size_t len = preferences.putString(ssid, value); |
|
|
|
|
|
preferences.end(); |
|
|
|
|
|
return len; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void Wifi::loop() { |
|
|
void Wifi::loop() { |
|
|
// Check if a client has connected
|
|
|
// Check if a client has connected
|
|
|
WiFiClient client = server.available(); |
|
|
WiFiClient client = server.available(); |
|
|