For checking if Yun is in Wifi range i'm using this lua script:
#!/usr/bin/lua
local function get_wifi_info(network, iface, accumulator)
local net = network:get_wifinet(iface)
if net then
local dev = net:get_device()
if dev then
accumulator["quality"] = net:signal_percent()
end
end
end
local function collect_wifi_info()
local network = require"luci.model.network".init()
local accumulator = {}
get_wifi_info(network, "wlan0", accumulator)
return accumulator
end
local info = collect_wifi_info()
if info.quality then
print(info.quality)
end
It is giving back the signalstrength of wifi.
At the sketch side im using this code:
boolean wifiConnected() {
String strength;
Process p; // Create a process and call it "p"
p.runShellCommand("/mnt/sda1/wifi-status.lua");
p.run(); // Run the process and wait for its termination
while (p.available()>0) {
char c = p.read();
strength += c;
}
// Ensure the last bit of data is sent.
Serial.flush();
#ifdef debug
Serial.println("Wifi Signalstaerke: " + strength);
#endif
if (strength == "") {
return false;
}
if (strength.toInt() > 0) {
return true;
}
else {
return false;
}
}
It's giving back TRUE if signalstrenght is more then zero.
Im using this in loop to decide, if yun should upload data or store data in file. After a while, sometimes hours, the hole yun is blocking. The white led, who is showing if wifi is ok, is going off and i can not access yun anymore until i reset it.
What could be going wrong? Thank's for some ideas.