Skip to content

Commit

Permalink
new script: wifiscan
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf128058 committed Jan 15, 2022
1 parent c9a8966 commit 4325a3b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ffbsee-wifiscan/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=ffbsee-wifiscan
PKG_VERSION:=0.1
PKG_RELEASE:=1

PKG_MAINTAINER:=Wolf <[email protected]>
PKG_LICENSE:=MIT

include $(TOPDIR)/../package/gluon.mk

define Package/ffbsee-wifiscan
TITLE:=The wifiscan-scripts generate a wifiscan-result-json-string
DEPENDS:=+iw
endef

$(eval $(call BuildPackageGluon,ffbsee-wifiscan))
11 changes: 11 additions & 0 deletions ffbsee-wifiscan/files/sbin/wifilist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

function wifilist()
{
iw dev | grep "Interface" | grep -v "mesh" | sed 's/.*Interface\|//' | while read device
do
iw dev $device scan lowpri | awk -f wlan_scan.awk
done
}
result="["$(wifilist|sed '$s/,$//')"]"
echo $result
13 changes: 13 additions & 0 deletions ffbsee-wifiscan/files/sbin/wlan_scan.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/^BSS/ {
mac = gensub ( /^BSS[[:space:]]*([0-9a-fA-F:]+).*?$/, "\\1", "g", $0 );
}
/^[[:space:]]*signal:/ {
signal = gensub ( /^[[:space:]]*signal:[[:space:]]*(\-?[0-9.]+).*?$/, "\\1", "g", $0 );
}
/^[[:space:]]*\* primary channel:/ {
channel = gensub (/^[[:space:]]*\* primary channel:[[:space:]]*(\-?[0-9.]+).*?$/, "\\1", "g", $0);
}
/^[[:space:]]*SSID:/ {
ssid = gensub ( /^[[:space:]]*SSID:[[:space:]]*([^\n]*).*?$/, "\\1", "g", $0 );
printf ( "{\"ssid\": \"%s\", \"mac\": \"%s\", \"signal\": %s, \"channel\": \"%s\"},\n", ssid, mac, signal, channel);
}

0 comments on commit 4325a3b

Please sign in to comment.