diff --git a/displayprodLinux/Network.share.xml b/displayprodLinux/Network.share.xml
index 64d63f9..31a0e2c 100644
--- a/displayprodLinux/Network.share.xml
+++ b/displayprodLinux/Network.share.xml
@@ -22,6 +22,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -184,6 +197,24 @@
ParameterType="%AID%_PT-IpOctet" Text="WLAN DNS 4. Oktett" Value="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -231,6 +262,10 @@
+
+
+
+
@@ -285,6 +320,10 @@
+
+
+
+
diff --git a/main/NetworkConfig.cpp b/main/NetworkConfig.cpp
index e2d258e..e6972b2 100644
--- a/main/NetworkConfig.cpp
+++ b/main/NetworkConfig.cpp
@@ -3,6 +3,7 @@
#include "Wifi.hpp"
#include "knx_facade.h"
#include "esp_log.h"
+#include
static const char* TAG = "NetworkConfig";
@@ -32,6 +33,13 @@ static constexpr uint16_t NW_WLAN_SUBNET = NW_PARAM_BASE + 21;
static constexpr uint16_t NW_WLAN_GATEWAY = NW_PARAM_BASE + 25;
static constexpr uint16_t NW_WLAN_DNS = NW_PARAM_BASE + 29;
+// WLAN credentials: bytes 33-129
+static constexpr uint16_t NW_WLAN_WPA = NW_PARAM_BASE + 33;
+static constexpr uint16_t NW_WLAN_SSID = NW_PARAM_BASE + 34;
+static constexpr uint16_t NW_WLAN_PASS = NW_PARAM_BASE + 66;
+static constexpr uint16_t NW_WLAN_SSID_LEN = 32;
+static constexpr uint16_t NW_WLAN_PASS_LEN = 64;
+
extern KnxFacade knx;
static void readIpOctets(uint16_t offset, uint8_t out[4]) {
@@ -40,6 +48,25 @@ static void readIpOctets(uint16_t offset, uint8_t out[4]) {
}
}
+static std::string readParamString(uint16_t offset, uint16_t maxLen) {
+ char buf[128] = {};
+ uint16_t len = (maxLen < sizeof(buf) - 1) ? maxLen : sizeof(buf) - 1;
+ for (uint16_t i = 0; i < len; i++) {
+ buf[i] = (char)knx.paramByte(offset + i);
+ if (buf[i] == '\0') break;
+ }
+ buf[len] = '\0';
+ return std::string(buf);
+}
+
+static wifi_auth_mode_t wpaVersionToAuthMode(uint8_t wpaVersion) {
+ switch (wpaVersion) {
+ case 1: return WIFI_AUTH_WPA3_PSK;
+ case 2: return WIFI_AUTH_WPA2_WPA3_PSK;
+ default: return WIFI_AUTH_WPA2_PSK;
+ }
+}
+
void NetworkConfig::applyFromKnx() {
if (!knx.configured()) {
ESP_LOGW(TAG, "KNX not configured, using default network settings");
@@ -92,5 +119,18 @@ void NetworkConfig::applyFromKnx() {
Wifi::instance().applyStaticIp(cfg);
}
+
+ // Read WLAN credentials from KNX parameters
+ std::string ssid = readParamString(NW_WLAN_SSID, NW_WLAN_SSID_LEN);
+ std::string password = readParamString(NW_WLAN_PASS, NW_WLAN_PASS_LEN);
+ uint8_t wpaVersion = knx.paramByte(NW_WLAN_WPA);
+ wifi_auth_mode_t authMode = wpaVersionToAuthMode(wpaVersion);
+
+ if (!ssid.empty()) {
+ ESP_LOGI(TAG, "WLAN connecting to SSID: %s (WPA=%d)", ssid.c_str(), wpaVersion);
+ Wifi::instance().connect(ssid.c_str(), password.c_str(), authMode);
+ } else {
+ ESP_LOGW(TAG, "WLAN enabled but no SSID configured");
+ }
}
}
diff --git a/main/Wifi.cpp b/main/Wifi.cpp
index 7894505..3c6069a 100644
--- a/main/Wifi.cpp
+++ b/main/Wifi.cpp
@@ -137,17 +137,17 @@ void Wifi::scan(std::function&)> callback) {
}, "wifi_scan", 4096, nullptr, 5, nullptr);
}
-void Wifi::connect(const char* ssid, const char* password) {
- ESP_LOGI(TAG, "Connecting to %s", ssid);
+void Wifi::connect(const char* ssid, const char* password, wifi_auth_mode_t authMode) {
+ ESP_LOGI(TAG, "Connecting to %s (auth=%d)", ssid, authMode);
xEventGroupClearBits(wifiEventGroup_, WIFI_CONNECTED_BIT | WIFI_FAIL_BIT);
wifi_config_t wifi_config = {};
strncpy((char*)wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid) - 1);
strncpy((char*)wifi_config.sta.password, password, sizeof(wifi_config.sta.password) - 1);
- wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
+ wifi_config.sta.threshold.authmode = authMode;
wifi_config.sta.pmf_cfg.capable = true;
- wifi_config.sta.pmf_cfg.required = false;
+ wifi_config.sta.pmf_cfg.required = (authMode == WIFI_AUTH_WPA3_PSK);
currentSSID_ = ssid;
diff --git a/main/Wifi.hpp b/main/Wifi.hpp
index 926050f..7b21722 100644
--- a/main/Wifi.hpp
+++ b/main/Wifi.hpp
@@ -18,7 +18,7 @@ public:
void init();
void applyStaticIp(const StaticIpConfig& cfg);
void scan(std::function&)> callback);
- void connect(const char* ssid, const char* password);
+ void connect(const char* ssid, const char* password, wifi_auth_mode_t authMode = WIFI_AUTH_WPA2_PSK);
void disconnect();
bool isConnected();
std::string getCurrentSSID();