Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 1.0.4 - fixed issue with QML rendering being blocked by BT sc…

…anning at 10.2.1
  • Loading branch information...
commit b7fa0e62c25c4aeea9ab3f4270f206aacb4e09ad 1 parent b7e158a
mdwoolley authored
View
4 HeartMonitor/.project
@@ -63,7 +63,7 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.rim.tad.tools.wst.jsdt.core.javascriptValidator</name>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
@@ -85,7 +85,7 @@
</buildCommand>
</buildSpec>
<natures>
- <nature>com.rim.tad.tools.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
View
4 HeartMonitor/README.md
@@ -24,6 +24,10 @@ the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
* **V1.0.0** - Initial release
* **V1.0.1** - OS Version support for Device Software **10.1.***
* **V1.0.3** - Workaround for problem caused by NULL event_data in early 10.2 builds. Ignore false GATT connect errno 16 errors.
+* **V1.0.4** - Updated FLOT to version 0.8.2.
+ Removed scan timer (redundant)
+ Trigger device scanning on start now performed in C++ instead of QML as this was blocking completion of QML loading/rendering at 10.2.1.
+ Added ActivityIndicator to indicate scanning activity
**Dependencies**
View
3  HeartMonitor/assets/.assets.index
@@ -1,5 +1,5 @@
1
-28
+29
common/DeviceItem.qml
common/SessionItem.qml
cover.qml
@@ -21,6 +21,7 @@ images/dgh.PNG
images/history.png
images/monitor.png
images/scan.png
+images/Thumbs.db
images/white_item_bg.png
LedDigit.qml
main.qml
View
302 HeartMonitor/assets/main.qml
@@ -30,21 +30,36 @@ TabbedPane {
property int p_scan_tab: 1
property int p_history_tab: 2
property int p_about_tab: 3
- property variant digit: [
- "asset:///images/dg0.PNG",
- "asset:///images/dg1.PNG",
- "asset:///images/dg2.PNG",
- "asset:///images/dg3.PNG",
- "asset:///images/dg4.PNG",
- "asset:///images/dg5.PNG",
- "asset:///images/dg6.PNG",
- "asset:///images/dg7.PNG",
- "asset:///images/dg8.PNG",
- "asset:///images/dg9.PNG"
- ]
+ property variant digit: [ "asset:///images/dg0.PNG", "asset:///images/dg1.PNG", "asset:///images/dg2.PNG", "asset:///images/dg3.PNG",
+ "asset:///images/dg4.PNG", "asset:///images/dg5.PNG", "asset:///images/dg6.PNG", "asset:///images/dg7.PNG",
+ "asset:///images/dg8.PNG", "asset:///images/dg9.PNG" ]
property variant dash: "asset:///images/dgh.PNG"
property variant blank: "asset:///images/dgblank.PNG"
+ function onShowTab(tab_index) {
+ switch (tab_index) {
+ case 0:
+ tabbedPane.activeTab = monitor_tab
+ break;
+ case 1:
+ tabbedPane.activeTab = scan_tab
+ break;
+ case 2:
+ tabbedPane.activeTab = about_tab
+ break;
+ default:
+ console.log("QQQQ onShowTab(" + tab_index + ") - invalid tab index");
+ }
+ }
+
+ function startActivityIndicator() {
+ activityIndicator.start();
+ }
+
+ function stopActivityIndicator() {
+ activityIndicator.stop();
+ }
+
function monitor(device_addr, device_name) {
_scan.setRemoteDevice(device_addr);
_hrm.monitorHeartRate(device_addr, device_name);
@@ -68,7 +83,7 @@ TabbedPane {
var image1_url = digit[index1];
var image2_url = digit[index2];
var image3_url = digit[index3];
-
+
if (index1 === 0) {
imgDigit1.imageSource = blank;
} else {
@@ -92,20 +107,19 @@ TabbedPane {
lblMaxHr.text = "Max: " + max_hr;
lblAvgHr.text = "Avg: " + avg_hr;
}
- onCreationCompleted: {
- console.log("YYYY current device name:" + _hrdc.getCurrentDeviceName());
- console.log("YYYY current device addr:" + _hrdc.getCurrentDeviceAddr());
- if (_hrdc.getCurrentDeviceAddr() != "") {
- p_prev_tab = p_monitor_tab;
- tabbedPane.activeTab = monitor_tab;
- } else {
- tabbedPane.activeTab = scan_tab;
- _scan.deviceListing.discover();
- beat_timer.stop();
- scan_timer.start();
- p_prev_tab = p_scan_tab;
- }
- }
+// onCreationCompleted: {
+// console.log("YYYY current device name:" + _hrdc.getCurrentDeviceName());
+// console.log("YYYY current device addr:" + _hrdc.getCurrentDeviceAddr());
+// if (_hrdc.getCurrentDeviceAddr() != "") {
+// p_prev_tab = p_monitor_tab;
+// tabbedPane.activeTab = monitor_tab;
+// } else {
+// tabbedPane.activeTab = scan_tab;
+// _scan.deviceListing.discover();
+// beat_timer.stop();
+// p_prev_tab = p_scan_tab;
+// }
+// }
onActiveTabChanged: {
}
Tab {
@@ -114,7 +128,6 @@ TabbedPane {
imageSource: "asset:///images/monitor.png"
onTriggered: {
beat_timer.start();
- scan_timer.stop();
}
Page {
actionBarVisibility: ChromeVisibility.Visible
@@ -243,30 +256,29 @@ TabbedPane {
}
}
}
-
-
+
// Actions are associated with the History function and will be reinstated in a later release when session history can be saved and restored
-// actions: [
-// ActionItem {
-// id: toggle_hr
-// title: qsTr("Stop and Save")
-// imageSource: "asset:///images/save.png"
-// onTriggered: {
-// if (p_monitoring == 1) {
-// beat_timer.stop();
-// _hrm.stopMonitoringHeartRate();
-// _hrm.saveSession("test");
-// toggle_hr.title = "Start"
-// p_monitoring = 0;
-// } else {
-// beat_timer.start();
-// _hrm.monitorHeartRate(p_dev_addr, p_dev_name);
-// toggle_hr.title = "Stop and Save";
-// p_monitoring = 1;
-// }
-// }
-// }
-// ]
+ // actions: [
+ // ActionItem {
+ // id: toggle_hr
+ // title: qsTr("Stop and Save")
+ // imageSource: "asset:///images/save.png"
+ // onTriggered: {
+ // if (p_monitoring == 1) {
+ // beat_timer.stop();
+ // _hrm.stopMonitoringHeartRate();
+ // _hrm.saveSession("test");
+ // toggle_hr.title = "Start"
+ // p_monitoring = 0;
+ // } else {
+ // beat_timer.start();
+ // _hrm.monitorHeartRate(p_dev_addr, p_dev_name);
+ // toggle_hr.title = "Stop and Save";
+ // p_monitoring = 1;
+ // }
+ // }
+ // }
+ // ]
}
}
Tab {
@@ -274,11 +286,8 @@ TabbedPane {
title: "Scan"
imageSource: "asset:///images/scan.png"
onTriggered: {
- _scan.deviceListing.discover();
- beat_timer.stop();
-// scan_timer.start();
- _scan.deviceListing.update();
- p_prev_tab = p_scan_tab;
+ console.log("QQQQ scan_tab onTriggered");
+ _hrm.scanForDevices();
}
Page {
actionBarVisibility: ChromeVisibility.Visible
@@ -286,6 +295,7 @@ TabbedPane {
layout: StackLayout {
}
verticalAlignment: VerticalAlignment.Fill
+
Label {
id: lblHeading_scan
textStyle {
@@ -307,6 +317,14 @@ TabbedPane {
}
horizontalAlignment: HorizontalAlignment.Center
}
+
+ ActivityIndicator {
+ id: activityIndicator
+ preferredWidth: 300
+ horizontalAlignment: HorizontalAlignment.Center
+ verticalAlignment: VerticalAlignment.Center
+ }
+
Container {
topPadding: 20
leftPadding: 20
@@ -336,99 +354,91 @@ TabbedPane {
}
}
}
-// Timer {
-// id: scan_timer
-// time_limit: 10000
-// onTimeout: {
-// _scan.deviceListing.update();
-// }
-// }
}
}
}
-
-
+
// The History feature is a work in progress and will be completed in a subsequent release
-
-// Tab {
-// id: history_tab
-// title: "History"
-// imageSource: "asset:///images/history.png"
-// onTriggered: {
-// _hrm.stopMonitoringHeartRate();
-// beat_timer.stop();
-// scan_timer.stop();
-// console.log("XXXX requesting loadSavedSessionList");
-// _sessions.loadSavedSessionList();
-// p_prev_tab = p_history_tab;
-// }
-// Page {
-// actionBarVisibility: ChromeVisibility.Visible
-// Container {
-// layout: StackLayout {
-// }
-// verticalAlignment: VerticalAlignment.Fill
-// Label {
-// id: lblHeading_history
-// text: qsTr("History")
-// textStyle {
-// base: SystemDefaults.TextStyles.BigText
-// color: Color.Green
-// }
-// verticalAlignment: VerticalAlignment.Center
-// horizontalAlignment: HorizontalAlignment.Center
-// }
-// Container {
-// topPadding: 20
-// leftPadding: 20
-// rightPadding: 20
-// bottomPadding: 20
-// ListView {
-// dataModel: _sessions.model
-// listItemComponents: [
-// ListItemComponent {
-// type: "listItem"
-// StandardListItem {
-// title: ListItemData.session_name
-// }
-// },
-// ListItemComponent {
-// type: "listItem"
-// StandardListItem {
-// title: ListItemData.session_datetime
-// }
-// }
-// ]
-// onTriggered: {
-// }
-// function itemType(data, indexPath) {
-// if (indexPath.length == 1) {
-// return "header";
-// } else {
-// return "listItem";
-// }
-// }
-// }
-// }
-// Label {
-// id: lblHistoryMessage
-// textStyle {
-// base: SystemDefaults.TextStyles.BodyText
-// color: Color.Green
-// fontFamily: "Courier"
-// lineHeight: 1.1
-// }
-// }
-// Timer {
-// id: history_timer
-// time_limit: 5000
-// onTimeout: {
-// lblHistoryMessage.text = ""
-// }
-// }
-// }
-// }
-// }
+
+ // Tab {
+ // id: history_tab
+ // title: "History"
+ // imageSource: "asset:///images/history.png"
+ // onTriggered: {
+ // _hrm.stopMonitoringHeartRate();
+ // beat_timer.stop();
+ // scan_timer.stop();
+ // console.log("XXXX requesting loadSavedSessionList");
+ // _sessions.loadSavedSessionList();
+ // p_prev_tab = p_history_tab;
+ // }
+ // Page {
+ // actionBarVisibility: ChromeVisibility.Visible
+ // Container {
+ // layout: StackLayout {
+ // }
+ // verticalAlignment: VerticalAlignment.Fill
+ // Label {
+ // id: lblHeading_history
+ // text: qsTr("History")
+ // textStyle {
+ // base: SystemDefaults.TextStyles.BigText
+ // color: Color.Green
+ // }
+ // verticalAlignment: VerticalAlignment.Center
+ // horizontalAlignment: HorizontalAlignment.Center
+ // }
+ // Container {
+ // topPadding: 20
+ // leftPadding: 20
+ // rightPadding: 20
+ // bottomPadding: 20
+ // ListView {
+ // dataModel: _sessions.model
+ // listItemComponents: [
+ // ListItemComponent {
+ // type: "listItem"
+ // StandardListItem {
+ // title: ListItemData.session_name
+ // }
+ // },
+ // ListItemComponent {
+ // type: "listItem"
+ // StandardListItem {
+ // title: ListItemData.session_datetime
+ // }
+ // }
+ // ]
+ // onTriggered: {
+ // }
+ // function itemType(data, indexPath) {
+ // if (indexPath.length == 1) {
+ // return "header";
+ // } else {
+ // return "listItem";
+ // }
+ // }
+ // }
+ // }
+ // Label {
+ // id: lblHistoryMessage
+ // textStyle {
+ // base: SystemDefaults.TextStyles.BodyText
+ // color: Color.Green
+ // fontFamily: "Courier"
+ // lineHeight: 1.1
+ // }
+ // }
+ // Timer {
+ // id: history_timer
+ // time_limit: 5000
+ // onTimeout: {
+ // lblHistoryMessage.text = ""
+ // }
+ // }
+ // }
+ // }
+ // }
Tab {
id: about_tab
title: "About"
@@ -456,7 +466,7 @@ TabbedPane {
}
Label {
id: lblHeading_version
- text: qsTr("V1.0.3")
+ text: qsTr("V1.0.4")
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
}
View
2,116 HeartMonitor/assets/webview/js/jquery.flot.js
1,327 additions, 789 deletions not shown
View
10,312 HeartMonitor/assets/webview/js/jquery.js
5,734 additions, 4,578 deletions not shown
View
2  HeartMonitor/buildnum
@@ -1 +1 @@
-204
+217
View
14 HeartMonitor/config.pri
@@ -97,7 +97,19 @@ lupdate_inclusion {
$$quote($$BASEDIR/../src/*.cxx) \
$$quote($$BASEDIR/../assets/*.qml) \
$$quote($$BASEDIR/../assets/*.js) \
- $$quote($$BASEDIR/../assets/*.qs)
+ $$quote($$BASEDIR/../assets/*.qs) \
+ $$quote($$BASEDIR/../assets/common/*.qml) \
+ $$quote($$BASEDIR/../assets/common/*.js) \
+ $$quote($$BASEDIR/../assets/common/*.qs) \
+ $$quote($$BASEDIR/../assets/images/*.qml) \
+ $$quote($$BASEDIR/../assets/images/*.js) \
+ $$quote($$BASEDIR/../assets/images/*.qs) \
+ $$quote($$BASEDIR/../assets/webview/*.qml) \
+ $$quote($$BASEDIR/../assets/webview/*.js) \
+ $$quote($$BASEDIR/../assets/webview/*.qs) \
+ $$quote($$BASEDIR/../assets/webview/js/*.qml) \
+ $$quote($$BASEDIR/../assets/webview/js/*.js) \
+ $$quote($$BASEDIR/../assets/webview/js/*.qs)
HEADERS += $$quote($$BASEDIR/../src/*.h) \
$$quote($$BASEDIR/../src/*.h++) \
View
6 HeartMonitor/src/BluetoothHandler.cpp
@@ -326,6 +326,8 @@ BluetoothHandler::BluetoothHandler(QObject *obj)
, _deviceListing(new DeviceListing(this))
, _remoteDeviceInfo(new RemoteDeviceInfo(this))
{
+
+ qDebug() << "XXXX constructing BluetoothHandler";
_scanner = this;
if (Utilities::getOSVersion().startsWith("10.0")) {
@@ -438,3 +440,7 @@ void BluetoothHandler::stopHrNotifications() {
}
}
+
+void BluetoothHandler::discover() {
+ _deviceListing->discover();
+}
View
1  HeartMonitor/src/BluetoothHandler.hpp
@@ -49,6 +49,7 @@ class BluetoothHandler: public QObject {
virtual ~BluetoothHandler();
void receiveHrNotifications();
void stopHrNotifications();
+ void discover();
private:
LocalDeviceInfo *_localDeviceInfo;
View
10 HeartMonitor/src/DeviceListing.cpp
@@ -84,7 +84,6 @@ void DeviceListing::discover()
toast.exec();
bt_disc_start_inquiry(BT_INQUIRY_GIAC);
- delay(5);
bt_disc_cancel_inquiry();
toast.setBody(tr("Search completed!"));
@@ -134,7 +133,14 @@ void DeviceListing::discover()
bool DeviceListing::isAHeartRateMonitor(bt_remote_device_t * remoteDevice) {
- qDebug() << "YYYY DeviceListing::isAHeartRateMonitor() - entering";
+ char buffer[128];
+ const int bufferSize = sizeof(buffer);
+ bt_rdev_get_friendly_name(remoteDevice, buffer, bufferSize);
+ QString device_name = QString::fromLatin1(buffer);
+ bt_rdev_get_address(remoteDevice, buffer);
+ QString device_addr = QString::fromLatin1(buffer);
+
+ qDebug() << "YYYY DeviceListing::isAHeartRateMonitor() starting - " << device_name << "[" << device_addr << "] - entering";
bool foundMonitor = false;
View
22 HeartMonitor/src/HeartMonitor.cpp
@@ -73,6 +73,8 @@ HeartMonitor::HeartMonitor(bb::cascades::Application *app)
if (hrdc->getCurrentDeviceAddr() != NULL) {
monitorHeartRate(hrdc->getCurrentDeviceAddr(),hrdc->getCurrentDeviceName());
+ } else {
+ scanForDevices();
}
HrDatabase* db = HrDatabase::getInstance();
db->initDatabase();
@@ -141,3 +143,23 @@ void HeartMonitor::saveSession(QString session_name) {
qDebug() << "XXXX ERROR:database saveSession operation failed";
}
}
+
+void HeartMonitor::showTab(int tab_index)
+{
+ QMetaObject::invokeMethod(_root, "onShowTab", Q_ARG(QVariant, tab_index));
+}
+
+void HeartMonitor::startActivityIndicator() {
+ QMetaObject::invokeMethod(_root, "startActivityIndicator");
+}
+
+void HeartMonitor::stopActivityIndicator() {
+ QMetaObject::invokeMethod(_root, "stopActivityIndicator");
+}
+
+void HeartMonitor::scanForDevices() {
+ showTab(1);
+ startActivityIndicator();
+ _handler->discover();
+ stopActivityIndicator();
+}
View
4 HeartMonitor/src/HeartMonitor.hpp
@@ -42,6 +42,7 @@ Q_OBJECT
Q_INVOKABLE int getMinHr();
Q_INVOKABLE int getMaxHr();
Q_INVOKABLE int getAvgHr();
+ Q_INVOKABLE void scanForDevices();
bb::cascades::Application* _app;
private:
@@ -51,6 +52,9 @@ Q_OBJECT
QFuture<void> *_future;
QFutureWatcher<void> *_watcher;
QMutex _mutex;
+ void showTab(int tab_index);
+ void startActivityIndicator();
+ void stopActivityIndicator();
public slots:
void logHeartRate(const QVariant &message);
View
22 HeartMonitor/translations/HeartMonitor.ts
@@ -14,12 +14,12 @@
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/DeviceListing.cpp" line="90"/>
+ <location filename="../src/DeviceListing.cpp" line="89"/>
<source>Search completed!</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/DeviceListing.cpp" line="121"/>
+ <location filename="../src/DeviceListing.cpp" line="120"/>
<source>Bluetooth Devices Nearby</source>
<translation type="unfinished"></translation>
</message>
@@ -285,42 +285,42 @@
<context>
<name>main</name>
<message>
- <location filename="../assets/main.qml" line="126"/>
+ <location filename="../assets/main.qml" line="139"/>
<source>Heart Rate Monitor</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="295"/>
+ <location filename="../assets/main.qml" line="305"/>
<source>Available Monitors</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="449"/>
+ <location filename="../assets/main.qml" line="459"/>
<source>About HeartMonitor</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="459"/>
- <source>V1.0.1</source>
+ <location filename="../assets/main.qml" line="469"/>
+ <source>V1.0.4</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="465"/>
+ <location filename="../assets/main.qml" line="475"/>
<source>The HeartMonitor application demonstrates how to acquire and use data transmitted by a Bluetooth 4.0 LE heart monitor device</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="476"/>
+ <location filename="../assets/main.qml" line="486"/>
<source>Authors:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="487"/>
+ <location filename="../assets/main.qml" line="497"/>
<source>Martin Woolley (@mdwrim)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../assets/main.qml" line="498"/>
+ <location filename="../assets/main.qml" line="508"/>
<source>John Murray (@jcmrim)</source>
<translation type="unfinished"></translation>
</message>
Please sign in to comment.
Something went wrong with that request. Please try again.