increase AP limit, rename WIfi to NinjaCross for buttons and master
This commit is contained in:
Binary file not shown.
@@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = esp32dev
|
default_envs = esp32thing
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
platform = https://github.com/platformio/platform-espressif32.git
|
platform = https://github.com/platformio/platform-espressif32.git
|
||||||
@@ -32,12 +32,11 @@ lib_deps =
|
|||||||
miguelbalboa/MFRC522@^1.4.12
|
miguelbalboa/MFRC522@^1.4.12
|
||||||
adafruit/RTClib@^2.1.4
|
adafruit/RTClib@^2.1.4
|
||||||
|
|
||||||
|
|
||||||
[env:esp32thing_OTA]
|
[env:esp32thing_OTA]
|
||||||
board = esp32thing
|
board = esp32thing
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = 192.168.1.94
|
upload_port = 192.168.1.96
|
||||||
build_flags =
|
build_flags =
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-mfix-esp32-psram-cache-issue
|
-mfix-esp32-psram-cache-issue
|
||||||
@@ -54,28 +53,9 @@ lib_deps =
|
|||||||
miguelbalboa/MFRC522@^1.4.12
|
miguelbalboa/MFRC522@^1.4.12
|
||||||
adafruit/RTClib@^2.1.4
|
adafruit/RTClib@^2.1.4
|
||||||
|
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
board = esp32dev
|
|
||||||
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
|
|
||||||
esp32async/AsyncTCP@^3.4.2
|
|
||||||
mlesniew/PicoMQTT@^1.3.0
|
|
||||||
miguelbalboa/MFRC522@^1.4.12
|
|
||||||
adafruit/RTClib@^2.1.4
|
|
||||||
|
|
||||||
|
|
||||||
[env:esp32thing]
|
[env:esp32thing]
|
||||||
board = esp32thing
|
board = esp32thing_plus
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_port = COM12
|
|
||||||
build_flags =
|
build_flags =
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-mfix-esp32-psram-cache-issue
|
-mfix-esp32-psram-cache-issue
|
||||||
|
|||||||
@@ -18,22 +18,32 @@ String getUniqueSSID();
|
|||||||
bool isInternetAvailable();
|
bool isInternetAvailable();
|
||||||
void loopOTA();
|
void loopOTA();
|
||||||
void setupOTA();
|
void setupOTA();
|
||||||
|
void onWiFiAPClientConnected(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||||
|
|
||||||
// Initialisiert das WLAN als Access Point oder Station und startet mDNS/OTA.
|
// Initialisiert das WLAN als Access Point oder Station und startet mDNS/OTA.
|
||||||
void setupWifi() {
|
void setupWifi() {
|
||||||
|
|
||||||
|
IPAddress local_ip(192, 168, 10, 1);
|
||||||
|
IPAddress gateway(192, 168, 10, 1);
|
||||||
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
|
WiFi.softAPConfig(local_ip, gateway, subnet); // Set AP IP and DHCP range
|
||||||
|
|
||||||
uniqueSSID = getUniqueSSID();
|
uniqueSSID = getUniqueSSID();
|
||||||
ssidAP = uniqueSSID.c_str();
|
ssidAP = uniqueSSID.c_str();
|
||||||
if (ssidSTA == nullptr || passwordSTA == nullptr ||
|
if (ssidSTA == nullptr || passwordSTA == nullptr ||
|
||||||
String(ssidSTA).isEmpty() || String(passwordSTA).isEmpty()) {
|
String(ssidSTA).isEmpty() || String(passwordSTA).isEmpty()) {
|
||||||
Serial.println("Fehler: ssidSTA oder passwordSTA ist null!");
|
Serial.println("Fehler: ssidSTA oder passwordSTA ist null!");
|
||||||
WiFi.mode(WIFI_MODE_AP);
|
WiFi.mode(WIFI_MODE_AP);
|
||||||
WiFi.softAP(ssidAP, passwordAP);
|
WiFi.softAP(ssidAP, passwordAP, 1, 0, 8);
|
||||||
|
// Call this in setupWifi() after WiFi.softAP(...)
|
||||||
|
WiFi.onEvent(onWiFiAPClientConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_AP_STACONNECTED);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
WiFi.mode(WIFI_MODE_APSTA);
|
WiFi.mode(WIFI_MODE_APSTA);
|
||||||
WiFi.begin(ssidSTA, passwordSTA);
|
WiFi.begin(ssidSTA, passwordSTA);
|
||||||
WiFi.softAP(ssidAP, passwordAP);
|
WiFi.softAP(ssidAP, passwordAP, 1, 0, 8);
|
||||||
|
// Call this in setupWifi() after WiFi.softAP(...)
|
||||||
|
WiFi.onEvent(onWiFiAPClientConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_AP_STACONNECTED);
|
||||||
|
|
||||||
// Add timeout for WiFi connection
|
// Add timeout for WiFi connection
|
||||||
unsigned long startAttemptTime = millis();
|
unsigned long startAttemptTime = millis();
|
||||||
@@ -47,7 +57,7 @@ void setupWifi() {
|
|||||||
Serial.println("Fehler: Verbindung zum WLAN fehlgeschlagen!");
|
Serial.println("Fehler: Verbindung zum WLAN fehlgeschlagen!");
|
||||||
Serial.println("Starte Access Point...");
|
Serial.println("Starte Access Point...");
|
||||||
WiFi.mode(WIFI_MODE_AP);
|
WiFi.mode(WIFI_MODE_AP);
|
||||||
WiFi.softAP(ssidAP, passwordAP);
|
WiFi.softAP(ssidAP, passwordAP, 1, 0, 8);
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Erfolgreich mit WLAN verbunden!");
|
Serial.println("Erfolgreich mit WLAN verbunden!");
|
||||||
Serial.print("IP Adresse: ");
|
Serial.print("IP Adresse: ");
|
||||||
@@ -104,7 +114,7 @@ String getUniqueSSID() {
|
|||||||
char uniqueId[6];
|
char uniqueId[6];
|
||||||
snprintf(uniqueId, sizeof(uniqueId), "%02X%03X", mac[4], mac[5]);
|
snprintf(uniqueId, sizeof(uniqueId), "%02X%03X", mac[4], mac[5]);
|
||||||
|
|
||||||
return String("AquaCross-") + String(uniqueId);
|
return String("NinjaCross-") + String(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prüft, ob das Internet erreichbar ist (z.B. durch Ping auf 8.8.8.8)
|
// Prüft, ob das Internet erreichbar ist (z.B. durch Ping auf 8.8.8.8)
|
||||||
@@ -113,3 +123,14 @@ bool isInternetAvailable() {
|
|||||||
// Versuche, eine Verbindung zu Googles DNS auf Port 53 herzustellen
|
// Versuche, eine Verbindung zu Googles DNS auf Port 53 herzustellen
|
||||||
return client.connect("8.8.8.8", 53);
|
return client.connect("8.8.8.8", 53);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onWiFiAPClientConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
|
Serial.print("Client connected! MAC: ");
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
Serial.printf("%02X", info.wifi_ap_staconnected.mac[i]);
|
||||||
|
if (i < 5) Serial.print(":");
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user