harbour-seaprint/qml/pages/WifiChecker.qml
2019-12-02 20:56:38 +01:00

47 lines
1.2 KiB
QML

import QtQuick 2.0
import Nemo.DBus 2.0
Item {
property bool connected: false
property string ssid
DBusInterface {
bus: DBus.SystemBus
service: 'net.connman'
path: '/'
iface: 'net.connman.Manager'
signalsEnabled: true
Component.onCompleted: go()
function servicesChanged() {
console.log("services changed");
go();
}
function go() {
console.log("go!")
call("GetServices", undefined,
function(result) {
for (var i = 0; i < result.length; i++) {
var entry = result[i][1];
if(entry.Type == "wifi" && (entry.State == "online" || entry.State == "ready")) {
ssid = entry.Name;
connected = true;
return;
}
}
ssid = undefined;
connected = false;
},
function(error, message) {
console.log('call failed', error, 'message:', message);
page.currentSSID = entry.Name;
})
}
}
}