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:
		@@ -7,13 +7,7 @@ if (isset($_POST['interface'])) {
 | 
			
		||||
 | 
			
		||||
    $iface = escapeshellcmd($_POST['interface']);
 | 
			
		||||
    $parser = new \RaspAP\Parsers\IwParser($iface);
 | 
			
		||||
 | 
			
		||||
    $supportedFrequencies = $parser->parseIwList($iface);
 | 
			
		||||
 | 
			
		||||
    # debug
 | 
			
		||||
    #foreach ($supportedFrequencies as $frequency) {
 | 
			
		||||
    #    echo "<br>Frequency: {$frequency['MHz']} MHz, Channel: {$frequency['Channel']}, dBm: {$frequency['dBm']}\n";
 | 
			
		||||
    #}
 | 
			
		||||
    $supportedFrequencies = $parser->parseIwInfo($iface);
 | 
			
		||||
 | 
			
		||||
    echo json_encode($supportedFrequencies);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,26 +13,33 @@ declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace RaspAP\Parsers;
 | 
			
		||||
 | 
			
		||||
class IwParser {
 | 
			
		||||
class IwParser
 | 
			
		||||
{
 | 
			
		||||
    private $iw_output;
 | 
			
		||||
 | 
			
		||||
    public function __construct(string $interface = 'wlan0') {
 | 
			
		||||
    public function __construct(string $interface = 'wlan0')
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        // Resolve physical device for selected 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];
 | 
			
		||||
 | 
			
		||||
        // Fetch 'iw info' output for phy
 | 
			
		||||
        $this->iw_output = shell_exec("iw $phy info");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function parseIwList() {
 | 
			
		||||
        /**
 | 
			
		||||
         * (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.
 | 
			
		||||
         */
 | 
			
		||||
    /**
 | 
			
		||||
     * Parses raw output of 'iw info' command, filtering supported frequencies.
 | 
			
		||||
     *
 | 
			
		||||
     * Frequencies with the following regulatory restrictions are excluded:
 | 
			
		||||
     * (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(
 | 
			
		||||
            "(no IR, radar detection)",
 | 
			
		||||
            "(radar detection)",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user