feat: WLAN-Treiber mit Onboarding-AP, Build-Credentials und Befehl net

This commit is contained in:
Michael Sauer
2026-09-11 22:50:43 +02:00
parent 2f7cadaeee
commit 4c2f9e5374
12 changed files with 361 additions and 4 deletions
+26
View File
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <string.h>
#include "wm_include.h"
#include "wm_watchdog.h"
@@ -13,6 +14,8 @@
#include "light/nl_boot_state.h"
#include "light/nl_control.h"
#include "light/nl_engine.h"
#include "net/nl_mdns.h"
#include "net/nl_wifi.h"
#include "sys/nl_app.h"
#include "sys/nl_console.h"
@@ -79,6 +82,17 @@ void nl_app_reboot(void)
void nl_app_request_factory_reset(void) { s_factory_reset_requested = true; }
int nl_app_set_wifi_credentials(const char *ssid, const char *pass)
{
nl_app_lock();
strncpy(s_settings.wifi_ssid, ssid, NL_SSID_LEN - 1);
s_settings.wifi_ssid[NL_SSID_LEN - 1] = '\0';
strncpy(s_settings.wifi_pass, pass, NL_PASS_LEN - 1);
s_settings.wifi_pass[NL_PASS_LEN - 1] = '\0';
nl_app_unlock();
return nl_app_save_settings();
}
void nl_app_factory_reset(void)
{
printf("factory reset\r\n");
@@ -160,6 +174,18 @@ static void app_task(void *arg)
tls_watchdog_init(20u * 1000u * 1000u); /* 20 s */
nl_console_start();
{
static nl_settings_t boot; /* copy: the network task may change s_settings later */
nl_app_lock();
boot = s_settings;
nl_app_unlock();
nl_mdns_set_name(boot.name);
if (boot.wifi_ssid[0])
nl_wifi_start(boot.wifi_ssid, boot.wifi_pass, NINLIGHT_AP_PASSWORD);
else
nl_wifi_start(NINLIGHT_WIFI_SSID, NINLIGHT_WIFI_PASSWORD, NINLIGHT_AP_PASSWORD);
}
boot_ms = nl_app_now_ms();
beat_seen = s_light_beat;
for (;;) {