summaryrefslogtreecommitdiffstats
path: root/core/downloadfromdcthread.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-05 19:41:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-11 13:55:41 -0700
commitb14a522f4f308aed41ab49b5529cc10c05168716 (patch)
tree2b3540e4aeefbe9c21ab9d3af1af2b07a4f503e0 /core/downloadfromdcthread.cpp
parent3b993fbaad0738efe54e797b60e4f49270951323 (diff)
downloadsubsurface-b14a522f4f308aed41ab49b5529cc10c05168716.tar.gz
QML UI: move BT handling into core code
This shouldn't be part of the UI (qmlmanager), but part of our overall handling of dive computers and BT devices. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r--core/downloadfromdcthread.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index 20f170125..bd8a637f1 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -99,8 +99,15 @@ void fill_computer_list()
#endif
}
+DCDeviceData *DCDeviceData::m_instance = NULL;
+
DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
{
+ if (m_instance) {
+ qDebug() << "already have an instance of DCDevieData";
+ return;
+ }
+ m_instance = this;
memset(&data, 0, sizeof(data));
data.trip = nullptr;
data.download_table = nullptr;
@@ -108,6 +115,18 @@ DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
data.deviceid = 0;
}
+DCDeviceData *DCDeviceData::instance()
+{
+ if (!m_instance)
+ m_instance = new DCDeviceData();
+ return m_instance;
+}
+
+QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
+{
+ return productList[vendor];
+}
+
DCDeviceData * DownloadThread::data()
{
return m_data;
@@ -222,3 +241,40 @@ device_data_t* DCDeviceData::internalData()
{
return &data;
}
+
+int DCDeviceData::getDetectedVendorIndex()
+{
+#if defined(BT_SUPPORT)
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getVendorIdx" << btDCs.first().vendorIdx;
+ return btDCs.first().vendorIdx;
+ }
+#endif
+ return -1;
+}
+
+int DCDeviceData::getDetectedProductIndex()
+{
+#if defined(BT_SUPPORT)
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getProductIdx" << btDCs.first().productIdx;
+ return btDCs.first().productIdx;
+ }
+#endif
+ return -1;
+}
+
+QString DCDeviceData::getDetectedDeviceAddress()
+{
+#if BT_SUPPORT
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ QString btAddr = btDCs.first().btdi.address().toString();
+ qDebug() << "getBtAddress" << btAddr;
+ return btAddr;
+ }
+ return QString();
+#endif
+}