如果需要根据自己的手机在连接或断开路由器WIFI时触发某个动作,可以通过iw命令定时查询手机的连接状态,执行如下命令可以列出所有连接到路由器WIFI的设备,
root@OpenWrt:~# iw dev wlan0 station dump
Station e0:ac:cb:b1:ca:ba (on wlan0)
inactive time: 27010 ms
rx bytes: 198087
rx packets: 1417
tx bytes: 843928
tx packets: 969
tx retries: 66
tx failed: 4
signal: -70 dBm
signal avg: -70 dBm
tx bitrate: 72.2 MBit/s MCS 7 short GI
rx bitrate: 24.0 MBit/s
expected throughput: 34.84Mbps
authorized: yes
authenticated: yes
preamble: short
WMM/WME: yes
MFP: no
TDLS peer: no
Station 04:52:f3:87:cf:77 (on wlan0)
inactive time: 620 ms
rx bytes: 316840
rx packets: 3260
tx bytes: 419569
tx packets: 1