1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Set txpower w/ iw, persist value in UI

This commit is contained in:
billz 2021-04-20 17:53:09 +01:00
parent 6c674537bb
commit 643afe09e8
2 changed files with 18 additions and 3 deletions

View File

@ -32,6 +32,10 @@ function DisplayHostAPDConfig()
exec("iw reg get | awk '/country / { sub(/:/,\"\",$2); print $2 }'", $country_code);
$cmd = "iw dev ".$_SESSION['ap_interface']." info | awk '$1==\"txpower\" {print $2}'";
exec($cmd, $txpower);
$txpower = intval($txpower[0]);
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['SaveHostAPDSettings'])) {
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
@ -62,7 +66,7 @@ function DisplayHostAPDConfig()
}
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
exec('iwgetid '. $_POST['interface']. ' -r', $wifiNetworkID);
exec('iwgetid '. $_POST['interface'].' -r', $wifiNetworkID);
if (!empty($wifiNetworkID[0])) {
$managedModeEnabled = true;
}
@ -90,6 +94,17 @@ function DisplayHostAPDConfig()
if (!isset($arrConfig['country_code']) && isset($country_code[0])) {
$arrConfig['country_code'] = $country_code[0];
}
// set txpower with iw if value is non-default ('auto')
if (isset($_POST['txpower']) && ($_POST['txpower'] != 'auto')) {
$sdBm = $_POST['txpower'] * 100;
exec('sudo /sbin/iw dev '.$_POST['interface'].' set txpower fixed '.$sdBm, $return);
$status->addMessage('Setting transmit power to '.$_POST['txpower'].' dBm.', 'success');
$txpower = $_POST['txpower'];
} elseif ($_POST['txpower'] == 'auto') {
exec('sudo /sbin/iw dev '.$_POST['interface'].' set txpower auto', $return);
$status->addMessage('Setting transmit power to '.$_POST['txpower'].'.', 'success');
$txpower = $_POST['txpower'];
}
echo renderTemplate(
"hostapd", compact(
@ -104,6 +119,7 @@ function DisplayHostAPDConfig()
"arrSecurity",
"arrEncType",
"arrTxPower",
"txpower",
"arrHostapdConf"
)
);

View File

@ -1,4 +1,3 @@
<?php echo '<pre>' . var_export($arrTxPower, true) . '</pre>'; ?>
<div class="tab-pane fade" id="advanced">
<h4 class="mt-3"><?php echo _("Advanced settings"); ?></h4>
<div class="row">
@ -58,7 +57,7 @@
<label for="cbxtxpower"><?php echo _("Transmit power (dBm)") ?></label>
<i class="fas fa-question-circle" data-toggle="tooltip" data-placement="right" title="<?php echo _("dBm is an abbreviation for decibel relative to one milliwatt. It is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW)."); ?>"></i>
<?php
SelectorOptions('txpower', $arrTxPower, 'auto', 'cbxtxpower');
SelectorOptions('txpower', $arrTxPower, $txpower, 'cbxtxpower');
?>
<small id="txpower_help" class="text-muted"><?php echo _("Sets the txpower option for the AP interface and the configured country."); ?></small>
</div>