diff --git a/app/js/custom.js b/app/js/custom.js
index d5c1abe5..3523fc56 100644
--- a/app/js/custom.js
+++ b/app/js/custom.js
@@ -120,6 +120,11 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) {
$('#txtwpapassphrase').val(genPassword(63));
});
+// Enable Bootstrap tooltips
+$(function () {
+ $('[data-toggle="tooltip"]').tooltip()
+})
+
function genPassword(pwdLen) {
var pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var rndPass = Array(pwdLen).fill(pwdChars).map(function(x) { return x[Math.floor(Math.random() * x.length)] }).join('');
diff --git a/config/defaults.json b/config/defaults.json
index faab15b6..67948d0d 100644
--- a/config/defaults.json
+++ b/config/defaults.json
@@ -49,6 +49,9 @@
"AllowedIPs": ["10.8.2.0/24"],
"PersistentKeepalive": [ "15" ]
}
+ },
+ "txpower": {
+ "dbm": [ "auto", "30", "20", "17", "10", "6", "3", "1", "0" ]
}
}
diff --git a/includes/functions.php b/includes/functions.php
index 2f1c502b..a3ffbf45 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -152,15 +152,16 @@ function getDefaultNetValue($svc,$iface,$key)
* Returns default options for the specified service
*
* @param string $svc
+ * @param string $key
* @return object $json
*/
-function getDefaultNetOpts($svc)
+function getDefaultNetOpts($svc,$key)
{
$json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true);
if ($json === null) {
return false;
} else {
- return $json[$svc]['options'];
+ return $json[$svc][$key];
}
}
@@ -774,4 +775,4 @@ function preg_only_match($pat,$haystack) {
function qr_encode($str)
{
return preg_replace('/(? 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
+ $arrTxPower = getDefaultNetOpts('txpower','dbm');
$managedModeEnabled = false;
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
sort($interfaces);
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);
@@ -61,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;
}
@@ -89,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(
@@ -102,6 +118,8 @@ function DisplayHostAPDConfig()
"selectedHwMode",
"arrSecurity",
"arrEncType",
+ "arrTxPower",
+ "txpower",
"arrHostapdConf"
)
);
@@ -306,13 +324,13 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
if ($bridgedEnable == 1) {
- $config = array_keys(getDefaultNetOpts('dhcp'));
+ $config = array_keys(getDefaultNetOpts('dhcp','options'));
$config[] = PHP_EOL.'# RaspAP br0 configuration';
$config[] = 'denyinterfaces eth0 wlan0';
$config[] = 'interface br0';
$config[] = PHP_EOL;
} elseif ($wifiAPEnable == 1) {
- $config = array_keys(getDefaultNetOpts('dhcp'));
+ $config = array_keys(getDefaultNetOpts('dhcp','options'));
$config[] = PHP_EOL.'# RaspAP uap0 configuration';
$config[] = 'interface uap0';
$config[] = 'static ip_address='.$ip_address;
diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers
index 93389d4d..355fd8eb 100644
--- a/installers/raspap.sudoers
+++ b/installers/raspap.sudoers
@@ -32,6 +32,7 @@ www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] up
www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan[0-9]
www-data ALL=(ALL) NOPASSWD:/sbin/ifup *
www-data ALL=(ALL) NOPASSWD:/sbin/ifdown *
+www-data ALL=(ALL) NOPASSWD:/sbin/iw
www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh
diff --git a/locale/en_US/LC_MESSAGES/messages.mo b/locale/en_US/LC_MESSAGES/messages.mo
index cd410c69..f51f7c62 100644
Binary files a/locale/en_US/LC_MESSAGES/messages.mo and b/locale/en_US/LC_MESSAGES/messages.mo differ
diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po
index 5713516c..a321f2b7 100644
--- a/locale/en_US/LC_MESSAGES/messages.po
+++ b/locale/en_US/LC_MESSAGES/messages.po
@@ -528,8 +528,8 @@ msgstr "Hide SSID in broadcast"
msgid "Maximum number of clients"
msgstr "Maximum number of clients"
-msgid "Configures the max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
-msgstr "Configures the max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
+msgid "Configures the max_num_sta
option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
+msgstr "Configures the max_num_sta
option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
msgid "Beacon interval"
msgstr "Beacon interval"
@@ -549,6 +549,15 @@ msgstr "Close"
msgid "Enable this option to log hostapd
activity."
msgstr "Enable this option to log hostapd
activity."
+msgid "Transmit power (dBm)"
+msgstr "Transmit power (dBm)"
+
+msgid "Sets the txpower
option for the AP interface and the configured country."
+msgstr "Sets the txpower
option for the AP interface and the configured country."
+
+msgid "dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW."
+msgstr "dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW."
+
#: includes/networking.php
msgid "Summary"
msgstr "Summary"
diff --git a/templates/hostapd/advanced.php b/templates/hostapd/advanced.php
index f7c9ee93..f331734b 100644
--- a/templates/hostapd/advanced.php
+++ b/templates/hostapd/advanced.php
@@ -52,11 +52,22 @@