<p dir="ltr">Good morning.<br>
It sounds like a good idea.<br>
Would it be an option to maybe allow the user to choose a specific transport type when they choose the dive computer?  As in for a Petrel 2, offer a choice between BT and BLE?<br>
Or for the G2, offer USB or BLE?</p>
<p dir="ltr">Benjamin </p>
<br><div class="gmail_quote"><div dir="ltr">On Fri, 23 Jun 2017, 07:52 Dirk Hohndel, <<a href="mailto:dirk@hohndel.org">dirk@hohndel.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Linus, Anton, everyone else...<br>
<br>
Looking at the code we added to filter the dive computer list I realized<br>
that this is just a silly hack and that this information needs to be<br>
collected in libdivecomputer, which already has a weird attempt to<br>
encapsulate the transport used. Right now that type is<br>
<br>
typedef enum dc_transport_t {<br>
        DC_TRANSPORT_NONE,<br>
        DC_TRANSPORT_SERIAL,<br>
        DC_TRANSPORT_USB,<br>
        DC_TRANSPORT_IRDA<br>
} dc_transport_t;<br>
<br>
And we then define in desktop-widgets/downloadfromdivecomputer.cpp<br>
<br>
// Workaround abuse of old libdc types<br>
#define DC_TRANSPORT_BLUETOOTH 1024<br>
<br>
And the way it is populated is pretty much this function:<br>
<br>
dc_transport_t<br>
dc_descriptor_get_transport (dc_descriptor_t *descriptor)<br>
{<br>
        if (descriptor == NULL)<br>
                return DC_TRANSPORT_NONE;<br>
<br>
        if (descriptor->type == DC_FAMILY_ATOMICS_COBALT)<br>
                return DC_TRANSPORT_USB;<br>
        else if (descriptor->type == DC_FAMILY_SUUNTO_EONSTEEL)<br>
                return DC_TRANSPORT_USB;<br>
        else if (descriptor->type == DC_FAMILY_SCUBAPRO_G2)<br>
                return DC_TRANSPORT_USB;<br>
        else if (descriptor->type == DC_FAMILY_UWATEC_SMART)<br>
                return DC_TRANSPORT_IRDA;<br>
        else<br>
                return DC_TRANSPORT_SERIAL;<br>
}<br>
<br>
Which is of course completely useless.<br>
<br>
I'm proposing to fix this to make this actually useful.<br>
<br>
typedef enum dc_transport_t {<br>
        DC_TRANSPORT_NONE = 0,<br>
        DC_TRANSPORT_SERIAL,<br>
        DC_TRANSPORT_USB_FTDI,<br>
        DC_TRANSPORT_USB_HID,<br>
        DC_TRANSPORT_USB_OTHER,<br>
        DC_TRANSPORT_IRDA,<br>
        DC_TRANSPORT_BT,<br>
        DC_TRANSPORT_BLE<br>
} dc_transport_t;<br>
<br>
<br>
First, let's include that thing in the dc_descriptor_t:<br>
<br>
struct dc_descriptor_t {<br>
        const char *vendor;<br>
        const char *product;<br>
        dc_family_t type;<br>
        unsigned int model;<br>
        dc_transport_t transport[3]; // 3 assuming that someone builds a dive computer that does USB, BT, and BLE<br>
        unsigned int serial;<br>
};<br>
<br>
Then we extend the g_descriptors to become useful:<br>
<br>
dc_descriptor_t g_descriptors[] = {<br>
//...<br>
        {"Suunto", "Vyper Novo", DC_FAMILY_SUUNTO_D9, 0x1D, { DC_TRANSPORT_USB_FTDI , 0, 0 }},<br>
        {"Suunto", "Zoop Novo",  DC_FAMILY_SUUNTO_D9, 0x1E, { DC_TRANSPORT_USB_FTDI , 0, 0 }},<br>
        /* Suunto EON Steel */<br>
#ifdef USBHID<br>
        {"Suunto", "EON Steel", DC_FAMILY_SUUNTO_EONSTEEL, 0, { DC_TRANSPORT_USB_HID, DC_TRANSPORT_BLE, 0 }},<br>
        {"Scubapro", "G2", DC_FAMILY_SCUBAPRO_G2, 0x11, { DC_TRANSPORT_USB_HID, DC_TRANSPORT_BLE, 0 }},<br>
#endif<br>
//...<br>
        {"Shearwater", "Petrel 2", DC_FAMILY_SHEARWATER_PETREL, 3, { DC_TRANSPORT_BT, DC_TRANSPORT_BLE, 0 }},<br>
//...<br>
        {"Uwatec", "Smart Pro",     DC_FAMILY_UWATEC_SMART, 0x10, { DC_TRANSPORT_IRDA, 0, 0 }},<br>
//...<br>
}<br>
<br>
Of course for those dive computers that change capabilities without<br>
changing names, we need to list all the ones they might have (and explain<br>
the problem in the FAQ / user manual) - as seen with the Petrel 2 in the<br>
example (for the EON Steel it's at least just a firmware update that makes<br>
it work).<br>
<br>
And now with this information it becomes MUCH easier to write the<br>
fill_computer_list() - we simply skip those descriptors that don't include<br>
on of the supported transports: (soon) only DC_TRANSPORT_BLE on IOS,<br>
DC_TRANSPORT_BT, DC_TRANSPORT_BLE, and DC_TRANSPORT_USB_FTDI on Android<br>
(Anton seems to believe that DC_TRANSPORT_USB_HID might work as well),<br>
etc.<br>
<br>
Does this seem reasonable? What am I missing?<br>
<br>
/D<br>
_______________________________________________<br>
subsurface mailing list<br>
<a href="mailto:subsurface@subsurface-divelog.org" target="_blank">subsurface@subsurface-divelog.org</a><br>
<a href="http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface" rel="noreferrer" target="_blank">http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface</a><br>
</blockquote></div>