aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-06-22 11:27:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-22 20:19:06 +0900
commitac750bbf20a187a86e6b1950673e5fa0a1fd53ac (patch)
tree67151618280524c243ffd8409b8983ad62fca9eb /core
parent05435d64aa3a019c3a3d05ca6a112b44daf5195d (diff)
downloadsubsurface-ac750bbf20a187a86e6b1950673e5fa0a1fd53ac.tar.gz
mobile: prune DC list to download from
Currently, only a small number of dive computers can be downloaded from the mobile app. Only present the supported ones to the user. So, currently restricted to classic BT. Not sure about FTDI support at this point. Version 2 of the same commit after review from Dirk. Fundamentally, support is as follows: Android: BT, BLE, and FTDI. iOS: BLE only. For all other OSses, this commit has no changes. As the BLE backend is not yet ready, no support on iOS yet. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'core')
-rw-r--r--core/downloadfromdcthread.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index 98130b730..8810799d9 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -4,6 +4,7 @@
QStringList vendorList;
QHash<QString, QStringList> productList;
+static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile
QMap<QString, dc_descriptor_t *> descriptorLookup;
static QString str_error(const char *fmt, ...)
@@ -49,21 +50,45 @@ void DownloadThread::run()
qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
}
+static void fill_supported_mobile_list()
+{
+ /* currently no BLE devices added as BLE backend is not ready yet */
+
+#if defined(Q_OS_ANDROID)
+ /* BT, BLE and FTDI devices */
+ mobileProductList["Heinrichs Weikamp"] =
+ QStringList({{"OSTC Sport"}, {"OSTC 2N"}, {"OSTC 3"},
+ {"OSTC 3+"}, {"OSTC 4"}});
+ mobileProductList["Shearwater"] =
+ QStringList({{"Petrel"}, {"Petrel 2"}, {"Perdix"}});
+#endif
+#if defined(Q_OS_IOS)
+ /* BLE only, Qt does not support classic BT on iOS */
+#endif
+}
+
void fill_computer_list()
{
dc_iterator_t *iterator = NULL;
dc_descriptor_t *descriptor = NULL;
struct mydescriptor *mydescriptor;
- QStringList computer;
+ fill_supported_mobile_list();
+
dc_descriptor_iterator(&iterator);
while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
const char *vendor = dc_descriptor_get_vendor(descriptor);
const char *product = dc_descriptor_get_product(descriptor);
-
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+ if (!mobileProductList.contains(vendor))
+ continue;
+#endif
if (!vendorList.contains(vendor))
vendorList.append(vendor);
-
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+ if (!mobileProductList[vendor].contains(product))
+ continue;
+#endif
if (!productList[vendor].contains(product))
productList[vendor].push_back(product);
@@ -73,6 +98,10 @@ void fill_computer_list()
Q_FOREACH (QString vendor, vendorList)
qSort(productList[vendor]);
+#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
+ /* currently suppress the Uemis Zurich on Q_OS_ANDROID and Q_OS_IOS,
+ * as it is no BT device */
+
/* and add the Uemis Zurich which we are handling internally
THIS IS A HACK as we magically have a data structure here that
happens to match a data structure that is internal to libdivecomputer;
@@ -92,6 +121,7 @@ void fill_computer_list()
productList["Uemis"].push_back("Zurich");
descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor;
+#endif
qSort(vendorList);
#if defined(SUBSURFACE_MOBILE) && defined(BT_SUPPORT)