From 711dbc17f270e6933b85c6e9f6361ec4d3c03b9b Mon Sep 17 00:00:00 2001 From: Conrad Lara - KG6JEI Date: Mon, 14 Jul 2014 20:40:49 -0700 Subject: [PATCH] Add a channel bandwidth selector to the setup screen. Required for 900mhz devices to be supported due to band size. This can also be useful for allowing more devices to fit into the same amount of RF space as nodes may often not need full 20mhz wide channels. 2.4ghz while using standard BBHN SSID is restricted to 20mhz for compatibility. ref BBHN->ticket:50 --- files/etc/config.ap/_setup | 1 + files/etc/config.ap/_setup.default | 1 + files/etc/config.ap/wireless | 1 + files/etc/config.mesh/_setup | 1 + files/etc/config.mesh/_setup.default | 1 + files/etc/config.mesh/wireless | 1 + files/etc/config.mesh_ap/_setup | 1 + files/etc/config.mesh_ap/_setup.default | 1 + files/etc/config.mesh_ap/wireless | 1 + files/etc/config.router/wireless | 1 + files/www/cgi-bin/channelmaps.pm | 19 +++++++++++++++++++ files/www/cgi-bin/setup | 15 +++++++++++++++ 12 files changed, 44 insertions(+) diff --git a/files/etc/config.ap/_setup b/files/etc/config.ap/_setup index 46b3eb3f..14ac2324 100644 --- a/files/etc/config.ap/_setup +++ b/files/etc/config.ap/_setup @@ -3,6 +3,7 @@ wifi_mode = ap wifi_ssid = wifi_txpower = 19 wifi_channel = 6 +wifi_chanbw = 20 wifi_distance = 0 wifi_hidden = 0 diff --git a/files/etc/config.ap/_setup.default b/files/etc/config.ap/_setup.default index 46b3eb3f..14ac2324 100644 --- a/files/etc/config.ap/_setup.default +++ b/files/etc/config.ap/_setup.default @@ -3,6 +3,7 @@ wifi_mode = ap wifi_ssid = wifi_txpower = 19 wifi_channel = 6 +wifi_chanbw = 20 wifi_distance = 0 wifi_hidden = 0 diff --git a/files/etc/config.ap/wireless b/files/etc/config.ap/wireless index 853802b6..ae29939f 100644 --- a/files/etc/config.ap/wireless +++ b/files/etc/config.ap/wireless @@ -2,6 +2,7 @@ config wifi-device radio0 option type mac80211 option phy phy0 option channel + option chanbw option distance config wifi-iface diff --git a/files/etc/config.mesh/_setup b/files/etc/config.mesh/_setup index b2151d78..d098c8c3 100644 --- a/files/etc/config.mesh/_setup +++ b/files/etc/config.mesh/_setup @@ -5,6 +5,7 @@ wifi_ssid = BroadbandHamnet-v2 wifi_mode = adhoc wifi_txpower = 19 wifi_channel = 1 +wifi_chanbw = 20 wifi_distance = 0 wifi_country = 00 diff --git a/files/etc/config.mesh/_setup.default b/files/etc/config.mesh/_setup.default index 49cf423b..260ed687 100644 --- a/files/etc/config.mesh/_setup.default +++ b/files/etc/config.mesh/_setup.default @@ -5,6 +5,7 @@ wifi_ssid = BroadbandHamnet-v2 wifi_mode = adhoc wifi_txpower = 19 wifi_channel = 1 +wifi_chanbw = 20 wifi_distance = 0 wifi_country = 00 diff --git a/files/etc/config.mesh/wireless b/files/etc/config.mesh/wireless index 06125f20..91945f7f 100644 --- a/files/etc/config.mesh/wireless +++ b/files/etc/config.mesh/wireless @@ -2,6 +2,7 @@ config wifi-device radio0 option type mac80211 option phy phy0 option channel + option chanbw option distance option country diff --git a/files/etc/config.mesh_ap/_setup b/files/etc/config.mesh_ap/_setup index 10aa592c..ed461bc9 100644 --- a/files/etc/config.mesh_ap/_setup +++ b/files/etc/config.mesh_ap/_setup @@ -3,6 +3,7 @@ wifi_mode = ap wifi_ssid = wifi_txpower = 19 wifi_channel = 6 +wifi_chanbw = 20 wifi_distance = 0 wifi_hidden = 0 diff --git a/files/etc/config.mesh_ap/_setup.default b/files/etc/config.mesh_ap/_setup.default index 10aa592c..ed461bc9 100644 --- a/files/etc/config.mesh_ap/_setup.default +++ b/files/etc/config.mesh_ap/_setup.default @@ -3,6 +3,7 @@ wifi_mode = ap wifi_ssid = wifi_txpower = 19 wifi_channel = 6 +wifi_chanbw = 20 wifi_distance = 0 wifi_hidden = 0 diff --git a/files/etc/config.mesh_ap/wireless b/files/etc/config.mesh_ap/wireless index 853802b6..ae29939f 100644 --- a/files/etc/config.mesh_ap/wireless +++ b/files/etc/config.mesh_ap/wireless @@ -2,6 +2,7 @@ config wifi-device radio0 option type mac80211 option phy phy0 option channel + option chanbw option distance config wifi-iface diff --git a/files/etc/config.router/wireless b/files/etc/config.router/wireless index bb43b0be..d64e39f7 100644 --- a/files/etc/config.router/wireless +++ b/files/etc/config.router/wireless @@ -2,6 +2,7 @@ config wifi-device radio0 option type mac80211 option phy phy0 option channel + option chanbw option disabled 1 config wifi-iface diff --git a/files/www/cgi-bin/channelmaps.pm b/files/www/cgi-bin/channelmaps.pm index 9d568d7e..72c6dff0 100644 --- a/files/www/cgi-bin/channelmaps.pm +++ b/files/www/cgi-bin/channelmaps.pm @@ -139,6 +139,25 @@ sub rf_channels_list } } +sub is_wifi_chanbw_valid +{ + my ($wifi_chanbw,$wifi_ssid) = @_; + my $boardinfo=hardware_info(); + if ( ( exists($boardinfo->{'rfband'}) ) && ( $boardinfo->{'rfband'} == "2400" ) && ( $wifi_chanbw != 20 ) ) + { + if ( (( length $wifi_ssid >= 33 ) || ( length $wifi_ssid == 0 )) || ( $wifi_ssid =~ /BroadBandHamnet-v.*/i )) + { + # 2.4ghz and default ssid not 20mhz wide -- Invalid chan_bw + return 0; + } else { + # chan_bw valid + return 1; + } + } + # Not 2.4ghz or device is unknown, trust the user submission. + return 1; +} + #weird uhttpd/busybox error requires a 1 at the end of this file 1 diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index c4799ad4..5065a8b3 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -179,6 +179,12 @@ if($parms{button_save}) push (@errors, "invalid WiFi channel") } + if ( !is_wifi_chanbw_valid($wifi_chanbw,$wifi_ssid) ) + { + push (@errors, "Invalid WiFi channel width"); + $wifi_chanbw = 20; + } + push (@errors, "invalid WiFi distance") if $wifi_distance < 0 or $wifi_distance =~ /\D/; $wifi_country_validated=0; @@ -523,6 +529,15 @@ if($wifi_proto ne "disabled") push @hidden, ""; } + { + print "Channel Width\n"; + print "\n"; + } + if ($config ne "mesh") { print "Country\n";