mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
05435d64aa
commit
ac750bbf20
1 changed files with 33 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue