|
4 | 4 | MiniWebRadio -- Webradio receiver for ESP32
|
5 | 5 |
|
6 | 6 | first release on 03/2017 */String Version ="\
|
7 |
| - Version 3.5.1 - Nov 18/2024 "; |
| 7 | + Version 3.5.1a - Nov 21/2024 "; |
8 | 8 |
|
9 | 9 | /* 2.8" color display (320x240px) with controller ILI9341 or HX8347D (SPI) or
|
10 | 10 | 3.5" color display (480x320px) with controller ILI9486 or ILI9488 (SPI)
|
@@ -1164,6 +1164,14 @@ bool connectToWiFi() {
|
1164 | 1164 | uint16_t idx = 0;
|
1165 | 1165 | wifiMulti.addAP(_SSID, _PW); // SSID and PW in code
|
1166 | 1166 | SerialPrintfln("WiFI_info: add SSID: " ANSI_ESC_CYAN "%s", _SSID);
|
| 1167 | + |
| 1168 | + if(pref.isKey("ap_ssid") && pref.isKey("ap_pw")) { // exists? |
| 1169 | + String ap_ssid = pref.getString("ap_ssid", ""); // credentials from accesspoint |
| 1170 | + String ap_pw = pref.getString("ap_pw", ""); |
| 1171 | + if(ap_ssid.length() > 0 && ap_pw.length() > 0) wifiMulti.addAP(ap_ssid.c_str(), ap_pw.c_str()); |
| 1172 | + SerialPrintfln("WiFI_info: add SSID: " ANSI_ESC_CYAN "%s", ap_ssid.c_str()); |
| 1173 | + } |
| 1174 | + |
1167 | 1175 | File file = SD_MMC.open("/networks.csv"); // try credentials given in "/networks.txt"
|
1168 | 1176 | if(file) { // try to read from SD_MMC
|
1169 | 1177 | while(file.available()) {
|
@@ -1430,6 +1438,9 @@ void setup() {
|
1430 | 1438 |
|
1431 | 1439 | if(TFT_CONTROLLER < 2) strcpy(_prefix, "/s");
|
1432 | 1440 | else strcpy(_prefix, "/m");
|
| 1441 | + |
| 1442 | + pref.begin("Pref", false); // instance of preferences from AccessPoint (SSID, PW ...) |
| 1443 | + |
1433 | 1444 | #if CONFIG_IDF_TARGET_ESP32
|
1434 | 1445 | tft.begin(TFT_CS, TFT_DC, VSPI, TFT_MOSI, TFT_MISO, TFT_SCK); // Init TFT interface ESP32
|
1435 | 1446 | #else
|
@@ -3390,6 +3401,15 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
|
3390 | 3401 |
|
3391 | 3402 | if(cmd == "AP_ready"){ webSrv.send("networks=", _scannedNetworks); return;} // via websocket
|
3392 | 3403 |
|
| 3404 | + if(cmd == "credentials"){ String AP_SSID = param.substring(0, param.indexOf("\n")); // via websocket |
| 3405 | + String AP_PW = param.substring(param.indexOf("\n") + 1); |
| 3406 | + SerialPrintfln("credentials: SSID " ANSI_ESC_BLUE "%s" ANSI_ESC_WHITE ", PW " ANSI_ESC_BLUE "%s", |
| 3407 | + AP_SSID.c_str(), AP_PW.c_str()); |
| 3408 | + pref.putString("ap_ssid", AP_SSID); |
| 3409 | + pref.putString("ap_pw", AP_PW); |
| 3410 | + ESP.restart();} |
| 3411 | + |
| 3412 | + |
3393 | 3413 | if(cmd.startsWith("SD/")){ String str = cmd.substring(2); // via XMLHttpRequest
|
3394 | 3414 | if(!webSrv.streamfile(SD_MMC, scaleImage(str.c_str()))){
|
3395 | 3415 | SerialPrintfln("webSrv: ... " ANSI_ESC_YELLOW "File not found " ANSI_ESC_RED "\"%s\"", str.c_str());
|
|
0 commit comments