harbour-seaprint/qml/components/WifiChecker.qml

48 lines
1.2 KiB
QML
Raw Normal View History

2019-12-02 22:56:06 +03:00
import QtQuick 2.0
2019-12-02 22:56:38 +03:00
import Nemo.DBus 2.0
2019-12-02 22:56:06 +03:00
Item {
2019-12-02 22:56:38 +03:00
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;
})
}
2019-12-02 22:56:06 +03:00
2019-12-02 22:56:38 +03:00
}
2019-12-02 22:56:06 +03:00
}