diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-04-06 11:22:53 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-04-07 06:58:54 +0000 |
commit | 8f09b31d98d50e9041d294e96eb0726cdf58f4b5 (patch) | |
tree | 76bd072d2d0ae93009267a7324c2a7d48329ef7c /examples | |
parent | e83df9ffb98981bad53cf077faa3cfde8f0eb5b1 (diff) | |
download | qtconnectivity-8f09b31d98d50e9041d294e96eb0726cdf58f4b5.tar.gz |
Remove heartlistener example
The heartrate game is the replacement example.
Change-Id: Ib51be2467c49075d34e6bea003e69453f0801dfc
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'examples')
25 files changed, 1 insertions, 1895 deletions
diff --git a/examples/bluetooth/bluetooth.pro b/examples/bluetooth/bluetooth.pro index 39a28174..bc18f571 100644 --- a/examples/bluetooth/bluetooth.pro +++ b/examples/bluetooth/bluetooth.pro @@ -12,6 +12,5 @@ qtHaveModule(quick): SUBDIRS += scanner \ picturetransfer \ pingpong \ lowenergyscanner \ - heartlistener \ heartrate-game \ chat diff --git a/examples/bluetooth/heartlistener/assets/Button.qml b/examples/bluetooth/heartlistener/assets/Button.qml deleted file mode 100644 index 51c377b1..00000000 --- a/examples/bluetooth/heartlistener/assets/Button.qml +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id:button - //color: "#3870BA" - - property real buttonWidth: 300 - property real buttonHeight: 80 - property string text: "Button" - - signal buttonClick() - width: click.pressed ? (buttonWidth - 15) : buttonWidth - height: click.pressed ? (buttonHeight - 15) :buttonHeight - - color: click.pressed ? "#3265A7" : "#3870BA" - - border.color: "#F0EBED" - border.width: 5 - radius: 10 - - Text { - id: label - font.pixelSize: 30; font.bold: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - anchors.fill: parent - elide: Text.ElideMiddle - color: "#F0EBED" - text: button.text - } - - MouseArea { - id: click - anchors.fill: parent - onClicked: buttonClick() - } -} diff --git a/examples/bluetooth/heartlistener/assets/Point.qml b/examples/bluetooth/heartlistener/assets/Point.qml deleted file mode 100644 index 0341d11a..00000000 --- a/examples/bluetooth/heartlistener/assets/Point.qml +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: point - - Image { - width: 10; height: 7 - smooth: true - source: "blue_heart_small.png" - } -} diff --git a/examples/bluetooth/heartlistener/assets/blue_heart.png b/examples/bluetooth/heartlistener/assets/blue_heart.png Binary files differdeleted file mode 100644 index 997ee699..00000000 --- a/examples/bluetooth/heartlistener/assets/blue_heart.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/assets/blue_heart_small.png b/examples/bluetooth/heartlistener/assets/blue_heart_small.png Binary files differdeleted file mode 100644 index 7bd1f981..00000000 --- a/examples/bluetooth/heartlistener/assets/blue_heart_small.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/assets/busy_dark.png b/examples/bluetooth/heartlistener/assets/busy_dark.png Binary files differdeleted file mode 100644 index 3a105953..00000000 --- a/examples/bluetooth/heartlistener/assets/busy_dark.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/assets/dialog.qml b/examples/bluetooth/heartlistener/assets/dialog.qml deleted file mode 100644 index bcaf299f..00000000 --- a/examples/bluetooth/heartlistener/assets/dialog.qml +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - opacity: 0.8 - color: "#E0DEDF" - anchors.horizontalCenter: parent.horizontalCenter - - property int hr: heartRate.hr - Text { - text: heartRate.message - color: "#3870BA" - - } - - onHrChanged: { - if (heartRate.hr > 0) { - root.destroy() - } - } -} diff --git a/examples/bluetooth/heartlistener/assets/draw.js b/examples/bluetooth/heartlistener/assets/draw.js deleted file mode 100644 index f884d472..00000000 --- a/examples/bluetooth/heartlistener/assets/draw.js +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -var component; -var size = 0; -var counter = 0; -var difference = 0; - -function start() { - size = heartRate.measurementsSize(); - difference = (plot.width-topbar.width)/size; - console.log(size +" "+ plot.width); - for (var i = 0; i< size; i++) { - var value = heartRate.measurements(i); - - drawIt(value); - counter++; - } -} - -function drawIt(value) { - if (component == null) - component = Qt.createComponent("Point.qml"); - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(plot); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.x = 10+(counter*difference); - console.log(plot.height) - dynamicObject.y = plot.height -value; - - } -} - diff --git a/examples/bluetooth/heartlistener/assets/home.qml b/examples/bluetooth/heartlistener/assets/home.qml deleted file mode 100644 index e77081ae..00000000 --- a/examples/bluetooth/heartlistener/assets/home.qml +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: screen - color: "#F0EBED" - property string message: heartRate.message - onMessageChanged: { - if (heartRate.message != "Scanning for devices..." && heartRate.message != "Low Energy device found. Scanning for more...") { - background.visible = false; - demoMode.visible = true; - } - else { - demoMode.visible = false; - background.visible = true; - } - } - - Rectangle { - id:select - width: parent.width - anchors.top: parent.top - height: 80 - color: "#F0EBED" - border.color: "#3870BA" - border.width: 2 - radius: 10 - - Text { - id: selectText - color: "#3870BA" - font.pixelSize: 34 - anchors.centerIn: parent - text: "Select Device" - } - } - - Rectangle { - id: spinner - width: parent.width - anchors.top: select.bottom - anchors.bottom: demoMode.top - visible: false - color: "#F0EBED" - z: 100 - - Rectangle { - id: inside - anchors.centerIn: parent - Image { - id: background - - width:100 - height:100 - anchors.horizontalCenter: parent.horizontalCenter - - source: "busy_dark.png" - fillMode: Image.PreserveAspectFit - NumberAnimation on rotation { duration: 3000; from:0; to: 360; loops: Animation.Infinite} - } - - Text { - id: infotext - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: background.bottom - text: heartRate.message - color: "#8F8F8F" - } - } - } - - Component.onCompleted: { - heartRate.deviceSearch(); - spinner.visible=true; - } - - ListView { - id: theListView - width: parent.width - onModelChanged: spinner.visible=false - anchors.top: select.bottom - anchors.bottom: demoMode.top - model: heartRate.name - - delegate: Rectangle { - id: box - height:140 - width: parent.width - color: "#3870BA" - border.color: "#F0EBED" - border.width: 5 - radius: 15 - - MouseArea { - anchors.fill: parent - onPressed: { box.color= "#3265A7"; box.height=110} - onClicked: { - heartRate.connectToService(modelData.deviceAddress); - pageLoader.source="monitor.qml"; - } - } - - Text { - id: device - font.pixelSize: 30 - text: modelData.deviceName - anchors.top: parent.top - anchors.topMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - color: "#F0EBED" - } - - Text { - id: deviceAddress - font.pixelSize: 30 - text: modelData.deviceAddress - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - color: "#F0EBED" - } - } - } - - Button { - id:demoMode - buttonWidth: parent.width - buttonHeight: 0.1*parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: scanAgain.top - text: "Run Demo" - onButtonClick: { - heartRate.startDemo(); - pageLoader.source="monitor.qml"; - } - } - - Button { - id:scanAgain - buttonWidth: parent.width - buttonHeight: 0.1*parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - text: "Menu" - onButtonClick: pageLoader.source="main.qml" - } -} diff --git a/examples/bluetooth/heartlistener/assets/main.qml b/examples/bluetooth/heartlistener/assets/main.qml deleted file mode 100644 index 89d9f600..00000000 --- a/examples/bluetooth/heartlistener/assets/main.qml +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 400 - height: 600 - id: begin - - Rectangle { - color: "#F0EBED" - anchors.fill: parent - Rectangle { - id: about - width: 0.75*parent.width - height: 0.1*parent.height - anchors.top: parent.top - anchors.topMargin: 20 - anchors.horizontalCenter: parent.horizontalCenter - color: "#F0EBED" - border.color: "#3870BA" - border.width: 2 - radius: 10 - Text { - id: aboutinfo - anchors.centerIn: parent - color: "#3870BA" - text: "Welcome to the Heart Listener Application" - } - } - - Button { - id:call - buttonWidth: 0.75*parent.width - buttonHeight: 0.15*parent.height - anchors.centerIn: parent - text: "Scan for Devices" - onButtonClick: pageLoader.source="home.qml" - } - } - - Loader { - id: pageLoader - anchors.fill: parent - } -} diff --git a/examples/bluetooth/heartlistener/assets/monitor.qml b/examples/bluetooth/heartlistener/assets/monitor.qml deleted file mode 100644 index 1d74ad84..00000000 --- a/examples/bluetooth/heartlistener/assets/monitor.qml +++ /dev/null @@ -1,154 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: screenMonitor - color: "#F0EBED" - - Button { - id:menu - buttonWidth: parent.width - buttonHeight: 0.1 * parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - text: "Menu" - onButtonClick: { - heartRate.disconnectService(); - pageLoader.source="home.qml"; - } - } - - Text { - id: hrValue - font.pointSize: 24; font.bold: true - anchors.top:menu.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 25 - - color: "#3870BA" - text: heartRate.hr - onTextChanged: { - if (heartRate.hr > 0 && updatei != null && heartRate.numDevices() > 0) { - updatei.destroy() - } - } - } - - Rectangle { - id: updatei - width: parent.width - height: 80 - anchors.bottom: stop.top - - color: "#F0EBED" - border.color: "#3870BA" - border.width: 2 - - Text { - id: logi - text: heartRate.message - anchors.centerIn: updatei - color: "#3870BA" - } - } - - Image { - id: background - width: 300 - height: width - anchors.centerIn: parent - source: "blue_heart.png" - fillMode: Image.PreserveAspectFit - NumberAnimation on width { - running: heartRate.hr > 0; - duration: heartRate.hr/60*250; - from:300; to: 350; - loops: Animation.Infinite; - } - - ParticleSystem { - id: systwo - anchors.fill: parent - - ImageParticle { - system: systwo - id: cptwo - source: "star.png" - colorVariation: 0.4 - color: "#000000FF" - } - - Emitter { - //burst on click - id: burstytwo - system: systwo - enabled: true - x: 160 - y: 150 - emitRate: heartRate.hr*100 - maximumEmitted: 4000 - acceleration: AngleDirection {angleVariation: 360; magnitude: 360; } - size: 4 - endSize: 8 - sizeVariation: 4 - } - - - } - - } - - Button { - id:stop - buttonWidth: parent.width - buttonHeight: 0.1*parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - text: "Stop Monitoring" - onButtonClick: { - burstytwo.enabled = false; - heartRate.disconnectService(); - pageLoader.source = "results.qml"; - } - } -} diff --git a/examples/bluetooth/heartlistener/assets/results.qml b/examples/bluetooth/heartlistener/assets/results.qml deleted file mode 100644 index 301762c3..00000000 --- a/examples/bluetooth/heartlistener/assets/results.qml +++ /dev/null @@ -1,291 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "draw.js" as DrawGraph - -Rectangle { - id: results - color: "#F0EBED" - - Component.onCompleted: heartRate.obtainResults() - - function getTime() { - var t = heartRate.time; - var min = Math.floor(t/60); - var sec = t%60; - var r = min + " min " + sec + " sec "; - return r; - } - - function drawGraph() { - var b = plot.height/200; - var ctx = canvas1.getContext('2d'); - ctx.beginPath() - ctx.moveTo(10, plot.height- (b*60)) - var size = heartRate.measurementsSize(); - var difference = (plot.width-topbar.width)/size; - - for (var i = 0; i< size; i++) { - var value = heartRate.measurements(i); - if (i == 0) { - ctx.moveTo(10+2, (plot.height- (value*b) + 2)); - ctx.rect((10 + i*difference), (plot.height- (value*b)), 4, 4); - - } - else { - ctx.lineTo((10+2 + i*difference), (plot.height- (value*b) + 2)); - ctx.rect((10 + i*difference), (plot.height- (value*b)), 4, 4); - } - - } - ctx.fillStyle = "#3870BA" - ctx.fill() - ctx.strokeStyle = "#3870BA" - ctx.stroke() - ctx.closePath() - } - - Rectangle { - id: res - width: parent.width - anchors.top: parent.top - height: 80 - color: "#F0EBED" - border.color: "#3870BA" - border.width: 2 - radius: 10 - Text { - id: restText - color: "#3870BA" - font.pixelSize: 34 - anchors.centerIn: parent - text: "Results" - } - } - - Text { - id: topbar - text: "200" - anchors.left: parent.left - anchors.top: res.bottom - anchors.rightMargin: 4 - color: "#3870BA" - z: 50 - } - - Rectangle { - id: level - anchors.left: topbar.right - - anchors.top: res.bottom - height: ((results.height -(res.height + menuLast.height + start.height ))/2) - width: 3 - color: "#3870BA" - } - - Text { - id: middlebar - anchors.verticalCenter: level.verticalCenter - anchors.left: parent.left - text: "100" - color: "#3870BA" - z: 50 - } - - Rectangle{ - id: downlevel - anchors.bottom: cover.top - width: parent.width - anchors.left: level.right - height: 3 - color: "#3870BA" - z: 50 - } - - Rectangle { - id: plot - anchors.left: level.right - anchors.leftMargin: 15 - width: results.width - height: ((parent.height-(res.height+menuLast.height+start.height))/2) - - anchors.top: res.bottom - color: "#F0EBED" - Canvas { - id: canvas1 - anchors.fill: parent - z: 150 - onPaint: drawGraph() - } - } - - Rectangle { - id: cover - anchors.top: plot.bottom - anchors.bottom: menuLast.top - width: parent.width - height: ((parent.height-(res.height+menuLast.height+start.height))/2) - color: "#F0EBED" - radius: 10 - border.color: "#3870BA" - border.width: 2 - - Flickable { - id: scroll - anchors.fill: parent - anchors.margins: 5 - clip: true - contentWidth: parent.width - contentHeight: stresult.height - - Rectangle { - id: stresult - width: parent.width - height: (results.height - (res.height + menuLast.height + start.height - 100)) - color: "#F0EBED" - radius: 10 - - Text { - id: averageHR - font.pixelSize: 30; - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - - color: "#3870BA" - text: "Average Heart Rate" - } - - Text { - id: averageHRt - font.pixelSize: 40; font.bold: true - anchors.top: averageHR.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: heartRate.average - } - - Text { - id: time - font.pixelSize: 30; - anchors.top: averageHRt.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: "Seconds measured:" - } - - Text { - id: timet - font.pixelSize: 40; font.bold: true - anchors.top: time.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: getTime() - } - Text { - id: maxi - font.pixelSize: 30; - anchors.top: timet.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 20 - color: "#3870BA" - text: " Max || Min " - } - - Text { - id: mini - font.pixelSize: 40; font.bold: true - anchors.top:maxi.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: " " + heartRate.maxHR + " || " + heartRate.minHR - } - - Text { - id: calories - font.pixelSize: 30; - anchors.top: mini.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: " Calories " - } - - Text { - id: caloriestext - font.pixelSize: 40; font.bold: true - anchors.top:calories.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 10 - color: "#3870BA" - text: heartRate.calories.toFixed(3) - } - } - } - } - - Button { - id:menuLast - buttonWidth: parent.width - buttonHeight: 0.1*parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: start.top - text: "Menu" - onButtonClick: { pageLoader.source="main.qml"} - } - - Button { - id:start - buttonWidth: parent.width - buttonHeight: 0.1*parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - text: "Start Monitoring" - onButtonClick: { - heartRate.connectToService(heartRate.deviceAddress()); - pageLoader.source="monitor.qml"; - } - } -} diff --git a/examples/bluetooth/heartlistener/assets/star.png b/examples/bluetooth/heartlistener/assets/star.png Binary files differdeleted file mode 100644 index defbde53..00000000 --- a/examples/bluetooth/heartlistener/assets/star.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/deviceinfo.cpp b/examples/bluetooth/heartlistener/deviceinfo.cpp deleted file mode 100644 index cfddf56d..00000000 --- a/examples/bluetooth/heartlistener/deviceinfo.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qbluetoothuuid.h> - -#include "deviceinfo.h" - -DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &info): - QObject(), m_device(info) -{ -} - -QBluetoothDeviceInfo DeviceInfo::getDevice() const -{ - return m_device; -} - -QString DeviceInfo::getAddress() const -{ -#ifdef Q_OS_MAC - // workaround for Core Bluetooth: - return m_device.deviceUuid().toString(); -#else - return m_device.address().toString(); -#endif -} - -void DeviceInfo::setDevice(const QBluetoothDeviceInfo &device) -{ - m_device = device; - emit deviceChanged(); -} diff --git a/examples/bluetooth/heartlistener/deviceinfo.h b/examples/bluetooth/heartlistener/deviceinfo.h deleted file mode 100644 index 636f7905..00000000 --- a/examples/bluetooth/heartlistener/deviceinfo.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DEVICEINFO_H -#define DEVICEINFO_H - -#include <QString> -#include <QObject> -#include <qbluetoothdeviceinfo.h> -#include <qbluetoothaddress.h> - -class DeviceInfo: public QObject -{ - Q_OBJECT - Q_PROPERTY(QString deviceName READ getName NOTIFY deviceChanged) - Q_PROPERTY(QString deviceAddress READ getAddress NOTIFY deviceChanged) -public: - DeviceInfo(const QBluetoothDeviceInfo &device); - void setDevice(const QBluetoothDeviceInfo &device); - QString getName() const { return m_device.name(); } - QString getAddress() const; - QBluetoothDeviceInfo getDevice() const; - -signals: - void deviceChanged(); - -private: - QBluetoothDeviceInfo m_device; -}; - -#endif // DEVICEINFO_H diff --git a/examples/bluetooth/heartlistener/doc/images/heartratefound.png b/examples/bluetooth/heartlistener/doc/images/heartratefound.png Binary files differdeleted file mode 100644 index 89517aa4..00000000 --- a/examples/bluetooth/heartlistener/doc/images/heartratefound.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/doc/images/heartratemonitor.png b/examples/bluetooth/heartlistener/doc/images/heartratemonitor.png Binary files differdeleted file mode 100644 index ed51ba86..00000000 --- a/examples/bluetooth/heartlistener/doc/images/heartratemonitor.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/doc/images/heartrateresults.png b/examples/bluetooth/heartlistener/doc/images/heartrateresults.png Binary files differdeleted file mode 100644 index 8180d1a4..00000000 --- a/examples/bluetooth/heartlistener/doc/images/heartrateresults.png +++ /dev/null diff --git a/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc b/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc deleted file mode 100644 index 2bb59ae1..00000000 --- a/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example heartlistener - \title Bluetooth Low Energy Heart Listener Example - \brief An example demonstrating the interaction with a Bluetooth Low Energy Heart Rate - device/service. The example demonstrates the use of all Qt Bluetooth - Low Energy classes. - - The Bluetooth Low Energy Heart Listener Example shows how to develop a Bluetooth - Low Energy application using the Qt Bluetooth API. The application covers - the scanning for Bluetooth Low Energy devices, connecting to a Heart Rate service - on the device, writing characteristics and descriptors and receiving updates from device - once the heart rate has changed. - - \image heartratemonitor.png - - The example introduces the following Qt classes: - - \list - \li \l QLowEnergyController - \li \l QLowEnergyService - \li \l QLowEnergyCharacteristic - \li \l QLowEnergyDescriptor - \endlist - - A Bluetooth Low Energy device with a Heart Rate - service is required for this application to work. An alternative might be a programmable - Bluetooth Low Energy device which might simulate the service. You can also use the - \l {heartrate-server} {Heart Rate server} example for that purpose. - If no such device can be found, the example uses a demo mode which creates and displays - random values. - - The \l {lowenergyscanner}{Bluetooth Low Energy Scanner} example might be more suitable - if a heart rate device is not available. The scanner example works with any type of Bluetooth - Low Energy peripheral device. - - \include examples-run.qdocinc - - \section1 Visual Tour - - The application searches for all Bluetooth Low Energy peripheral devices in the vicinity. - It is assumed that the remote devices advertise their presence. The found devices are - presented in a list. Note that it shows all Bluetooth Low Energy devices even those which - do not offer a Heart Rate service. - - \image heartratefound.png - - After the user has selected a target device, the example connects to its Heart Rate service - if one is available. It automatically enables notification updates for the Heart Rate value - and presents the current value on the screen. - - \image heartratemonitor.png - - Once the monitoring process is canceled, a small graph presents a summary of the received - values. - - \image heartrateresults.png -*/ - diff --git a/examples/bluetooth/heartlistener/heartlistener.pro b/examples/bluetooth/heartlistener/heartlistener.pro deleted file mode 100644 index 7856b64e..00000000 --- a/examples/bluetooth/heartlistener/heartlistener.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = app -TARGET = heartlistener - -QT += quick bluetooth - -# Input -HEADERS += deviceinfo.h \ - heartrate.h -SOURCES += deviceinfo.cpp \ - heartrate.cpp \ - main.cpp - -OTHER_FILES += assets/*.qml \ - assets/*.js - -RESOURCES += \ - resources.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/bluetooth/heartlistener -INSTALLS += target diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp deleted file mode 100644 index c206b69e..00000000 --- a/examples/bluetooth/heartlistener/heartrate.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "heartrate.h" - -#include <QtEndian> - -HeartRate::HeartRate(): - m_currentDevice(QBluetoothDeviceInfo()), foundHeartRateService(false), - m_max(0), m_min(0), calories(0), m_control(0), timer(0), - m_service(0) -{ - //! [devicediscovery-1] - m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); - m_deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(5000); - - connect(m_deviceDiscoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), - this, SLOT(addDevice(const QBluetoothDeviceInfo&))); - connect(m_deviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), - this, SLOT(deviceScanError(QBluetoothDeviceDiscoveryAgent::Error))); - connect(m_deviceDiscoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished())); - //! [devicediscovery-1] - - // initialize random seed for demo mode - qsrand(QTime::currentTime().msec()); -} - -HeartRate::~HeartRate() -{ - qDeleteAll(m_devices); - m_devices.clear(); -} - -void HeartRate::deviceSearch() -{ - qDeleteAll(m_devices); - m_devices.clear(); - //! [devicediscovery-2] - m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); - //! [devicediscovery-2] - setMessage("Scanning for devices..."); -} - -//! [devicediscovery-3] -void HeartRate::addDevice(const QBluetoothDeviceInfo &device) -{ - if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { - qWarning() << "Discovered LE Device name: " << device.name() << " Address: " - << device.address().toString(); -//! [devicediscovery-3] - DeviceInfo *dev = new DeviceInfo(device); - m_devices.append(dev); - setMessage("Low Energy device found. Scanning for more..."); -//! [devicediscovery-4] - } - //... -} -//! [devicediscovery-4] - -void HeartRate::scanFinished() -{ - if (m_devices.size() == 0) - setMessage("No Low Energy devices found"); - Q_EMIT nameChanged(); -} - -void HeartRate::deviceScanError(QBluetoothDeviceDiscoveryAgent::Error error) -{ - if (error == QBluetoothDeviceDiscoveryAgent::PoweredOffError) - setMessage("The Bluetooth adaptor is powered off, power it on before doing discovery."); - else if (error == QBluetoothDeviceDiscoveryAgent::InputOutputError) - setMessage("Writing or reading from the device resulted in an error."); - else - setMessage("An unknown error has occurred."); -} - - -void HeartRate::setMessage(QString message) -{ - m_info = message; - Q_EMIT messageChanged(); -} - -QString HeartRate::message() const -{ - return m_info; -} - -QVariant HeartRate::name() -{ - return QVariant::fromValue(m_devices); -} - -void HeartRate::connectToService(const QString &address) -{ - m_measurements.clear(); - - bool deviceFound = false; - for (int i = 0; i < m_devices.size(); i++) { - if (((DeviceInfo*)m_devices.at(i))->getAddress() == address ) { - m_currentDevice.setDevice(((DeviceInfo*)m_devices.at(i))->getDevice()); - setMessage("Connecting to device..."); - deviceFound = true; - break; - } - } - // we are running demo mode - if (!deviceFound) { - startDemo(); - return; - } - - if (m_control) { - m_control->disconnectFromDevice(); - delete m_control; - m_control = 0; - - } - //! [Connect signals] - m_control = new QLowEnergyController(m_currentDevice.getDevice(), this); - connect(m_control, SIGNAL(serviceDiscovered(QBluetoothUuid)), - this, SLOT(serviceDiscovered(QBluetoothUuid))); - connect(m_control, SIGNAL(discoveryFinished()), - this, SLOT(serviceScanDone())); - connect(m_control, SIGNAL(error(QLowEnergyController::Error)), - this, SLOT(controllerError(QLowEnergyController::Error))); - connect(m_control, SIGNAL(connected()), - this, SLOT(deviceConnected())); - connect(m_control, SIGNAL(disconnected()), - this, SLOT(deviceDisconnected())); - - m_control->connectToDevice(); - //! [Connect signals] -} - -//! [Connecting to service] - -void HeartRate::deviceConnected() -{ - m_control->discoverServices(); -} - -void HeartRate::deviceDisconnected() -{ - setMessage("Heart Rate service disconnected"); - qWarning() << "Remote device disconnected"; -} - -//! [Connecting to service] - -//! [Filter HeartRate service 1] -void HeartRate::serviceDiscovered(const QBluetoothUuid &gatt) -{ - if (gatt == QBluetoothUuid(QBluetoothUuid::HeartRate)) { - setMessage("Heart Rate service discovered. Waiting for service scan to be done..."); - foundHeartRateService = true; - } -} -//! [Filter HeartRate service 1] - -void HeartRate::serviceScanDone() -{ - delete m_service; - m_service = 0; - - //! [Filter HeartRate service 2] - if (foundHeartRateService) { - setMessage("Connecting to service..."); - m_service = m_control->createServiceObject( - QBluetoothUuid(QBluetoothUuid::HeartRate), this); - } - - if (!m_service) { - setMessage("Heart Rate Service not found."); - return; - } - - connect(m_service, SIGNAL(stateChanged(QLowEnergyService::ServiceState)), - this, SLOT(serviceStateChanged(QLowEnergyService::ServiceState))); - connect(m_service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)), - this, SLOT(updateHeartRateValue(QLowEnergyCharacteristic,QByteArray))); - connect(m_service, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)), - this, SLOT(confirmedDescriptorWrite(QLowEnergyDescriptor,QByteArray))); - - m_service->discoverDetails(); - //! [Filter HeartRate service 2] -} - -void HeartRate::disconnectService() -{ - foundHeartRateService = false; - m_stop = QDateTime::currentDateTime(); - - if (m_devices.isEmpty()) { - if (timer) - timer->stop(); - return; - } - - //disable notifications before disconnecting - if (m_notificationDesc.isValid() && m_service - && m_notificationDesc.value() == QByteArray::fromHex("0100")) - { - m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0000")); - } else { - m_control->disconnectFromDevice(); - delete m_service; - m_service = 0; - } -} - -//! [Error handling] -void HeartRate::controllerError(QLowEnergyController::Error error) -{ - setMessage("Cannot connect to remote device."); - qWarning() << "Controller Error:" << error; -} -//! [Error handling] - - -//! [Find HRM characteristic] -void HeartRate::serviceStateChanged(QLowEnergyService::ServiceState s) -{ - switch (s) { - case QLowEnergyService::ServiceDiscovered: - { - const QLowEnergyCharacteristic hrChar = m_service->characteristic( - QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement)); - if (!hrChar.isValid()) { - setMessage("HR Data not found."); - break; - } - - m_notificationDesc = hrChar.descriptor( - QBluetoothUuid::ClientCharacteristicConfiguration); - if (m_notificationDesc.isValid()) { - m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100")); - setMessage("Measuring"); - m_start = QDateTime::currentDateTime(); - } - - break; - } - default: - //nothing for now - break; - } -} -//! [Find HRM characteristic] - -void HeartRate::serviceError(QLowEnergyService::ServiceError e) -{ - switch (e) { - case QLowEnergyService::DescriptorWriteError: - setMessage("Cannot obtain HR notifications"); - break; - default: - qWarning() << "HR service error:" << e; - } -} - -//! [Reading value 1] -void HeartRate::updateHeartRateValue(const QLowEnergyCharacteristic &c, - const QByteArray &value) -{ - // ignore any other characteristic change -> shouldn't really happen though - if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement)) - return; - - - const quint8 *data = reinterpret_cast<const quint8 *>(value.constData()); - quint8 flags = data[0]; - - //Heart Rate - if (flags & 0x1) { // HR 16 bit? otherwise 8 bit - const quint16 heartRate = qFromLittleEndian<quint16>(data[1]); - //qDebug() << "16 bit HR value:" << heartRate; - m_measurements.append(heartRate); - } else { - const quint8 *heartRate = &data[1]; - m_measurements.append(*heartRate); - //qDebug() << "8 bit HR value:" << *heartRate; - } - - //Energy Expended - if (flags & 0x8) { - int index = (flags & 0x1) ? 5 : 3; - const quint16 energy = qFromLittleEndian<quint16>(data[index]); - qDebug() << "Used Energy:" << energy; - } - //! [Reading value 1] - - Q_EMIT hrChanged(); -//! [Reading value 2] -} -//! [Reading value 2] - -void HeartRate::confirmedDescriptorWrite(const QLowEnergyDescriptor &d, - const QByteArray &value) -{ - if (d.isValid() && d == m_notificationDesc && value == QByteArray::fromHex("0000")) { - //disabled notifications -> assume disconnect intent - m_control->disconnectFromDevice(); - delete m_service; - m_service = 0; - } -} - -int HeartRate::hR() const -{ - if (m_measurements.isEmpty()) - return 0; - return m_measurements.last(); -} - -void HeartRate::obtainResults() -{ - Q_EMIT timeChanged(); - Q_EMIT averageChanged(); - Q_EMIT caloriesChanged(); -} - -int HeartRate::time() -{ - return m_start.secsTo(m_stop); -} - -int HeartRate::maxHR() const -{ - return m_max; -} - -int HeartRate::minHR() const -{ - return m_min; -} - -float HeartRate::average() -{ - if (m_measurements.size() == 0) { - return 0; - } else { - m_max = 0; - m_min = 1000; - int sum = 0; - for (int i = 0; i < m_measurements.size(); i++) { - sum += (int) m_measurements.value(i); - if (((int)m_measurements.value(i)) > m_max) - m_max = (int)m_measurements.value(i); - if (((int)m_measurements.value(i)) < m_min) - m_min = (int)m_measurements.value(i); - } - return sum/m_measurements.size(); - } -} - -int HeartRate::measurements(int index) const -{ - if (index > m_measurements.size()) - return 0; - else - return (int)m_measurements.value(index); -} - -int HeartRate::measurementsSize() const -{ - return m_measurements.size(); -} - -QString HeartRate::deviceAddress() const -{ - return m_currentDevice.getAddress(); -} - -float HeartRate::caloriesCalculation() -{ - calories = ((-55.0969 + (0.6309 * average()) + (0.1988 * 94) + (0.2017 * 24)) / 4.184) * 60 * time()/3600 ; - return calories; -} - -int HeartRate::numDevices() const -{ - return m_devices.size(); -} - -void HeartRate::startDemo() -{ - m_start = QDateTime::currentDateTime(); - if (!timer) { - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(receiveDemo())); - } - timer->start(1000); - setMessage("This is Demo mode"); -} - -void HeartRate::receiveDemo() -{ - m_measurements.append(randomPulse()); - Q_EMIT hrChanged(); -} - -int HeartRate::randomPulse() const -{ - // random number between 50 and 70 - return qrand() % (70 - 50) + 50; -} diff --git a/examples/bluetooth/heartlistener/heartrate.h b/examples/bluetooth/heartlistener/heartrate.h deleted file mode 100644 index 1766ce3a..00000000 --- a/examples/bluetooth/heartlistener/heartrate.h +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef HEARTRATE_H -#define HEARTRATE_H - -#include "deviceinfo.h" - -#include <QString> -#include <QDebug> -#include <QDateTime> -#include <QVector> -#include <QTimer> -#include <QBluetoothDeviceDiscoveryAgent> -#include <QBluetoothDeviceInfo> -#include <QLowEnergyController> -#include <QLowEnergyService> - - -QT_USE_NAMESPACE -class HeartRate: public QObject -{ - Q_OBJECT - Q_PROPERTY(QVariant name READ name NOTIFY nameChanged) - Q_PROPERTY(QString message READ message NOTIFY messageChanged) - Q_PROPERTY(int hr READ hR NOTIFY hrChanged) - Q_PROPERTY(int maxHR READ maxHR NOTIFY averageChanged) - Q_PROPERTY(int minHR READ minHR NOTIFY averageChanged) - Q_PROPERTY(float average READ average NOTIFY averageChanged) - Q_PROPERTY(int time READ time NOTIFY timeChanged) - Q_PROPERTY(float calories READ caloriesCalculation NOTIFY caloriesChanged) - -public: - HeartRate(); - ~HeartRate(); - void setMessage(QString message); - QString message() const; - QVariant name(); - int hR() const; - int time(); - float average(); - int maxHR() const; - int minHR() const; - float caloriesCalculation(); - -public slots: - void deviceSearch(); - void connectToService(const QString &address); - void disconnectService(); - void startDemo(); - - void obtainResults(); - int measurements(int index) const; - int measurementsSize() const; - QString deviceAddress() const; - int numDevices() const; - -private slots: - //QBluetothDeviceDiscoveryAgent - void addDevice(const QBluetoothDeviceInfo&); - void scanFinished(); - void deviceScanError(QBluetoothDeviceDiscoveryAgent::Error); - - //QLowEnergyController - void serviceDiscovered(const QBluetoothUuid &); - void serviceScanDone(); - void controllerError(QLowEnergyController::Error); - void deviceConnected(); - void deviceDisconnected(); - - - //QLowEnergyService - void serviceStateChanged(QLowEnergyService::ServiceState s); - void updateHeartRateValue(const QLowEnergyCharacteristic &c, - const QByteArray &value); - void confirmedDescriptorWrite(const QLowEnergyDescriptor &d, - const QByteArray &value); - void serviceError(QLowEnergyService::ServiceError e); - - //DemoMode - void receiveDemo(); - -Q_SIGNALS: - void messageChanged(); - void nameChanged(); - void hrChanged(); - void averageChanged(); - void timeChanged(); - void caloriesChanged(); - -private: - int randomPulse() const; - - DeviceInfo m_currentDevice; - QBluetoothDeviceDiscoveryAgent *m_deviceDiscoveryAgent; - QLowEnergyDescriptor m_notificationDesc; - QList<QObject*> m_devices; - QString m_info; - bool foundHeartRateService; - QVector<quint16> m_measurements; - QDateTime m_start; - QDateTime m_stop; - int m_max; - int m_min; - float calories; - QLowEnergyController *m_control; - QTimer *timer; // for demo application - QLowEnergyService *m_service; -}; - -#endif // HEARTRATE_H diff --git a/examples/bluetooth/heartlistener/main.cpp b/examples/bluetooth/heartlistener/main.cpp deleted file mode 100644 index 7aa17080..00000000 --- a/examples/bluetooth/heartlistener/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QLoggingCategory> -#include <QQmlContext> -#include <QGuiApplication> -#include <QQuickView> -#include "heartrate.h" - -int main(int argc, char *argv[]) -{ - //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); - QGuiApplication app(argc, argv); - - HeartRate heartRate; - QQuickView *view = new QQuickView; - view->rootContext()->setContextProperty("heartRate", &heartRate); - view->setSource(QUrl("qrc:/assets/main.qml")); - view->setResizeMode(QQuickView::SizeRootObjectToView); - view->show(); - return app.exec(); - -} diff --git a/examples/bluetooth/heartlistener/resources.qrc b/examples/bluetooth/heartlistener/resources.qrc deleted file mode 100644 index ac6f9c83..00000000 --- a/examples/bluetooth/heartlistener/resources.qrc +++ /dev/null @@ -1,16 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>assets/blue_heart.png</file> - <file>assets/busy_dark.png</file> - <file>assets/Button.qml</file> - <file>assets/dialog.qml</file> - <file>assets/draw.js</file> - <file>assets/home.qml</file> - <file>assets/main.qml</file> - <file>assets/monitor.qml</file> - <file>assets/Point.qml</file> - <file>assets/results.qml</file> - <file>assets/star.png</file> - <file>assets/blue_heart_small.png</file> - </qresource> -</RCC> diff --git a/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc b/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc index 22c6fcd1..34f1b633 100644 --- a/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc +++ b/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc @@ -51,7 +51,7 @@ \endlist The example implements a server application, which means it has no graphical user interface. - To visualize what it is doing, you can use the \l {heartlistener}{Heart Listener} + To visualize what it is doing, you can use the \l {heartrate-game}{Heart Rate Game} example, which is basically the client-side counterpart to this application. \note On Linux, advertising requires privileged access, so you need to run |