Permalink
Browse files

Rewrite wifi detection based on updated modules

  • Loading branch information...
NEMS Linux
NEMS Linux committed Dec 1, 2018
1 parent 6266c65 commit 4de8eb18399b06c7c68fdf4eaa9234544af020eb
Showing with 10 additions and 8 deletions.
  1. +10 −8 info2.sh
@@ -70,25 +70,27 @@ switch($argv[1]) {
break;
case 7: // list detected wifi access points in json format
$wifitmp=shell_exec('nmcli -m multiline dev wifi');
$wifi = array();
$wifitmp=shell_exec('iwlist wlan0 scan');
$wifiarr=explode(PHP_EOL,$wifitmp);
$count=0;
if (is_array($wifiarr) && count($wifiarr) > 0) {
foreach ($wifiarr as $arr) {
$tmp = explode(':',$arr);
if ($tmp[0] == '*') {
if (substr(trim($tmp[0]),0,4) == 'Cell') {
$count++;
} else {
if (isset($tmp[1])) $result[$count][$tmp[0]] = trim($tmp[1]);
if (isset($tmp[1])) $result[$count][trim($tmp[0])] = trim($tmp[1]);
}
}
if (isset($result) && count($result) > 0) {
foreach ($result as $data) {
if ($data['SSID'] != '--') {
$wifi[$data['SSID']]['channel'] = $data['CHAN'];
$wifi[$data['SSID']]['signal'] = $data['SIGNAL'];
$wifi[$data['SSID']]['rate'] = $data['RATE'];
$wifi[$data['SSID']]['security'] = $data['SECURITY'];
if (isset($data['ESSID'])) $data['ESSID'] = str_replace('"','',$data['ESSID']);
if (strlen($data['ESSID']) > 0) {
$wifi[$data['ESSID']]['channel'] = $data['Channel'];
$wifi[$data['ESSID']]['frequency'] = $data['Frequency'];
$wifi[$data['ESSID']]['rate'] = $data['Bit Rates'];
$wifi[$data['ESSID']]['encryption'] = $data['Encryption key'];
}
}
}

0 comments on commit 4de8eb1

Please sign in to comment.