Added ESP32thing, WIFI depending if STA is privided, check licence for WIfi open
This commit is contained in:
@@ -60,3 +60,22 @@ lib_deps =
|
|||||||
esp32async/AsyncTCP@^3.4.2
|
esp32async/AsyncTCP@^3.4.2
|
||||||
mlesniew/PicoMQTT@^1.3.0
|
mlesniew/PicoMQTT@^1.3.0
|
||||||
miguelbalboa/MFRC522@^1.4.12
|
miguelbalboa/MFRC522@^1.4.12
|
||||||
|
|
||||||
|
[env:esp32thing]
|
||||||
|
board = esp32thing
|
||||||
|
monitor_speed = 115200
|
||||||
|
build_flags =
|
||||||
|
-DBOARD_HAS_PSRAM
|
||||||
|
-mfix-esp32-psram-cache-issue
|
||||||
|
targets = uploadfs
|
||||||
|
board_build.psram = disabled
|
||||||
|
lib_deps =
|
||||||
|
bblanchon/ArduinoJson@^7.4.1
|
||||||
|
esp32async/ESPAsyncWebServer@^3.7.7
|
||||||
|
lostincompilation/PrettyOTA@^1.1.3
|
||||||
|
esp32async/AsyncTCP@^3.4.2
|
||||||
|
mlesniew/PicoMQTT@^1.3.0
|
||||||
|
miguelbalboa/MFRC522@^1.4.12
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -184,19 +184,12 @@ void saveWifiSettings() {
|
|||||||
preferences.putString("ssid", ssidSTA);
|
preferences.putString("ssid", ssidSTA);
|
||||||
preferences.putString("password", passwordSTA);
|
preferences.putString("password", passwordSTA);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
|
Serial.printf("WLAN-Einstellungen gespeichert: SSID=%s, Passwort=%s\n", ssidSTA, passwordSTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadWifiSettings() {
|
void loadWifiSettings() {
|
||||||
preferences.begin("wifi", true);
|
preferences.begin("wifi", true);
|
||||||
|
|
||||||
// Speicher freigeben, falls bereits zugewiesen
|
|
||||||
if (ssidSTA) {
|
|
||||||
free(ssidSTA);
|
|
||||||
}
|
|
||||||
if (passwordSTA) {
|
|
||||||
free(passwordSTA);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neue Werte laden und dynamisch zuweisen
|
// Neue Werte laden und dynamisch zuweisen
|
||||||
String ssid = preferences.getString("ssid", "");
|
String ssid = preferences.getString("ssid", "");
|
||||||
String password = preferences.getString("password", "");
|
String password = preferences.getString("password", "");
|
||||||
@@ -282,6 +275,7 @@ void setup() {
|
|||||||
loadButtonConfig();
|
loadButtonConfig();
|
||||||
loadBestTimes();
|
loadBestTimes();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
loadWifiSettings();
|
||||||
|
|
||||||
setupWifi(); // WiFi initialisieren
|
setupWifi(); // WiFi initialisieren
|
||||||
setupOTA(&server);
|
setupOTA(&server);
|
||||||
|
|||||||
@@ -5,6 +5,11 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
const char* ssidAP;
|
||||||
|
const char* passwordAP = nullptr;
|
||||||
|
|
||||||
|
char* ssidSTA = nullptr;
|
||||||
|
char* passwordSTA = nullptr;
|
||||||
|
|
||||||
// Timer Struktur
|
// Timer Struktur
|
||||||
struct TimerData {
|
struct TimerData {
|
||||||
@@ -61,6 +66,8 @@ void saveBestTimes();
|
|||||||
void loadBestTimes();
|
void loadBestTimes();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
void loadWifiSettings();
|
||||||
|
void saveWifiSettings();
|
||||||
void unlearnButton();
|
void unlearnButton();
|
||||||
int checkLicence();
|
int checkLicence();
|
||||||
String getTimerDataJSON();
|
String getTimerDataJSON();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
#define LED_PIN LED_BUILTIN
|
#define LED_PIN 13
|
||||||
|
|
||||||
|
|
||||||
// Status LED
|
// Status LED
|
||||||
|
|||||||
@@ -191,6 +191,8 @@ void setupRoutes(){
|
|||||||
ssidSTA = strdup(ssid.c_str());
|
ssidSTA = strdup(ssid.c_str());
|
||||||
passwordSTA = strdup(password.c_str());
|
passwordSTA = strdup(password.c_str());
|
||||||
|
|
||||||
|
saveWifiSettings();
|
||||||
|
|
||||||
// Rückmeldung
|
// Rückmeldung
|
||||||
DynamicJsonDocument doc(64);
|
DynamicJsonDocument doc(64);
|
||||||
doc["success"] = true;
|
doc["success"] = true;
|
||||||
|
|||||||
@@ -10,11 +10,6 @@
|
|||||||
#include "licenceing.h"
|
#include "licenceing.h"
|
||||||
|
|
||||||
String uniqueSSID;
|
String uniqueSSID;
|
||||||
const char* ssidAP;
|
|
||||||
const char* passwordAP = nullptr;
|
|
||||||
|
|
||||||
char* ssidSTA = strdup("Obiwlankenobi");
|
|
||||||
char* passwordSTA = strdup("Delfine1!");
|
|
||||||
|
|
||||||
PrettyOTA OTAUpdates;
|
PrettyOTA OTAUpdates;
|
||||||
|
|
||||||
@@ -24,15 +19,32 @@ void setupWifi() {
|
|||||||
|
|
||||||
uniqueSSID = getUniqueSSID();
|
uniqueSSID = getUniqueSSID();
|
||||||
ssidAP = uniqueSSID.c_str();
|
ssidAP = uniqueSSID.c_str();
|
||||||
|
//print station SSID
|
||||||
|
Serial.println("Access Point SSID: " + String(ssidSTA));
|
||||||
|
Serial.println("Access Point PW: " + String(passwordSTA));
|
||||||
|
|
||||||
WiFi.mode(WIFI_MODE_APSTA);
|
if ((ssidSTA == nullptr) || (passwordSTA == nullptr)) {
|
||||||
WiFi.softAP(ssidAP, passwordAP);
|
Serial.println("Fehler: ssidSTA oder passwordSTA ist null!");
|
||||||
WiFi.begin(ssidSTA, passwordSTA);
|
WiFi.mode(WIFI_MODE_AP);
|
||||||
|
WiFi.softAP(ssidAP, passwordAP);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
|
||||||
delay(500);
|
|
||||||
Serial.print(".");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
WiFi.mode(WIFI_MODE_APSTA);
|
||||||
|
WiFi.begin(ssidSTA, passwordSTA);
|
||||||
|
WiFi.softAP(ssidAP, passwordAP);
|
||||||
|
|
||||||
|
while (WiFi.status() != WL_CONNECTED){
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Only wait for connection if ssidSTA and passwordSTA are set
|
||||||
|
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
Serial.println("Verbunden mit WLAN!");
|
Serial.println("Verbunden mit WLAN!");
|
||||||
Serial.print("IP-Adresse: ");
|
Serial.print("IP-Adresse: ");
|
||||||
|
|||||||
Reference in New Issue
Block a user