blob: fc319d2f3020d2498e904024275118eb4e171daf [file] [log] [blame]
#!/bin/sh
. /etc/utils.sh
taxonomize() {
sig="$1"
mac="$2"
python -c "import taxonomy; \
print ';'.join(taxonomy.identify_wifi_device('$sig', '$mac'))"
}
dhcpname() {
mac="$1"
while read -r time leasemac ip name junk; do
if contains "$leasemac" "$mac"; then
echo "$name"
fi
done </config/dhcp.leases
}
dhcpsig() {
mac="$1"
while read -r leasemac sig; do
if contains "$leasemac" "$mac"; then
echo "$sig"
fi
done </config/dhcp.fingerprints
}
stations24=""
stations5=""
watch-dir /tmp/wifi/fingerprints | while read junk; do
sleep 0.25
wifi24=$(wifi show -b 2.4 2>&1)
wifi5=$(wifi show -b 5 2>&1)
for file in /tmp/wifi/fingerprints/*; do
[ -e "$file" ] || continue
contains "$file" ".tmp" && continue
sig=$(cat "$file")
mac=$(basename "$file")
name=$(dhcpname "$mac")
tax=$(taxonomize "$sig" "$mac")
dhcpsig=$(dhcpsig "$mac")
stationskey="$mac|$sig"
if contains "$wifi24" "$mac"; then
contains "$stations24" "$stationskey" && continue
date
echo 2.4GHz: "$name" "$mac"
echo "$tax"
echo "$sig"
echo "dhcp|$dhcpsig"
echo
stations24="${stations24},$stationskey"
fi
if contains "$wifi5" "$mac"; then
contains "$stations5" "$stationskey" && continue
date
echo 5.0GHz: "$name" "$mac"
echo "$tax"
echo "$sig"
echo "dhcp|$dhcpsig"
echo
stations5="${stations5},$stationskey"
fi
done
done