/* * Copyright 2012 Ruediger Gad * * This file is part of QZeeControl. * * QZeeControl is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * QZeeControl is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with QZeeControl. If not, see . */ import QtQuick 1.1 import com.nokia.meego 1.0 import QtMobility.connectivity 1.2 import qzeecontrol 1.0 Page { tools: commonTools Label { id: label anchors.centerIn: parent text: "Press to connect." } Button{ id: connectButton anchors { horizontalCenter: parent.horizontalCenter top: label.bottom topMargin: 10 } text: "Connect" onClicked: { btDiscovery.discovery = true } } Button{ id: disconnectButton anchors { horizontalCenter: parent.horizontalCenter top: connectButton.bottom topMargin: 10 } text: "Disconnect" onClicked: { btConn.disconnect() } } BluetoothDiscoveryModel{ id: btDiscovery discovery: false minimalDiscovery: true onDiscoveryChanged: { if(discovery){ label.text = "Scanning for devices..." connectButton.enabled = false disconnectButton.enabled = false }else{ connectButton.enabled = true disconnectButton.enabled = false } } onNewServiceDiscovered: { console.log("Service " + service.serviceName + " found on " + service.deviceName + " at address " + service.deviceAddress + " on port " + service.servicePort + ".") //btSocket.service = service btConn.connect(service.deviceAddress, service.servicePort) } } /* BluetoothSocket{ id: btSocket onDataAvailable: { console.log("Data available: " + stringData.charCodeAt(0) + data) } onServiceChanged: { console.log("Service changed. Connecting...") connected = true } onConnectedChanged: { console.log("Connected.") } }*/ BtConnector{ id: btConn onConnected: { connectButton.enabled = false disconnectButton.enabled = true label.text = "Connected." } onDisconnected: { connectButton.enabled = true disconnectButton.enabled = false label.text = "Press to connect." } onStickMoved: { console.log("Stick moved. x: " + x + " y: " + y) } onButtonsChanged: { console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d) } } }