summaryrefslogtreecommitdiffstats
path: root/examples/wifi/wifi-qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/wifi/wifi-qml')
-rw-r--r--examples/wifi/wifi-qml/WifiConnectionHandler.qml51
-rw-r--r--examples/wifi/wifi-qml/WifiScanner.qml249
-rw-r--r--examples/wifi/wifi-qml/doc/images/wifi-qml.jpgbin76197 -> 0 bytes
-rw-r--r--examples/wifi/wifi-qml/doc/src/wifi-qml.qdoc85
-rw-r--r--examples/wifi/wifi-qml/main.cpp30
-rw-r--r--examples/wifi/wifi-qml/main.qml32
-rw-r--r--examples/wifi/wifi-qml/qml.qrc7
-rw-r--r--examples/wifi/wifi-qml/wifi-qml.pro11
8 files changed, 0 insertions, 465 deletions
diff --git a/examples/wifi/wifi-qml/WifiConnectionHandler.qml b/examples/wifi/wifi-qml/WifiConnectionHandler.qml
deleted file mode 100644
index f3f2c10..0000000
--- a/examples/wifi/wifi-qml/WifiConnectionHandler.qml
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use the contact form at
-** http://www.qt.io
-**
-** This file is part of Qt Enterprise Embedded.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** the contact form at http://www.qt.io
-**
-****************************************************************************/
-import QtQuick 2.3
-import B2Qt.Wifi 1.0
-
-//! [0]
-Item {
- WifiConfiguration {
- id: localConfig
- ssid: "network-for-my-device"
- passphrase: "password123"
- protocol: "WPA2"
- }
-
- Connections {
- target: WifiManager
- onBackendStateChanged: {
- if (WifiManager.backendState === WifiManager.Running)
- WifiManager.connect(localConfig)
- }
- onNetworkStateChanged: {
- if (WifiManager.networkState === WifiManager.Connected)
- print("successfully connected to: " + WifiManager.currentSSID)
- }
- }
-
- Component.onCompleted: {
- if (WifiManager.backendState === WifiManager.Running) {
- WifiManager.connect(localConfig)
- } else {
- WifiManager.start()
- }
- }
-}
-//! [0]
diff --git a/examples/wifi/wifi-qml/WifiScanner.qml b/examples/wifi/wifi-qml/WifiScanner.qml
deleted file mode 100644
index 9dbbd46..0000000
--- a/examples/wifi/wifi-qml/WifiScanner.qml
+++ /dev/null
@@ -1,249 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use the contact form at
-** http://www.qt.io
-**
-** This file is part of Qt Enterprise Embedded.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** the contact form at http://www.qt.io
-**
-****************************************************************************/
-import QtQuick 2.3
-import QtQuick.Controls 1.2
-import B2Qt.Wifi 1.0
-
-Item {
- anchors.fill: parent
-
- Binding {
- target: WifiManager
- property: "scanning"
- value: networkView.visible
- }
-
- Button {
- id: wifiOnOffButton
- anchors.top: parent.top
- anchors.topMargin: 20
- anchors.left: parent.left
- anchors.right: parent.right
- onClicked: {
- if (WifiManager.backendState === WifiManager.Running) {
- if (networkView.visible)
- networkView.visible = false
- WifiManager.stop()
- } else if (WifiManager.backendState === WifiManager.NotRunning) {
- WifiManager.start()
- }
- }
-
- Component.onCompleted: updateButtonText(WifiManager.backendState)
- Connections {
- target: WifiManager
- onBackendStateChanged: wifiOnOffButton.updateButtonText(backendState)
- }
-
- function updateButtonText(backendState)
- {
- if (backendState === WifiManager.Initializing)
- wifiOnOffButton.text = "Initializing..."
- if (backendState === WifiManager.Terminating)
- wifiOnOffButton.text = "Terminating..."
- if (backendState === WifiManager.NotRunning)
- wifiOnOffButton.text = "Switch On"
- if (backendState === WifiManager.Running)
- wifiOnOffButton.text = "Switch Off"
- }
- }
-
- Button {
- id: listNetworksButton
- anchors.top: wifiOnOffButton.bottom
- anchors.topMargin: 30
- anchors.left: parent.left
- anchors.right: parent.right
- visible: WifiManager.backendState === WifiManager.Running
- text: networkView.visible ? "Hide wifi networks"
- : "List available wifi networks"
- onClicked: networkView.visible = !networkView.visible
- }
- //! [0]
- ListView {
- id: networkView
- model: WifiManager.networks
- delegate: listDelegate
- implicitHeight: 800
- anchors.top: listNetworksButton.bottom
- anchors.topMargin: 30
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- visible: false
- clip: true
-
- property string networkStateText: ""
- property QtObject expandedNetworkBox: null
- property bool hasExpandedNetworkBox: expandedNetworkBox !== null
-
- function setNetworkStateText(networkState) {
- if (networkState === WifiManager.ObtainingIPAddress)
- networkView.networkStateText = " (obtaining ip..)"
- else if (networkState === WifiManager.DhcpRequestFailed)
- networkView.networkStateText = " (dhcp request failed)"
- else if (networkState === WifiManager.Connected)
- networkView.networkStateText = " (connected)"
- else if (networkState === WifiManager.Authenticating)
- networkView.networkStateText = " (authenticating..)"
- else if (networkState === WifiManager.HandshakeFailed)
- networkView.networkStateText = " (wrong password)"
- else if (networkState === WifiManager.Disconnected)
- networkView.networkStateText = ""
- }
-
- Connections {
- target: WifiManager
- onNetworkStateChanged: networkView.setNetworkStateText(networkState)
- }
-
- Component.onCompleted: {
- if (WifiManager.backendState == WifiManager.Running)
- networkView.visible = true
- }
- }
- //! [0]
- //! [2]
- WifiConfiguration {
- id: config
- protocol: "WPA2"
- }
- //! [2]
- Component {
- id: listDelegate
- Rectangle {
- id: networkBox
- property bool expanded: false
- property bool isCurrentNetwork: WifiManager.currentSSID === ssid
- property bool connected: isCurrentNetwork && WifiManager.networkState === WifiManager.Connected
- property int notExpandedHeight: ssidLabel.height + bssidLabel.height + 20
- property int expandedHeight: notExpandedHeight + passwordInput.height + connectionButton.height + 54
- property int connectedExpandedHeight: notExpandedHeight + connectionButton.height + 30
- height: expanded ? (connected ? connectedExpandedHeight : expandedHeight) : notExpandedHeight
- width: parent.width
- clip: true
- border.color: "black"
- border.width: 1
-
- Component.onDestruction: if (expanded) networkView.expandedNetworkBox = null
- onHeightChanged: if (expanded) networkView.positionViewAtIndex(index, ListView.Contain)
-
- Behavior on height { NumberAnimation { duration: 500; easing.type: Easing.InOutCubic } }
- //! [1]
- Text {
- id: ssidLabel
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.margins: 5
- anchors.leftMargin: 10
- font.pixelSize: 26
- font.bold: true
- text: isCurrentNetwork ? ssid + networkView.networkStateText : ssid
- Component.onCompleted: networkView.setNetworkStateText(WifiManager.networkState)
- }
-
- Text {
- id: bssidLabel
- anchors.top: ssidLabel.bottom
- anchors.left: parent.left
- anchors.margins: 5
- anchors.leftMargin: 30
- text: bssid
- font.pixelSize: ssidLabel.font.pixelSize * 0.8
- }
-
- Text {
- id: flagsLabel
- anchors.top: bssidLabel.top
- anchors.left: bssidLabel.right
- anchors.leftMargin: 35
- text: (supportsWPA2 ? "WPA2 " : "")
- + (supportsWPA ? "WPA " : "")
- + (supportsWEP ? "WEP " : "")
- + (supportsWPS ? "WPS " : "");
- font.pixelSize: ssidLabel.font.pixelSize * 0.8
- font.italic: true
- }
-
- ProgressBar {
- id: signalStrengthBar
- height: 20
- width: networkBox.width * 0.5
- anchors.margins: 10
- anchors.right: parent.right
- anchors.top: parent.top
- minimumValue: 0
- maximumValue: 100
- value : signalStrength
- }
- //! [1]
- MouseArea {
- anchors.fill: parent
- onClicked: handleNetworkBoxExpanding()
- }
-
- function handleNetworkBoxExpanding()
- {
- expanded = !expanded
- if (expanded) {
- if (networkView.hasExpandedNetworkBox)
- networkView.expandedNetworkBox.expanded = false
- networkView.expandedNetworkBox = networkBox
- } else {
- networkView.expandedNetworkBox = null
- }
- }
-
- TextField {
- id: passwordInput
- anchors.top: flagsLabel.bottom
- anchors.topMargin: 15
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width * 0.36
- height: connectionButton.height * 1.1
- placeholderText: "Enter Password"
- visible: !connected
- font.pixelSize: 16
- echoMode: TextInput.Password
- inputMethodHints: Qt.ImhNoPredictiveText
- }
-
- Button {
- id: connectionButton
- y: connected ? passwordInput.y
- : passwordInput.y + passwordInput.height + 10
- width: passwordInput.width
- anchors.horizontalCenter: parent.horizontalCenter
- text: connected ? "Disconnect" : "Connect"
- //! [3]
- onClicked: {
- if (connected) {
- WifiManager.disconnect()
- } else {
- config.ssid = ssid;
- config.passphrase = passwordInput.text
- if (!WifiManager.connect(config))
- print("failed to connect: " + WifiManager.lastError)
- }
- }
- //! [3]
- }
- }
- }
-}
diff --git a/examples/wifi/wifi-qml/doc/images/wifi-qml.jpg b/examples/wifi/wifi-qml/doc/images/wifi-qml.jpg
deleted file mode 100644
index 649707f..0000000
--- a/examples/wifi/wifi-qml/doc/images/wifi-qml.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/wifi/wifi-qml/doc/src/wifi-qml.qdoc b/examples/wifi/wifi-qml/doc/src/wifi-qml.qdoc
deleted file mode 100644
index ba77c1e..0000000
--- a/examples/wifi/wifi-qml/doc/src/wifi-qml.qdoc
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use the contact form at
-** http://www.qt.io
-**
-** This file is part of Qt Enterprise Embedded.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** the contact form at http://www.qt.io
-**
-****************************************************************************/
-/*!
-
- \title Getting Started with B2Qt.Wifi in QML
- \example wifi/wifi-qml
- \ingroup wifi-examples
- \brief Guide to getting started with B2Qt.Wifi using QML.
-
- \section1 Preparing the Application
-
- Use the following \c import statement in the QML files to access the B2Qt.Wifi QML types:
-
- \code
- import B2Qt.Wifi 1.0
- \endcode
-
- This guide will demonstrate how to create a QML based application that utilizes
- B2Qt.Wifi API to set up a wifi network connection. We will start by looking at how to scan the
- surroundings for wifi access points and how to display and process this data in the application.
- At the end of the guide we will show how to connect directly to a known wifi network configuration.
-
- \image wifi-qml.jpg
-
- \section1 Listing Wifi Networks
-
- First we need to set up ListView which we will use to list wifi networks
- that can be sensed by the device. The sensed network access points are packed as a list-based
- data model and can be retrieved from WifiManager::networks. Here we also set a custom item
- delegate and connect to WifiManager::networkStateChanged signal.
-
- \snippet wifi/wifi-qml/WifiScanner.qml 0
-
- \section1 Creating a Delegate
-
- The wifi network model has many data roles that describe the different properties of wifi networks.
- This data can be used by an application to list detailed network information and/or to set up
- WifiConfiguration objects. We use these network data roles in our delegate for listing
- ssid, bssid, supported security protocols and for signal strengh representation.
-
- \snippet wifi/wifi-qml/WifiScanner.qml 1
-
- \section1 Connecting To a Selected Network
-
- WifiConfiguration element will be used to describe the network that we want to connect to,
- selected from the network list.
-
- \snippet wifi/wifi-qml/WifiScanner.qml 2
-
- When \uicontrol Connect button is clicked we set the network name and password properties on
- the \c config and pass it to WifiManager::connect, which sets up a wifi connection behind-the-scenes.
- During this operation or whenever there are changes in the network state, QWifiManager provides
- asynchronous QWifiManager::NetworkState change events.
-
- \snippet wifi/wifi-qml/WifiScanner.qml 3
-
- \section1 Connecting To a Known Network
-
- If you are not interested in scanning the environment for wifi network access points and you already
- know the network configuration beforehand, the network scanning, listing and selection steps can be
- entirely skipped. This can be a valid use-case for devices that won't be changing their physical location.
-
- QWifiManager::BackendState change events are delivered asynchronously. Therefore we have to add a signal handler
- that will connect to the network access point after the backend initialization process has been completed,
- if the backend is not already in the initialized state at the time of running this code.
-
- \snippet wifi/wifi-qml/WifiConnectionHandler.qml 0
-
- */
diff --git a/examples/wifi/wifi-qml/main.cpp b/examples/wifi/wifi-qml/main.cpp
deleted file mode 100644
index 32c6b74..0000000
--- a/examples/wifi/wifi-qml/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use the contact form at
-** http://www.qt.io
-**
-** This file is part of Qt Enterprise Embedded.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** the contact form at http://www.qt.io
-**
-****************************************************************************/
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
-
- return app.exec();
-}
diff --git a/examples/wifi/wifi-qml/main.qml b/examples/wifi/wifi-qml/main.qml
deleted file mode 100644
index 9c8726d..0000000
--- a/examples/wifi/wifi-qml/main.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use the contact form at
-** http://www.qt.io
-**
-** This file is part of Qt Enterprise Embedded.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** the contact form at http://www.qt.io
-**
-****************************************************************************/
-import QtQuick 2.3
-import QtQuick.Window 2.2
-
-Window {
- visible: true
- width: Screen.width
- height: Screen.height
- color: "#D9D9D9"
-
- WifiScanner {}
-
- // disable the above line before enabling WifiConnectionHandler
- // WifiConnectionHandler {}
-}
diff --git a/examples/wifi/wifi-qml/qml.qrc b/examples/wifi/wifi-qml/qml.qrc
deleted file mode 100644
index 3c36973..0000000
--- a/examples/wifi/wifi-qml/qml.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- <file>WifiScanner.qml</file>
- <file>WifiConnectionHandler.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/wifi/wifi-qml/wifi-qml.pro b/examples/wifi/wifi-qml/wifi-qml.pro
deleted file mode 100644
index 70fc76a..0000000
--- a/examples/wifi/wifi-qml/wifi-qml.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-
-SOURCES += main.cpp
-
-RESOURCES += qml.qrc
-
-target.path = /data/user/qt
-export(target.path)
-INSTALLS += target