mirror of https://github.com/aredn/aredn.git
bugfix: Add max power level tracking control for per channel power on devices
Mainly relates to TP-Link devices which have a roving power level programmed into the hardware. The datasheets for the hardware may say higher power but the chip has been programmed to not go above these values.
This commit is contained in:
parent
9b30e157bc
commit
108e05088b
|
@ -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})
|
||||
|
|
|
@ -958,6 +958,7 @@ sub hardware_info
|
|||
'pwroffset' => '0',
|
||||
'usechains' => 1,
|
||||
'rfband' => '2400',
|
||||
'chanpower' => { 1 => '22', 14 => '23' },
|
||||
},
|
||||
'TP-Link CPE510 v1.0' => {
|
||||
'name' => 'TP-Link CPE510 v1.0',
|
||||
|
@ -967,6 +968,7 @@ sub hardware_info
|
|||
'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
|
||||
{
|
||||
|
|
|
@ -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,7 +600,7 @@ 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) }
|
||||
for($i = wifi_maxpower($wifi_channel); $i >= 1; --$i) { selopt($i+$txpoweroffset ." dBm", $i, $wifi_txpower) }
|
||||
print "</select></td></tr>\n";
|
||||
|
||||
print "<tr><td>Distance</td>\n";
|
||||
|
|
Loading…
Reference in New Issue