- Mon Aug 10, 2015 8:48 am
#25522
I've changed up my code some, but the problem still persists. The way I've found to get around it is to simply manually restart the node after calling wifi.sta.getap().
Do you guys think there will be any problems with restarting the node many many times? That way it won't crash and restart on it's own. I've also com across another peculiar problem. I would like to have the option to record the BSSID's of the networks around me, however when I change "wifi.sta.getap(append_ap)" to "wifi.sta.getap(1, appendap)" the logging function behaves differently. When appending SSID's to the file the function behaves as you would think it would, every time it is called a line of commas separated SSID's are appended into the file. However with the BSSID's a line isn't appended every time and sometimes the lines stop right in the middle of a BSSID. I have never gotten more than two and a half lines (two lines and an incomplete line). I asked a friend of mine what he thought, and he suggested that maybe the buffer wasn't getting cleared, but file.flush() doesn't seem to solve the problem. It's rather strange considering I have no trouble with the SSID's. Any suggestions?
My init.lua:
Code: Select allwifi.setmode(wifi.STATION)
function append_ap(t)
file.open("ap_list.txt", "a")
for k,v in pairs(t) do
if next(t, k) == nil then file.write(k)
else file.write(k..", ")
end
end
file.write("\n")
file.flush()
file.close()
print("yay")
end
wifi.sta.getap(append_ap)
tmr.alarm(0, 900000, 1, node.restart)
swoop swoop