From f4fe820944e7eb1732d1417a4c567b5092fc76db Mon Sep 17 00:00:00 2001 From: Elias Coppens Date: Wed, 12 Feb 2025 09:52:06 +0100 Subject: [PATCH] feat(ap): Separate 2.4G and 5G SSIDs and set correct channels --- machines/liminix/ap-v01/system.nix | 1 + machines/liminix/ap-v01/wlan.nix | 21 ++++++++++---- meta/nodes/liminix.nix | 46 ++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/machines/liminix/ap-v01/system.nix b/machines/liminix/ap-v01/system.nix index 3cc27b0..0d258b8 100644 --- a/machines/liminix/ap-v01/system.nix +++ b/machines/liminix/ap-v01/system.nix @@ -28,5 +28,6 @@ in defaultProfile.packages = with pkgs; [ zyxel-bootconfig min-collect-garbage + hostapd-radius ]; } diff --git a/machines/liminix/ap-v01/wlan.nix b/machines/liminix/ap-v01/wlan.nix index 1ac7ffa..4f1ff12 100644 --- a/machines/liminix/ap-v01/wlan.nix +++ b/machines/liminix/ap-v01/wlan.nix @@ -12,23 +12,32 @@ let svc = config.system.service; - inherit (nodeMeta.extraNodeSettings) building floor ap-no; + inherit (nodeMeta.extraNodeSettings) + building + floor + ap-no + real-ap-no + ; hex = x: lib.fixedWidthString 2 "0" (lib.toHexString x); mac-1 = "02:5B:6A:${hex (building * 4)}:${hex floor}:${hex ap-no}"; mac-2 = "02:5B:6A:${hex (building * 4 + 1)}:${hex floor}:${hex ap-no}"; + channel-1 = builtins.elemAt [ 1 6 11 ] (lib.mod (real-ap-no + floor) 3); + + channel-2 = builtins.elemAt [ 36 52 100 ] (lib.mod (real-ap-no + floor) 3); + secrets-1 = { ssid = "DGNum"; }; secrets-2 = { - ssid = "DGNum"; + ssid = "DGNum 5G"; }; baseParams = { country_code = "FR"; hw_mode = "g"; - channel = 6; + channel = channel-1; wmm_enabled = 1; ieee80211n = 1; ht_capab = "[LDPC][GF][HT40-][HT40+][SHORT-GI-40][MAX-AMSDU-7935][TX-STBC]"; @@ -56,9 +65,9 @@ let vht_capab = "[MAX-MPDU-7991][SU-BEAMFORMEE][SU-BEAMFORMER][RXLDPC][SHORT-GI-80][MAX-A-MPDU-LEN-EXP3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][TX-STBC-2BY1][RX-STBC-1][MU-BEAMFORMER]"; vht_oper_chwidth = 1; he_oper_chwidth = 1; - channel = 36; # TODO understand interferences - vht_oper_centr_freq_seg0_idx = 42; - he_oper_centr_freq_seg0_idx = 42; + channel = channel-2; # TODO understand interferences + vht_oper_centr_freq_seg0_idx = channel-2 + 6; + he_oper_centr_freq_seg0_idx = channel-2 + 6; require_vht = 1; }; diff --git a/meta/nodes/liminix.nix b/meta/nodes/liminix.nix index 8f654a2..c421af3 100644 --- a/meta/nodes/liminix.nix +++ b/meta/nodes/liminix.nix @@ -18,7 +18,7 @@ let nix-lib = import ../../lib/nix-lib; inherit (nix-lib) mapFuse; - mkAP' = building: floor: ap-no: { + mkAP' = permutations: building: floor: ap-no: { "ap-v01-${builtins.toString building}-${builtins.toString floor}-${builtins.toString ap-no}" = { site = "unknown"; adminGroups = [ "fai" ]; @@ -34,6 +34,7 @@ let extraNodeSettings = { inherit building floor ap-no; + real-ap-no = (builtins.elemAt (builtins.elemAt permutations floor) (ap-no - 1)) - 1; vendor-mac = null; }; }; @@ -55,8 +56,9 @@ let building-no, floors, ap-nos, + permutations, }: - mapFuse (f: mapFuse (mkAP' building-no f) (mkRange ap-nos)) (mkRange floors); + mapFuse (f: mapFuse (mkAP' permutations building-no f) (mkRange ap-nos)) (mkRange floors); APs = { hypnos-1 = { @@ -69,6 +71,32 @@ let from = 1; to = 7; }; + permutations = [ + [ + 1 + 2 + 3 + 5 + 6 + 4 + ] + [ + 1 + 2 + 6 + 3 + 5 + 4 + ] + [ + 1 + 2 + 5 + 3 + 6 + 4 + ] + ]; }; hypnos-2 = { @@ -81,6 +109,20 @@ let from = 1; to = 3; }; + permutations = [ + [ + 1 + 2 + ] + [ + 1 + 2 + ] + [ + 1 + 2 + ] + ]; }; };