Only offer dive computers with supported transports

On Android we still need to do more filtering as only some of the USB
divecomputers are supported. But on iOS this takes care of it without
the hard coded list.

Additionally, if built without BT or BLE support, the corresponding dive
computers are no longer shown (e.g. Perdix AI on Windows).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-04-18 21:19:14 -07:00
parent 0aa87687a8
commit c5e4086820

View file

@ -101,20 +101,6 @@ static void fill_supported_mobile_list()
mobileProductList["Atomic Aquatics"] =
QStringList({{"Cobalt"}, {"Cobalt 2"}});
#endif
#if defined(Q_OS_IOS)
/* BLE only, Qt does not support classic BT on iOS */
mobileProductList["Heinrichs Weikamp"] =
QStringList({{"OSTC 2"}, {"OSTC 3"}, {"OSTC 3+"}, {"OSTC 4"}, {"OSTC Plus"}, {"OSTC Sport"}, {"OSTC 2 TR"}});
mobileProductList["Mares"] =
QStringList({{"Puck Pro"}, {"Smart"}, {"Quad"}});
mobileProductList["Scubapro"] =
QStringList({{"Aladin Sport Matrix"}, {"Aladin Square"}, {"G2"}});
mobileProductList["Shearwater"] =
QStringList({{"Perdix"}, {"Perdix AI"}, {"Petrel"}, {"Petrel 2"}});
mobileProductList["Suunto"] =
QStringList({{"EON Core"}, {"EON Steel"}});
#endif
}
@ -123,10 +109,31 @@ void fill_computer_list()
dc_iterator_t *iterator = NULL;
dc_descriptor_t *descriptor = NULL;
int transportMask = 0;
#if defined(BT_SUPPORT)
transportMask |= DC_TRANSPORT_BLUETOOTH;
#endif
#if defined(BLE_SUPPORT)
transportMask |= DC_TRANSPORT_BLE;
#endif
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(Q_OS_MAC)
transportMask |= DC_TRANSPORT_IRDA;
#endif
#if !defined(Q_OS_IOS)
transportMask |= DC_TRANSPORT_USB | DC_TRANSPORT_USBHID;
#endif
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
transportMask |= DC_TRANSPORT_SERIAL;
#endif
fill_supported_mobile_list();
dc_descriptor_iterator(&iterator);
while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
if ((dc_descriptor_get_transports(descriptor) & transportMask) == 0)
// none of the transports are available, skip
continue;
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)