mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
parseIwList -> parseIwInfo() + formatting
This commit is contained in:
parent
7a612592c2
commit
25cc92b593
@ -7,13 +7,7 @@ if (isset($_POST['interface'])) {
|
|||||||
|
|
||||||
$iface = escapeshellcmd($_POST['interface']);
|
$iface = escapeshellcmd($_POST['interface']);
|
||||||
$parser = new \RaspAP\Parsers\IwParser($iface);
|
$parser = new \RaspAP\Parsers\IwParser($iface);
|
||||||
|
$supportedFrequencies = $parser->parseIwInfo($iface);
|
||||||
$supportedFrequencies = $parser->parseIwList($iface);
|
|
||||||
|
|
||||||
# debug
|
|
||||||
#foreach ($supportedFrequencies as $frequency) {
|
|
||||||
# echo "<br>Frequency: {$frequency['MHz']} MHz, Channel: {$frequency['Channel']}, dBm: {$frequency['dBm']}\n";
|
|
||||||
#}
|
|
||||||
|
|
||||||
echo json_encode($supportedFrequencies);
|
echo json_encode($supportedFrequencies);
|
||||||
}
|
}
|
||||||
|
@ -13,26 +13,33 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace RaspAP\Parsers;
|
namespace RaspAP\Parsers;
|
||||||
|
|
||||||
class IwParser {
|
class IwParser
|
||||||
|
{
|
||||||
private $iw_output;
|
private $iw_output;
|
||||||
|
|
||||||
public function __construct(string $interface = 'wlan0') {
|
public function __construct(string $interface = 'wlan0')
|
||||||
|
{
|
||||||
|
|
||||||
// Resolve physical device for selected interface
|
// Resolve physical device for selected interface
|
||||||
$iface = escapeshellarg($interface);
|
$iface = escapeshellarg($interface);
|
||||||
exec("iw dev | awk -v iface=".$iface." '/^phy#/ { phy = $0 } $1 == \"Interface\" { interface = $2 } interface == iface { print phy }'", $return);
|
$pattern = "iw dev | awk -v iface=".$iface." '/^phy#/ { phy = $0 } $1 == \"Interface\" { interface = $2 } interface == iface { print phy }'";
|
||||||
|
exec($pattern, $return);
|
||||||
$phy = $return[0];
|
$phy = $return[0];
|
||||||
|
|
||||||
// Fetch 'iw info' output for phy
|
// Fetch 'iw info' output for phy
|
||||||
$this->iw_output = shell_exec("iw $phy info");
|
$this->iw_output = shell_exec("iw $phy info");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseIwList() {
|
/**
|
||||||
/**
|
* Parses raw output of 'iw info' command, filtering supported frequencies.
|
||||||
* (no IR): the AP won't Initiate Radiation until a DFS scan (or similar) is complete on these bands.
|
*
|
||||||
* (radar detection): the specified channels are shared with radar equipment.
|
* Frequencies with the following regulatory restrictions are excluded:
|
||||||
* (disabled): self-explanatory.
|
* (no IR): the AP won't Initiate Radiation until a DFS scan (or similar) is complete on these bands.
|
||||||
*/
|
* (radar detection): the specified channels are shared with radar equipment.
|
||||||
|
* (disabled): self-explanatory.
|
||||||
|
*/
|
||||||
|
public function parseIwInfo()
|
||||||
|
{
|
||||||
$excluded = array(
|
$excluded = array(
|
||||||
"(no IR, radar detection)",
|
"(no IR, radar detection)",
|
||||||
"(radar detection)",
|
"(radar detection)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user