diff --git a/files/etc/config/wireless b/files/etc/config/wireless index 11effbb0..128d4516 100644 --- a/files/etc/config/wireless +++ b/files/etc/config/wireless @@ -1,7 +1,6 @@ config wifi-device radio0 option type mac80211 option phy phy0 - option channel 1 option distance 0 config wifi-iface diff --git a/files/etc/uci-defaults/setwifichannel b/files/etc/uci-defaults/setwifichannel new file mode 100755 index 00000000..a5d3237b --- /dev/null +++ b/files/etc/uci-defaults/setwifichannel @@ -0,0 +1,4 @@ +#!/bin/sh + +uci set wireless.radio0.channel=`perl -I/www/cgi-bin -e 'use channelmaps; $channels = rf_channels_list(); foreach $channelnumber (sort {$a <=> $b} keys %{$channels} ) { print $channelnumber; exit 0;}'` +uci -q commit diff --git a/files/www/cgi-bin/channelmaps.pm b/files/www/cgi-bin/channelmaps.pm new file mode 100644 index 00000000..697c5410 --- /dev/null +++ b/files/www/cgi-bin/channelmaps.pm @@ -0,0 +1,139 @@ + +use perlfunc; + +############################# + +# +# @returns all channels, or specific band lis +sub rf_channel_map +{ + %channellist = ( + '2400' => { + 1 => "1 (2412)", + 2 => "2 (2417)", + 3 => "3 (2422)", + 4 => "4 (2427)", + 5 => "5 (2432)", + 6 => "6 (2437)", + 7 => "7 (2442)", + 8 => "8 (2447)", + 9 => "9 (2452)", + 10 => "10 (2457)", + 11 => "11 (2462)", + }, + '5500' => { + 37 => "36 (5190)", + 40 => "40 (5200)", + 44 => "44 (5220)", + 48 => "48 (5240)", + 52 => "52 (5260)", + 56 => "56 (5280)", + 60 => "60 (5300)", + 64 => "64 (5320)", + 100 => "100 (5500)", + 104 => "104 (5520)", + 108 => "108 (5540)", + 112 => "112 (5560)", + 116 => "116 (5580)", + 120 => "120 (5600)", + 124 => "124 (5620)", + 128 => "128 (5640)", + 132 => "132 (5660)", + 136 => "136 (5680)", + 140 => "140 (5700)", + 149 => "149 (5745)", + 153 => "153 (5765)", + 157 => "157 (5785)", + 161 => "161 (5805)", + 165 => "165 (5825)", + }, + # 5800 UBNT US Band + # Limiting to US speced channels until the hardware can be tested + # lower into the spectrum. + '5800ubntus' => { + 149 => "149 (5745)", + 153 => "153 (5765)", + 157 => "157 (5785)", + 161 => "161 (5805)", + 165 => "165 (5825)", + }, + ); + + my($reqband) = @_; + + if ( defined($reqband) ){ + if ( exists($channellist{$reqband}) ){ + return $channellist{$reqband}; + } + else + { + return -1; + } + } + else { + return $channellist; + } +} + +sub is_channel_valid +{ + my ($channel) = @_; + + if ( !defined($channel) ) { + return -1; + } + + $boardinfo=hardware_info(); + #We know about the band so lets use it + if ( exists($boardinfo->{'rfband'})) + { + $validchannels=rf_channel_map($boardinfo->{'rfband'}); + + if ( exists($validchannels->{$channel}) ) + { + return 1; + } else { + return 0; + } + } + # We don't have the device band in the data file so lets fall back to checking manually + else { + my $channelok=0; + foreach (`iwlist wlan0 channel`) + { + next unless /Channel $channel/; + $channelok=1; + } + return $channelok; + } + +} + + +sub rf_channels_list +{ + + $boardinfo=hardware_info(); + #We know about the band so lets use it + if ( exists($boardinfo->{'rfband'})) + { + if (rf_channel_map($boardinfo->{'rfband'}) != -1 ) + { + return rf_channel_map($boardinfo->{'rfband'}); + } + } + else + { + my %channels = (); + foreach (`iwlist wlan0 channel` ) + { + next unless /([0-9]+) : ([0-9]+.[0-9]+)/; + $channels->{$1} = "$2 GHZ" ; + } + return $channels; + } +} + +#weird uhttpd/busybox error requires a 1 at the end of this file +1 + diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index 44a51f79..5f3332e5 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -913,6 +913,17 @@ sub hardware_info 'defaultant' => 3, 'usechains' => 1, }, + '0xe1b5' => { + 'name' => 'Rocket M5', + 'comment' => 'Rocket M5 in testing', + 'supported' => '-2', + 'maxpower' => '22', + 'pwroffset' => '5', + 'antennas' => { 1 => "Chain0", 2 => "Chain1", 3 => "Diversity"}, + 'defaultant' => 3, + 'usechains' => 1, + 'rfband' => '5800ubntus', + }, '0xe202' => { 'name' => 'Bullet M2 HP', 'comment' => '', @@ -923,6 +934,28 @@ sub hardware_info 'defaultant' => 1, 'usechains' => 0, }, + '0xe205' => { + 'name' => 'Bullet M5', + 'comment' => 'Bullet M5 In testing.', + 'supported' => '-2', + 'maxpower' => '19', + 'pwroffset' => '6', + 'antennas' => { 1 => 'N Connector' }, + 'defaultant' => 1, + 'usechains' => 0, + 'rfband' => '5800ubntus', + }, + '0xe215' => { + 'name' => 'airGrid M5', + 'comment' => 'airGrid M5 in testing', + 'supported' => '-2', + 'maxpower' => '19', + 'pwroffset' => '1', + 'antennas' => { 1 => 'airGrid' }, + 'defaultant' => 1, + 'usechains' => 0, + 'rfband' => '5800ubntus', + }, '0xe243' => { 'name' => 'NannoBridge M3', 'comment' => 'Not Tested', @@ -943,6 +976,61 @@ sub hardware_info 'defaultant' => 1, 'usechains' => 0, }, + '0xe255' => { + 'name' => 'airGrid M5 HP', + 'comment' => 'airGrid M5 HP in testing', + 'supported' => '-2', + 'maxpower' => '19', + 'pwroffset' => '6', + 'antennas' => { 1 => 'airGrid' }, + 'defaultant' => 1, + 'usechains' => 0, + 'rfband' => '5800ubntus', + }, + '0xe2b5' => { + 'name' => 'NannoBridge M5', + 'comment' => 'NanoBridge M5 in testing', + 'supported' => '-2', + 'maxpower' => '22', + 'pwroffset' => '1', + 'antennas' => { 1 => "Horizontal", 2 => "Vertical", 3 => "Diversity"}, + 'defaultant' => 3, + 'usechains' => 1, + 'rfband' => '5800ubntus', + }, + '0xe4e5' => { + 'name' => 'NannoBeam M5 International', + 'comment' => 'NanoBeam M5 International in testing', + 'supported' => '-2', + 'maxpower' => '22', + 'pwroffset' => '1', + 'antennas' => { 1 => "Horizontal", 2 => "Vertical", 3 => "Diversity"}, + 'defaultant' => 3, + 'usechains' => 1, + 'rfband' => '5500', + }, + '0xe805' => { + 'name' => 'NanoStation M5', + 'comment' => 'NanoStation M5 in testing', + 'supported' => '-2', + 'maxpower' => '22', + 'pwroffset' => '5', + 'antennas' => { 1 => "Horizontal", 2 => "Vertical", 3 => "Diversity" }, + 'defaultant' => 3, + 'usechains' => 1, + 'rfband' => '5800ubntus', + }, + '0xe8a5' => { + 'name' => 'NanoStation Loco M5', + 'comment' => 'NanoStation Loco M5 in testing', + 'supported' => '-2', + 'maxpower' => '22', + 'pwroffset' => '1', + 'antennas' => { 1 => "Horizontal", 2 => "Vertical", 3 => "Diversity" }, + 'defaultant' => 3, + 'usechains' => 1, + 'rfband' => '5800ubntus', + }, ); $boardid = hardware_boardid(); diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index d2e90e73..698fb90d 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -4,6 +4,7 @@ $debug = 0; BEGIN {push @INC, '/www/cgi-bin'}; use perlfunc; +use channelmaps; # # load the config parms @@ -165,8 +166,13 @@ if($parms{button_save}) } } - push (@errors, "invalid WiFi SSID") unless length $wifi_ssid <= 32; - push (@errors, "invalid WiFi channel") if $wifi_channel < 1 or $wifi_channel > 11; + push (@errors, "invalid WiFi SSID") unless length $wifi_ssid <= 32; + + if ( is_channel_valid($wifi_channel) != 1 ) + { + push (@errors, "invalid WiFi channel") + } + push (@errors, "invalid WiFi distance") if $wifi_distance < 0 or $wifi_distance =~ /\D/; if($lan_proto eq "static") @@ -486,8 +492,12 @@ if($wifi_proto ne "disabled") { print "