From 3ae73a9728dea7bd6bec55f5a2424b08ab36677f Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 8 Nov 2025 09:49:59 +0100 Subject: [PATCH] Add getModeCapabilities(), validate channel widths for 802.11ax/be --- .../Networking/Hotspot/HostapdManager.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/RaspAP/Networking/Hotspot/HostapdManager.php b/src/RaspAP/Networking/Hotspot/HostapdManager.php index c9d0a5ef..0bcbbcb4 100644 --- a/src/RaspAP/Networking/Hotspot/HostapdManager.php +++ b/src/RaspAP/Networking/Hotspot/HostapdManager.php @@ -102,6 +102,12 @@ class HostapdManager if (!empty($config['ieee80211ac']) && strval($config['ieee80211ac']) === '1') { $selected = 'ac'; } + if (!empty($config['ieee80211ax']) && strval($config['ieee80211ax']) === '1') { + $selected = 'ax'; + } + if (!empty($config['ieee80211be']) && strval($config['ieee80211be']) === '1') { + $selected = 'be'; + } if (!empty($config['ieee80211w']) && strval($config['ieee80211w']) === '2') { $selected = 'w'; } @@ -189,10 +195,24 @@ class HostapdManager $vht_freq_idx = ($params['channel'] < RASPI_5GHZ_CHANNEL_MIN) ? 42 : 155; $hwMode = isset($params['hw_mode']) ? $params['hw_mode'] : ''; + // validate channel width for 802.11ax/be + if (in_array($hwMode, ['ax', 'be'])) { + // for 6GHz band (channels 1-233) wider bandwidths are available + $is6GHz = ($params['channel'] >= 1 && $params['channel'] <= 233); + + // for 802.11be, 320 MHz only available on 6GHz + if ($hwMode === 'be' && !$is6GHz && isset($params['eht_oper_chwidth']) && $params['eht_oper_chwidth'] == 4) { + // reset to 160 MHz if 320 MHz requested on non-6GHz + $params['eht_oper_chwidth'] = 2; + } + } + // fetch settings for selected mode $modeSettings = getDefaultNetOpts('hostapd', 'modes', $hwMode); $settings = $modeSettings[$hwMode]['settings'] ?? []; + error_log("HostapdManager::buildConfig() -> settings\n" . var_export($settings, true)); + if (!empty($settings)) { foreach ($settings as $line) { if (!is_string($line)) { @@ -457,5 +477,26 @@ class HostapdManager return is_array($configs) ? count($configs) : 0; } + /** + * Gets capabilities for a given IEEE 802.11 mode + * + * @param string $mode + * @return array + */ + public function getModeCapabilities(string $mode): array + { + $capabilities = [ + 'a' => ['bands' => ['5'], 'max_width' => 20], + 'b' => ['bands' => ['2.4'], 'max_width' => 22], + 'g' => ['bands' => ['2.4'], 'max_width' => 20], + 'n' => ['bands' => ['2.4', '5'], 'max_width' => 40], + 'ac' => ['bands' => ['5'], 'max_width' => 160], + 'ax' => ['bands' => ['2.4', '5', '6'], 'max_width' => 160], + 'be' => ['bands' => ['2.4', '5', '6'], 'max_width' => 320] + ]; + + return $capabilities[$mode] ?? $capabilities['g']; + } + }