Permalink
Browse files

Add wifi network detection

  • Loading branch information...
NEMS Linux
NEMS Linux committed Nov 29, 2018
1 parent aaa6544 commit 6d642afcc99e331e4e63df94dd78c4d064926871
Showing with 30 additions and 0 deletions.
  1. +4 −0 info.sh
  2. +26 −0 info2.sh
@@ -83,6 +83,10 @@ elif [[ $COMMAND == "hwid" ]]; then
/sbin/ifconfig enp0s3 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | md5sum | cut -d"-" -f1 -
fi
elif [[ $COMMAND == "wifi" ]]; then
# output json response of detected wifi networks
/usr/local/share/nems/nems-scripts/info2.sh 7
elif [[ $COMMAND == "platform" ]]; then
# show if is pi or if is xu4, etc. by numerical value
/usr/local/share/nems/nems-scripts/info2.sh 3
@@ -69,6 +69,32 @@ switch($argv[1]) {
echo $data;
break;
case 7: // list detected wifi access points in json format
$wifitmp=shell_exec('nmcli -m multiline dev wifi');
$wifiarr=explode(PHP_EOL,$wifitmp);
$count=0;
if (is_array($wifiarr) && count($wifiarr) > 0) {
foreach ($wifiarr as $arr) {
$tmp = explode(':',$arr);
if ($tmp[0] == '*') {
$count++;
} else {
if (isset($tmp[1])) $result[$count][$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'];
}
}
}
}
echo json_encode($wifi);
break;
}

0 comments on commit 6d642af

Please sign in to comment.