Merge branch 'FixupTPLinkPower' into release-3.15.1.0

Deals with the fact that TPLink has max powers that differ based on frequency and are programed into the chip lower than what the manufacture states in its datasheet.

We want to make sure we don't fry any boards so we honor what the chip programming is set to.
This commit is contained in:
Conrad Lara - KG6JEI 2015-07-22 23:20:23 -07:00
commit 2755094c9f
5 changed files with 31 additions and 7 deletions

View File

@ -420,7 +420,7 @@ open(FILE, ">/etc/local/services") or die;
print FILE "#!/bin/sh\n";
unless($cfg{wifi_proto} eq "disabled")
{
$cfg{wifi_txpower} = wifi_maxpower() if not defined $cfg{wifi_txpower} or $cfg{wifi_txpower} > wifi_maxpower();
$cfg{wifi_txpower} = wifi_maxpower($cfg{wifi_channel}) if not defined $cfg{wifi_txpower} or $cfg{wifi_txpower} > wifi_maxpower($cfg{wifi_channel});
$cfg{wifi_txpower} = 1 if $cfg{wifi_txpower} < 1;
print FILE "/usr/sbin/iw dev wlan0 set txpower fixed $cfg{wifi_txpower}00\n";
if(defined $cfg{aprs_lat} and defined $cfg{aprs_lon})

View File

@ -954,19 +954,21 @@ sub hardware_info
'name' => 'TP-Link CPE210 v1.0',
'comment' => '',
'supported' => '-2',
'maxpower' => '27',
'maxpower' => '23',
'pwroffset' => '0',
'usechains' => 1,
'rfband' => '2400',
'chanpower' => { 1 => '22', 14 => '23' },
},
'TP-Link CPE510 v1.0' => {
'name' => 'TP-Link CPE510 v1.0',
'comment' => '',
'supported' => '-2',
'maxpower' => '27',
'maxpower' => '23',
'pwroffset' => '0',
'usechains' => 1,
'rfband' => '5800ubntus',
'chanpower' => { 48 => '10', 149 => '17', 184 => '23' },
},
'0xc2a2' => {
'name' => 'Bullet 2 HP',
@ -1268,8 +1270,22 @@ sub hardware_info
# Return maximum dbm value for tx power
sub wifi_maxpower
{
my ($wifichannel) = @_;
$boardinfo = hardware_info();
if ( exists $boardinfo->{'maxpower'} ) {
if ( exists $boardinfo->{'chanpower'} ) {
my $chanpower=$boardinfo->{'chanpower'};
foreach ( sort {$a<=>$b} keys %{$chanpower} )
{
if ( $wifichannel <= $_ )
{
return $chanpower->{$_};
}
}
# We should never get here
return 27;
} elsif ( exists $boardinfo->{'maxpower'} ) {
return $boardinfo->{'maxpower'};
} else
{

View File

@ -140,7 +140,7 @@ unless($parms{reload})
}
# sanitize the active settings
$wifi_txpower = wifi_maxpower() if not defined $wifi_txpower or $wifi_txpower > wifi_maxpower();
$wifi_txpower = wifi_maxpower($wifi_channel) if not defined $wifi_txpower or $wifi_txpower > wifi_maxpower($wifi_channel);
$wifi_txpower = 1 if $wifi_txpower < 1;
$wifi_distance = 0 unless defined $wifi_distance;
$wifi_distance = 0 if $wifi_distance =~ /\D/;
@ -600,8 +600,8 @@ if($wifi_proto ne "disabled")
print "<tr><td><nobr>Tx Power</nobr></td>\n";
print "<td><select name=wifi_txpower>\n";
my $txpoweroffset = wifi_txpoweroffset();
for($i = wifi_maxpower(); $i >= 1; --$i) { selopt($i+$txpoweroffset ." dBm", $i, $wifi_txpower) }
print "</select></td></tr>\n";
for($i = wifi_maxpower($wifi_channel); $i >= 1; --$i) { selopt($i+$txpoweroffset ." dBm", $i, $wifi_txpower) }
print "</select>&nbsp;&nbsp;<a href=\"/help.html\#power\" target=\"_blank\"><img src=\"/qmark.png\"></a></td></tr>\n";
print "<tr><td>Distance</td>\n";
print "<td><input type=text size=8 name=wifi_distance value='$wifi_distance' title='Distance in meters to the farthest neighbor'>&nbsp;meters</td></tr>\n";

View File

@ -287,6 +287,14 @@ As always a dummy load on unused RF ports is recommended to keep out physical
contaminants and to avoid EMI/RFI interference.
</p>
<p>
<a name="power"></a>The <strong>Power</strong> setting controls the max power
the unit may output. The node may decrease its power output as it enters higher
speed data rates to maintain a linear spectrum. Some devices may have max power
levels that change based on what channel/frequency the hardware is operating on,
in this case the max level will change when you save the settings and will be
capped at the max level supported by the hardware for that frequency.
</p>
<p>
The <strong>Distance</strong> setting adjusts the packet retry timer
to account for stations that are very far away, presumably about 300 meters or
more. The value should be set to the distance in meters to the farthest node

BIN
files/www/qmark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B