summaryrefslogtreecommitdiffstats
path: root/app/wifi/Wifi.qml
diff options
context:
space:
mode:
authorMilan Srdinko <msrdinko@alps.cz>2017-04-21 13:17:49 +0200
committerMilan Srdinko <msrdinko@alps.cz>2017-04-21 14:57:15 +0200
commita439f966d66555251fedbae99fb51757778c7456 (patch)
treed2412f840a37a146e6a880b814a70bb561c89f07 /app/wifi/Wifi.qml
parent607d2a47e93b721ef9671d62109384a290094b5f (diff)
WiFi: Fix WiFi UI not sync with network manager
Fix error that state of WiFi ON/OFF button after widget start is not in sync with actual state of wireless adapter. Change-Id: I71ac07d11b2364d6dbb69b492774323c9c39fbd6 AGL-BUG: SPEC-531 Signed-off-by: Milan Srdinko <msrdinko@alps.cz>
Diffstat (limited to 'app/wifi/Wifi.qml')
-rw-r--r--app/wifi/Wifi.qml117
1 files changed, 76 insertions, 41 deletions
diff --git a/app/wifi/Wifi.qml b/app/wifi/Wifi.qml
index b4e3357..20d12c0 100644
--- a/app/wifi/Wifi.qml
+++ b/app/wifi/Wifi.qml
@@ -27,6 +27,8 @@ SettingPage {
icon: '/wifi/images/HMI_Settings_WifiIcon.svg'
title: 'Wifi'
checkable: true
+ readonly property bool isWifi: true
+ property bool isInitializing: true
property string wifiAPIpath: bindingAddress + '/wifi-manager/'
//http://localhost:12345/api
@@ -48,6 +50,8 @@ SettingPage {
property string request_str: ""
property string status_str: ""
+
+
WebSocket {
id: websocket
url: address_str
@@ -122,6 +126,13 @@ SettingPage {
}
}
+ else if (verb_str == "status") {
+
+ var status = "OFF"
+ status = (message_json[2].response).Power
+
+ checked = (status === "ON") ? true : false
+ }
} else
console.log("Unhadled websocket message", message_json[0])
}
@@ -136,7 +147,35 @@ SettingPage {
} else if (websocket.status == WebSocket.Open) {
status_str = "Socket opened; sending message..."
+ //first get the status
+ verb_str = "status"
+ parameterJson = 'None'
+ sendSocketMesage(verb_str, parameterJson)
+
+
+
+ } else if (websocket.status == WebSocket.Closed) {
+ status_str = "Socket closed"
+ console.log("Socket closed, bye.")
+
+ websocket.active = false
+
+ }
+
+ console.log(status_str)
+ }
+ active: false
+ }
+
+ onCheckedChanged: {
+ console.log("Wifi set to", checked)
+
+ if (websocket.active) {
+
+ if (checked == true) {
+
//subscribe for events
+ var parameterJson
//network list updated event
verb_str = "eventadd"
@@ -182,60 +221,52 @@ SettingPage {
parameterJson = 'None'
sendSocketMesage(verb_str, parameterJson)
+ } else {
- } else if (websocket.status == WebSocket.Closed) {
- status_str = "Socket closed"
- console.log("Socket closed, bye.")
-
- }
-
- console.log(status_str)
- }
- active: false
- }
-
- onCheckedChanged: {
- console.log("Wifi set to", checked)
+ if (!isInitializing) {
- if (checked == true) {
- //activating is done when socket is opened
- websocket.active = true
+ networkList.clear()
- } else {
- networkList.clear()
+ verb_str = "deactivate"
+ parameterJson = 'None'
+ sendSocketMesage(verb_str, parameterJson)
- verb_str = "deactivate"
- var parameterJson = 'None'
- sendSocketMesage(verb_str, parameterJson)
+ verb_str = "eventunsub"
+ parameterJson = {
+ tag: 'passkey'
+ }
+ sendSocketMesage(verb_str, parameterJson)
- verb_str = "eventunsub"
- parameterJson = {
- tag: 'passkey'
- }
- sendSocketMesage(verb_str, parameterJson)
+ verb_str = "eventdel"
+ parameterJson = {
+ tag: 'passkey'
+ }
+ sendSocketMesage(verb_str, parameterJson)
- verb_str = "eventdel"
- parameterJson = {
- tag: 'passkey'
- }
- sendSocketMesage(verb_str, parameterJson)
+ verb_str = "eventunsub"
+ parameterJson = {
+ tag: 'networkList'
+ }
+ sendSocketMesage(verb_str, parameterJson)
- verb_str = "eventunsub"
- parameterJson = {
- tag: 'networkList'
- }
- sendSocketMesage(verb_str, parameterJson)
+ verb_str = "eventdel"
+ parameterJson = {
+ tag: 'networkList'
+ }
- verb_str = "eventdel"
- parameterJson = {
- tag: 'networkList'
- }
+ }
+ }
+ isInitializing = false
+ }
- websocket.active = false
+ else {
+ console.log("Websocket not active.")
+ websocket.active = true
}
+
}
@@ -444,4 +475,8 @@ SettingPage {
}
}
+ function activateWifi(){
+ websocket.active = true
+ }
+
}