Files
RouterOS/RouterOSAssistant/Core/Models/WifiNetworkConfig.swift
T
KayandClaude Sonnet 5 016f57f613 M5: WLAN-Schritt + echte set-Operation im Befehlsmodell
RouterOSCommand unterstützt jetzt neben .add auch .set (bestehenden
Eintrag ändern statt neuen anzulegen) — nötig, weil WLAN-Interfaces
schon vor jeder Konfiguration existieren. SSH löst das per CLI-eigenem
"set [find field=value] ..." inline auf; REST hat dafür keine
Entsprechung und muss den Eintrag erst per GET suchen (matchField/
matchValue), seine .id auslesen, dann PATCH auf restPath/<id> senden
(RestTransport.findItemID). Mit dem Nutzer abgestimmte Entscheidung
gegen die einfachere "WLAN nur über SSH"-Variante.

WifiNetworkConfig: pro erkanntem Legacy-Wireless-Interface
(/interface wireless, type=wlan) eine SSID/Passwort-Konfiguration,
Sicherheitsprofil (WPA2) wird zuerst angelegt, dann per set mit dem
Interface verknüpft. Geräte ohne WLAN zeigen einen Hinweistext statt
des Formulars (User-Anforderung: muss berücksichtigt werden). Geräte
mit dem neueren "wifi"-Treiber (type=wifi, wifiwave2/802.11ax) werden
erkannt, aber bewusst nicht unterstützt -- anderes Menü, eigener
Umbau nötig, dazu Hinweistext.

cliPath wurde in allen bisherigen Command-Buildern (Wan/Lan/Vlan) zu
menuPath + .add migriert, da RouterOSCommand jetzt operation-basiert
ist statt den Aktionswort im Pfad-String zu verstecken.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HReLXMbmPvtQ23p1iWiJNW
2026-09-12 13:41:25 +02:00

51 lines
2.0 KiB
Swift

import Foundation
/// SSID/password for one existing wireless radio (`/interface wireless`, the legacy RouterOS
/// wireless driver). Devices without any WLAN hardware simply have no entries.
///
/// Not supported: RouterOS' newer "wifi" package (`/interface wifi`, used on newer wifiwave2/
/// 802.11ax hardware) — different menu structure entirely. Detecting and handling that is left
/// for a later milestone; the Setup step explains this to the user when it sees `wifi`-typed
/// interfaces instead of `wlan`-typed ones.
struct WifiNetworkConfig: Identifiable, Equatable {
var id: String { interfaceName }
var interfaceName: String
var enabled: Bool = false
var ssid: String = ""
var password: String = ""
private var securityProfileName: String { "sec_\(interfaceName)" }
/// The wireless interface already exists out of the box — this only ever `set`s it plus
/// `add`s a security profile, never creates a new wireless interface.
func buildCommands() -> [RouterOSCommand] {
guard enabled else { return [] }
return [
RouterOSCommand.add(
menuPath: "/interface wireless security-profiles",
restPath: "interface/wireless/security-profiles",
arguments: [
"name": securityProfileName,
"mode": "dynamic-keys",
"authentication-types": "wpa2-psk",
"wpa2-pre-shared-key": password
],
summary: "WLAN-Sicherheitsprofil für \"\(ssid)\" anlegen (WPA2)"
),
RouterOSCommand.set(
menuPath: "/interface wireless",
restPath: "interface/wireless",
matchField: "name",
matchValue: interfaceName,
arguments: [
"ssid": ssid,
"security-profile": securityProfileName,
"disabled": "no"
],
summary: "WLAN \"\(ssid)\" auf \(interfaceName) aktivieren"
)
]
}
}