1
0

More than 3 years have passed since last update.

PHPでWi-Fi制御

Last updated at Posted at 2020-06-16

PHP WiFi
GitHub:https://github.com/sanchescom/php-wifi
Packagist:https://packagist.org/packages/sanchescom/php-wifi

インストール

Composerでインストールします。

>composer require sanchescom/php-wifi

コマンド

コマンドとして利用することができます。

アクセスポイント一覧

>.\vendor\bin\wifi list
 SSID               BSSID              Channel  Quality  dBm    Frequency  Connected  Security
----------------------------------------------------------------------------------------------------
 Buffalo-A-XXXX     XX:c2:bf:XX:fa:cc  53       63       -67    5250       true       WPA2-Personal
 aterm-XXXXXX-a     a4:XX:42:f1:XX:63  41       73       -62    5100       false      WPA2-Personal
...

接続しているアクセスポイント一覧

>.\vendor\bin\wifi list --connected
 SSID               BSSID              Channel  Quality  dBm    Frequency  Connected  Security
----------------------------------------------------------------------------------------------------
 Buffalo-A-XXXX     XX:c2:bf:XX:fa:cc  53       63       -67    5250       true       WPA2-Personal

切断

>.\vendor\bin\wifi disconnect --bssid=XX:c2:bf:XX:fa:cc --device=wlan

接続

>.\vendor\bin\wifi connect --bssid=XX:c2:bf:XX:fa:cc --password=password --device=wlan

PHP

index.php
<?php
include __DIR__ . '/vendor/autoload.php';

use Sanchescom\WiFi\WiFi;

$networks = WiFi::scan()->getAll();

foreach ($networks as $network) {
    echo "ssid:{$network->ssid} connected:{$network->connected}\n";
}
>php index.php
ssid:Buffalo-A-XXXX connected:1
ssid:aterm-XXXXXX-a connected:
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0