--rssi2
-- ID AF home 4c:17:eb:de:7e:a3
-- ID Af mobile f0:d7:aa:e8:9c:0e
require ("gpio")require ("scanwifi")
local leds = {}
leds[1]='3g'
leds[2]='wlan'
leds[3]='lan'
leds[4]='wps'
while 1 do
local t={}
local line
local len=1
--for line in io.lines('/proc/net/wireless') do
-- for line in io.lines('/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/stations/f0:d7:aa:e8:9c:0e/last_signal') do for line in io.lines('/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/ave_beacon') do t[len]=line
len=len+1
end
writeGPIO(leds[1],0)
writeGPIO(leds[2],0)
writeGPIO(leds[3],0)
writeGPIO(leds[4],0)
local gpio18=t[1]
local sw1=string.find(gpio18,'-',1,true)
s=t[1]
-- while 1 do
RSSI=tonumber(string.sub(s,2,3))
if RSSI ==0 then print("wifi nao conectado")
elseif RSSI>0 and RSSI<=25 then
print("RSSI EXCELENTE")
writeGPIO(leds[1],1)
writeGPIO(leds[2],1)
writeGPIO(leds[3],1)
writeGPIO(leds[4],1)
elseif RSSI >25 and RSSI <40 then
print("RSSI BOM")
writeGPIO(leds[1],1)
writeGPIO(leds[2],1)
writeGPIO(leds[3],1)
writeGPIO(leds[4],0)
elseif RSSI >=40 and RSSI <55 then
print ("RSSI FRACO")
writeGPIO(leds[1],1)
writeGPIO(leds[2],1)
writeGPIO(leds[3],0)
writeGPIO(leds[4],0)
elseif RSSI >=55 and RSSI <70 then
print ("RSSI MUITO FRACO")
writeGPIO(leds[1],1)
writeGPIO(leds[2],0)
writeGPIO(leds[3],0)
writeGPIO(leds[4],0)
elseif RSSI >=70 then
print ("RSSI RUIM")
writeGPIO(leds[1],0)
writeGPIO(leds[2],0)
writeGPIO(leds[3],0)
writeGPIO(leds[4],0) end
print("RSSI= -",RSSI)
--io.write("RSSI= -\n ",RSSI)
--io.flush()
--print (t[21])
--print (sw1)rt={}rt[1]=(scanRT("GVT-07AF"))--print ("scan= -",rt)--sleep(1)rt[2]=(scanRT("dlink-Multi-2"))--sleep(1)rt[3]=(scanRT("HSTRADE"))print(rt[1],rt[2],rt[3])--if type(sw1)=="number" then
-- print("Gpio 18 -")
-- else print("gpio 18 low")
--end--return RSSIend