Workaround for WifiChecker triggering too often

This commit is contained in:
Anton Thomasson 2020-01-04 13:30:55 +01:00
parent 477aeeded0
commit ef8ecff007
2 changed files with 21 additions and 8 deletions

View file

@ -3,8 +3,10 @@ import Nemo.DBus 2.0
Item { Item {
id: checker
property bool connected: false property bool connected: false
property string ssid property var ssid
DBusInterface { DBusInterface {
bus: DBus.SystemBus bus: DBus.SystemBus
@ -29,17 +31,20 @@ Item {
for (var i = 0; i < result.length; i++) { for (var i = 0; i < result.length; i++) {
var entry = result[i][1]; var entry = result[i][1];
if(entry.Type == "wifi" && (entry.State == "online" || entry.State == "ready")) { if(entry.Type == "wifi" && (entry.State == "online" || entry.State == "ready")) {
ssid = entry.Name; if(checker.ssid != entry.Name) {
connected = true; // For whatever reason, the onchanged signal triggers when there isn't really a change
// so don't update the ssid if it is the same
checker.ssid = entry.Name;
}
checker.connected = true;
return; return;
} }
} }
ssid = undefined; checker.ssid = undefined;
connected = false; checker.connected = false;
}, },
function(error, message) { function(error, message) {
console.log('call failed', error, 'message:', message); console.log('call failed', error, 'message:', message);
page.currentSSID = entry.Name;
}) })
} }

View file

@ -21,7 +21,7 @@ Page {
WifiChecker { WifiChecker {
id: wifi id: wifi
onConnectedChanged: { onConnectedChanged: {
console.log("conn", connected) console.log("conn", connected, ssid)
if(connected) { if(connected) {
var favourites = db.getFavourites(ssid); var favourites = db.getFavourites(ssid);
console.log(favourites); console.log(favourites);
@ -32,8 +32,16 @@ Page {
} }
} }
property bool initialSSIDchange: true
onSsidChanged: { onSsidChanged: {
discovery.reset(); console.log("ssid changed", ssid);
if(!initialSSIDchange)
{
discovery.reset();
}
initialSSIDchange = false;
} }
} }