var wifi;
var ssid = 'ssid';
var password = 'password';
function initWifi(){
print('trying to connect wifi...');
wifi = require('Wifi');
wifi.connect(ssid, {password: password}, function() {
console.log('Connected to Wifi.IP address is:', wifi.getIP().ip);
});
}
function connectWifiAgain(){
if((require('Wifi').getStatus().ssid=='') || !(require('Wifi').getStatus().ssid)){
console.log('lost connect, trying to connect wifi again...');
wifi.connect(ssid, {password: password}, function() {
console.log('Connected to Wifi.IP address is:', wifi.getIP().ip);
});
}
}
function onInit(){
initWifi();
setInterval(connectWifiAgain,10000);
}
onInit();
save();