default wifi distance to 0, disallow saving with 0 value, change alert to show on 0

This commit is contained in:
Darryl Quinn 2016-01-05 23:09:34 -06:00
parent 1e24cda1f1
commit 07f447313f
3 changed files with 17 additions and 14 deletions

View File

@ -6,7 +6,7 @@ wifi_mode = adhoc
wifi_txpower = 19
wifi_channel = 1
wifi_chanbw = 20
wifi_distance = 100000
wifi_distance = 0
wifi_country = 00
dmz_mode = 3

View File

@ -6,7 +6,7 @@ wifi_mode = adhoc
wifi_txpower = 19
wifi_channel = 1
wifi_chanbw = 20
wifi_distance = 100000
wifi_distance = 0
wifi_country = 00
dmz_mode = 3

View File

@ -150,24 +150,27 @@ $wifi_distance = 0 if $wifi_distance =~ /\D/;
$parms{wifi_distance} = $wifi_distance;
$parms{wifi_txpower} = $wifi_txpower;
@errors = ();
#
# apply the wifi settings
#
if($parms{button_apply} or $parms{button_save})
{
my $wifiintf = get_interface("wifi");
$cmd = "";
$cmd .= "iw phy phy0 set distance $wifi_distance >/dev/null 2>&1;";
$cmd .= "iw dev $wifiintf set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;";
system $cmd;
if($wifi_distance < 1 or $wifi_distance =~ /\D/)
{
push (@errors, "invalid distance value");
} else {
my $wifiintf = get_interface("wifi");
$cmd = "";
$cmd .= "iw phy phy0 set distance $wifi_distance >/dev/null 2>&1;";
$cmd .= "iw dev $wifiintf set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;";
system $cmd;
}
}
# validate and save configuration
@errors = ();
if($parms{button_save})
{
if($wifi_proto eq "static")
@ -200,7 +203,7 @@ if($parms{button_save})
$wifi_chanbw = 20;
}
push (@errors, "invalid WiFi distance") if $wifi_distance < 0 or $wifi_distance =~ /\D/;
$wifi_country_validated=0;
foreach my $testcountry (split(',',"00,HX,AD,AE,AL,AM,AN,AR,AT,AU,AW,AZ,BA,BB,BD,BE,BG,BH,BL,BN,BO,BR,BY,BZ,CA,CH,CL,CN,CO,CR,CY,CZ,DE,DK,DO,DZ,EC,EE,EG,ES,FI,FR,GE,GB,GD,GR,GL,GT,GU,HN,HK,HR,HT,HU,ID,IE,IL,IN,IS,IR,IT,JM,JP,JO,KE,KH,KP,KR,KW,KZ,LB,LI,LK,LT,LU,LV,MC,MA,MO,MK,MT,MY,MX,NL,NO,NP,NZ,OM,PA,PE,PG,PH,PK,PL,PT,PR,QA,RO,RS,RU,RW,SA,SE,SG,SI,SK,SV,SY,TW,TH,TT,TN,TR,UA,US,UY,UZ,VE,VN,YE,ZA,ZW")) {
@ -373,7 +376,7 @@ function updDist(x) {
document.getElementsByName('wifi_distance_disp')[0].value = x;
dist_hidden.value = xc;
// if default, then ALERT!
if(dist_hidden.value==100000) {
if(dist_hidden.value==0) {
distBox.className = 'dist-alert';
} else {
distBox.className = 'dist-norm';
@ -640,7 +643,7 @@ if($wifi_proto ne "disabled")
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 id='dist' class='dist-norm'><td>Distance to<br />FARTHEST Node</td>\n";
print "<tr id='dist' class='dist-norm'><td>Distance to<br />FARTHEST Neighbor</td>\n";
$wifi_distance_disp=int($wifi_distance/1000);
print "<td><input readonly type=text size=8 name='wifi_distance_disp' value='$wifi_distance_disp' title='Distance to the farthest neighbor'>&nbsp;<span id='distance_unit_text'>kilometers</span><br />";