2 * Copyright 2012 Ruediger Gad
4 * This file is part of QZeeControl.
6 * QZeeControl is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * QZeeControl is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with QZeeControl. If not, see <http://www.gnu.org/licenses/>.
21 import com.nokia.meego 1.0
22 import QtMobility.connectivity 1.2
23 import qzeecontrol 1.0
30 anchors{bottom: connectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
32 text: "Press to connect."
37 anchors{bottom: disconnectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
42 btDiscovery.discovery = true
48 anchors{bottom: buttonRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
59 anchors.centerIn: parent
86 anchors{top: buttonRow.bottom; topMargin: 10; horizontalCenter: parent.horizontalCenter}
99 x: moveArea.x + (moveArea.width * 0.5) + btConn.x
100 y: moveArea.y + (moveArea.height * 0.5) + btConn.y
102 onXChanged: console.log("New x: " + x)
103 onYChanged: console.log("New y: " + y)
108 BluetoothDiscoveryModel{
112 minimalDiscovery: true
114 onDiscoveryChanged: {
116 label.text = "Scanning for devices..."
117 connectButton.enabled = false
118 disconnectButton.enabled = false
120 connectButton.enabled = true
121 disconnectButton.enabled = false
125 onNewServiceDiscovered: {
126 console.log("Service " + service.serviceName + " found on " + service.deviceName + " at address " + service.deviceAddress + " on port " + service.servicePort + ".")
127 //btSocket.service = service
128 btConn.connect(service.deviceAddress, service.servicePort)
137 console.log("Data available: " + stringData.charCodeAt(0) + data)
141 console.log("Service changed. Connecting...")
145 onConnectedChanged: {
146 console.log("Connected.")
154 connectButton.enabled = false
155 disconnectButton.enabled = true
156 label.text = "Connected."
160 connectButton.enabled = true
161 disconnectButton.enabled = false
162 label.text = "Press to connect."
166 console.log("Stick moved. x: " + x + " y: " + y)
170 console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d)
171 labelA.color = a ? "red" : "blue"
172 labelB.color = b ? "red" : "blue"
173 labelC.color = c ? "red" : "blue"
174 labelD.color = d ? "red" : "blue"