FlashAirで、周囲のWiFiのアクセスポイントを検索して、そのログを取るソフトを作ってみている。
とりあえず、一定時間毎に、時間と、SSIDとRSSIを記録するというのを作ってみた。
ログを取ったあと、そのログを解析して、無線AP情報から緯度経度を推定するサービスと連動させて移動の軌跡を出せるかなあ、とか考えている。
コードはLua言語で書いた。FlashAir W-04で動かしている。
test.luaというファイル名でFlashAirのSDカードストレージのルートフォルダーに入れる。
local file = io.open("/log.txt", "a")
file:write("WiFi SSID Logging data\r\n")
file:write("---\r\n")
file:close()
fa.SetCurrentTime(0x2821,0)
hh=0
mm=0
ss=0
sleep(100)
while true do
	file = io.open("/log.txt", "a")
	file:write("time , "..hh..","..mm..","..ss.."\r\n")
	count = fa.Scan()
	for i=0, (count-1), 1 do
		ssid, other = fa.GetScanInfo(i)
		if ssid ~= "" then
			file:write("SSID,"..ssid.."\r\n")
			for key, val in pairs(other) do
				if key=="RSSI" then
					file:write(" RSSI,"..val.."\r\n")
				end
			end
		end
	end
	file:write("---\r\n")
	file:close()
	fat_time = lfs.attributes("/log.txt")
	hh = bit32.band (bit32.rshift(fat_time.modification, 11),0x1F);
	mm = bit32.band (bit32.rshift(fat_time.modification, 5),0x3F);
	ss = bit32.band (fat_time.modification,0x1F)*2;
	sleep(1000*30)
end
 続きを読む →