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
+ }
+
}
' href='#n458'>458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712