feat(wifi): scan, connect and persist networks from the settings app
Adds a wifi binding over the Arduino API and a settings flow that scans, picks the strongest AP per SSID, takes a password from an on-screen keyboard, and reports connection state. Credentials join /settings.lua and reconnect at boot. Settings are now written through a temp file and rename, and strings are Lua-escaped, so a password cannot corrupt the file the firmware parses at boot.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
#include <TFT_eSPI.h>
|
||||
#include <WiFi.h>
|
||||
#include <XPT2046_Touchscreen.h>
|
||||
|
||||
#include "lua/lua_app.h"
|
||||
@@ -58,6 +59,11 @@ void setup() {
|
||||
return;
|
||||
}
|
||||
settings.load(); // absent file keeps the built-in defaults
|
||||
WiFi.persistent(false);
|
||||
if (settings.wifiSsid.length()) {
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(settings.wifiSsid.c_str(), settings.wifiPassword.c_str());
|
||||
}
|
||||
startApp(LAUNCHER);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user