From 4325a3ba5d99741c272dffb751df20d6c704315a Mon Sep 17 00:00:00 2001 From: Jonas Hess Date: Sat, 15 Jan 2022 22:05:38 +0100 Subject: [PATCH] new script: wifiscan --- ffbsee-wifiscan/Makefile | 17 +++++++++++++++++ ffbsee-wifiscan/files/sbin/wifilist.sh | 11 +++++++++++ ffbsee-wifiscan/files/sbin/wlan_scan.awk | 13 +++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 ffbsee-wifiscan/Makefile create mode 100755 ffbsee-wifiscan/files/sbin/wifilist.sh create mode 100644 ffbsee-wifiscan/files/sbin/wlan_scan.awk diff --git a/ffbsee-wifiscan/Makefile b/ffbsee-wifiscan/Makefile new file mode 100644 index 0000000..b704ce7 --- /dev/null +++ b/ffbsee-wifiscan/Makefile @@ -0,0 +1,17 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ffbsee-wifiscan +PKG_VERSION:=0.1 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Wolf +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)) diff --git a/ffbsee-wifiscan/files/sbin/wifilist.sh b/ffbsee-wifiscan/files/sbin/wifilist.sh new file mode 100755 index 0000000..5da93e0 --- /dev/null +++ b/ffbsee-wifiscan/files/sbin/wifilist.sh @@ -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 diff --git a/ffbsee-wifiscan/files/sbin/wlan_scan.awk b/ffbsee-wifiscan/files/sbin/wlan_scan.awk new file mode 100644 index 0000000..bed8b6f --- /dev/null +++ b/ffbsee-wifiscan/files/sbin/wlan_scan.awk @@ -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); +}