107 Commits

Author SHA1 Message Date
Jef Driesen
d4472b758f Add support for the Divesoft Freedom and Liberty
The latest versions of the Divesoft Freedom (HW 4.x) and Liberty (HW
2.x) dive computers support BLE communication. Previous generations did
support only a mass storage mode, where the dives are available as DLF
files. The BLE communication protocol uses HDLC framing for the data
packets. The dives downloaded over BLE have the same data format as the
DLF files.

Co-authored-by: Jan Matoušek <jan.matousek@rekomando.cz>
Tested-by: Jakub Hečko <jakub.hecko@divesoft.com>
2023-04-24 00:02:17 +02:00
Jef Driesen
9eef8c50c0 Add support for the Oceans S1
The Oceans S1 uses a plaintext and line based communication protocol
over BLE. The larger payloads, which also contain plaintext data, are
transferred using the XMODEM-CRC protocol.

Based-on-code-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-01-25 14:17:29 +01:00
Jef Driesen
86e9cc3443 Add support for the Deepblu Cosmiq+
The Deepblu Cosmiq+ uses a plaintext and line based communication
protocol over BLE, where the binary payload data is encoded as
hexadecimal characters.

Based-on-code-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-01-25 13:32:14 +01:00
Jef Driesen
12c77a228e Add a public api to configure the clock synchronization
For dive computers where the reference time (epoch) of the device is
unknown, libdivecomputer uses the current time of the device (devtime)
and the host system (systime) to synchronize both clocks.

Currently, both timestamps are passed directly to the constructor of the
parser. With the new public function, the application can adjust the
timestamps afterwards.
2022-08-11 17:36:26 +02:00
Jef Driesen
6ab140461a Add a public api to configure the depth calibration
Some dive computers store the depth as an absolute pressure value (in
bar). To convert to a depth value (in meters), the atmospheric pressure
and water density are required. For dive computers that do not have
those values available, libdivecomputer uses a default value. With the
new public api functions, applications can adjust those default values.

Some dive computers already provided a backend specific calibration
function. Those functions are now deprecated. They are kept around to
maintain backwards compatibility for now, but they will be removed in
the next version.
2022-08-11 17:36:15 +02:00
Jef Driesen
7fb943ae7f Add support for parsing the decompression model
Report the decompression algorithm (Buhlmann, VPM, RGBM or DCIEM), and
if available also the parameters. For now only the conservatism setting
is supported, and for the Buhlmann algorithm also the Gradient Factors
(GF).
2022-08-11 17:35:03 +02:00
Jef Driesen
4b4efb2c07 Add support for the Seac Screen and Action 2022-06-02 11:29:32 +02:00
Ryan Gardner
75f260a941 Add support for the Deep Six Excursion
Based on original work and code by Ryan Gardner, with some additional
improvements and integration into libdivecomputer by Jef Driesen.
2021-08-17 22:38:53 +02:00
Jef Driesen
6ef72ab420 Add support for the Sporasub SP2
The Sporasub SP2 uses a very simple communication protocol and memory
layout, but with some unusual aspects:

Dives are artifically limited to a maximum of 6000 samples.

Unlike all other dive computers, the dives are not stored in some kind
of ringbuffer structure. Once the memory is full, no new dives can be
recorded. The existing dives need to be erased first, and the dive
computer will start recording again at te start of the memory area. The
Sporasub application has an "Auto-clear watch memory after data
transfer" feature for this purpose.

I didn't implement a more efficient download algorithm because
downloading a full memory dumps takes less than 10 seconds.
2021-04-15 16:47:59 +02:00
Jef Driesen
10a4ec0b08 Define DC_TIMEZONE_NONE as a signed integer
The hexadecimal value 0x80000000 is too large to be represented as a
signed 32bit integer. Therefore the default type for the constant is an
unsigned 32bit integer. This is a bit annoying because the timezone
field is actually defined as a signed integer, and thus comparisions
produce -Wsign-compare compiler warnings.

Fixed by switching to INT_MIN, which is the same underlying value but
interpreted as a signed integer.
2021-01-05 09:32:45 +01:00
Jef Driesen
fe9a3d9a10 Add a function to insert data anywhere in the buffer
The memory buffer already supported appending and prepending data, but
not inserting data anywhere in the buffer. That's exactly what the new
function does. The free space is still maintained at either the start or
the end of the buffer.
2020-10-20 13:56:20 +02:00
Jef Driesen
c84bbd93a3 Add an I/O implementation for USB communication
The USB communication is now also implemented as an I/O stream
transport. Unlike most I/O devices, USB communication supports multiple
interfaces and endpoints. This requires some some special care:

In the general case, autodetection isn't really possible without
additional knowledge. Hence the need for the filter parameters to pass
this kind of information.

The implementation assumes two bulk endpoints for the standard
read/write interface. Communication with the control endpoint is
supported through the new DC_IOCTL_USB_CONTROL_{READ,WRITE} ioctl's.
2020-08-11 15:16:36 +02:00
Jef Driesen
71a149d776 Add support for Liquivision dive computers 2020-07-09 17:02:32 +02:00
David Carron
8d35ee6978 Add support for the McLean Extreme 2020-06-08 13:45:43 +02:00
Jef Driesen
f65e3cf39e Install the ioctl header file 2020-01-17 08:12:14 +01:00
Jef Driesen
e71278a13f Add an ioctl to retrieve the remote device name 2020-01-06 21:24:58 +01:00
Jef Driesen
c205299c02 Re-implement the set_latency function as an ioctl
The set_latency function is the perfect example of a feature that should
be implemented as an ioctl: it's only implemented by a single driver,
and the functionality is also highly platform specific.
2020-01-06 21:24:58 +01:00
Jef Driesen
0359a57fdc Add an ioctl function to the I/O interface
This new ioctl function allows to perform I/O stream specific requests
through a generic interface. This provides an easy way to extend the I/O
interface with some driver specific features, without having to modify
the public api.
2020-01-06 21:21:50 +01:00
Jef Driesen
f6fa2b84bc Add a poll function to the I/O interface
The Linux implementation is very straighforward and just a lightweight
wrapper around the select function. But the Windows implementation is
much more complex, because the Windows event notification mechanism
behaves very different:

The WaitCommEvent function does not support a timeout and is always a
blocking call. The only way to implement a timeout is to use
asynchronous I/O (or overlapped I/O as it's called in the Windows API),
to run the operation in the background. This requires some additional
book keeping to keep track of the pending background operation.

The event mechanism is also edge triggered instead of level triggered,
and reading the event with the WaitCommEvent function clears the pending
event. Therefore, the state of the input buffer needs to be checked with
the ClearCommError function before and after the WaitCommEvent call.

The check before is necessary in case the event is already cleared by a
previous WaitCommEvent call, while there is still data present in the
input buffer. In this case, WaitCommEvent should not be called at all,
because it would wait until more data arrives.

The check afterwards is necessary in case WaitCommEvent reports a
pending event, while the data in the input buffer has already been
consumed. In this case, the current event must be ignored and
WaitCommEvent needs to be called again, to wait for the next event.
2020-01-06 13:44:07 +01:00
Jef Driesen
4c91309c56 Add firmware upgrade support for the Ratio computers 2019-11-14 09:43:35 +01:00
Jef Driesen
e363e5b1fd Add support for the Cressi Goa and Cartesio 2019-01-14 21:14:30 +01:00
Calle Gunnarsson
4da94a7285 Include stddef.h in iostream.h
This header need to be included to successfully generate Go-bindings.
2018-08-20 07:55:54 +02:00
Jef Driesen
472e9e984c Add support for the Tecdiving DiveComputer.eu 2018-06-22 23:24:30 +02:00
Jef Driesen
8aef4a49a0 Unify the Uwatec Smart, Meridian and G2 backends
The Uwatec Smart, Meridian and G2 backends are almost identical, except
for the low-level packet sending and receiving code. With the new I/O
layer, those three backends can easily be unified in a single backend.

The Meridian and G2 are completely removed, only the family types are
kept for backwards compatibility.
2018-06-22 23:13:44 +02:00
Jef Driesen
3d394c9262 Don't use the USB VID/PID for opening the device
When two or more identical (or very similar) dive computers are
connected, the USB VID/PID can be ambiguous. That's because the VID/PID
identifies the type of the USB device, and not the individual device.
But each USB HID device descriptor returned by the device discovery
represents a single connected device, and thus guarantees to open the
correct USB device.

To obtain the same behaviour as before, an application can simply open
the first discovered device.
2018-04-03 22:02:15 +02:00
Jef Driesen
a7d0033bae Add a Bluetooth Low Energy (BLE) transport type
Libdivecomputer doesn't have built-in support for BLE communication yet,
so this is mainly for future use and custom I/O implementations.
2018-04-03 21:52:20 +02:00
Jef Driesen
44eba5515c Move the I/O implementations to the public api
The I/O implementations need to be exposed in the public api, otherwise
applications won't be able to use them!
2018-04-03 21:44:08 +02:00
Jef Driesen
ef2402eff5 Integrate the new I/O interface in the public api
Currently the dive computer backends are responsible for opening (and
closing) the underlying I/O stream internally. The consequence is that
each backend is hardwired to a specific transport type (e.g. serial,
irda or usbhid). In order to remove this dependency and support more
than one transport type in the same backend, the opening (and closing)
of the I/O stream is moved to the application.

The dc_device_open() function is modified to accept a pointer to the I/O
stream, instead of a string with the device node (which only makes sense
for serial communication). The dive computer backends only depend on the
common I/O interface.
2018-04-03 21:11:06 +02:00
Jef Driesen
30ea13b36b Remove the obsolete transport function
With the support for multiple transports per device, the
dc_descriptor_get_transport() function became obsolete because it does
support only a single transport type. Applications should use the new
dc_descriptor_get_transports() function instead.
2018-04-03 21:11:06 +02:00
Jef Driesen
aee59a33be Add support for querying the available built-in transports
Because the list of supported built-in transports depends on the
availability of external libraries (libusb, hidapi) and the operating
system, the application needs some mechanism to retrieve this
information at runtime. Therefore, a new dc_context_get_transports()
function is added, which returns a bitmask with all the available
built-in transports.
2018-04-03 21:11:06 +02:00
Jef Driesen
eed993fd16 Add support for multiple transports per device
Several dive computers support multiple transports. For example the
Suunto Eon Steel supports both USB HID and BLE. All devices using
bluetooth classic communication support both the native bluetooth
transport and the legacy serial port emulation.

To support this feature, the values of the dc_transport_t type are
changed into bitmasks, and the dc_descriptor_t struct is extended with a
bitfield with all the supported transports.
2018-04-03 21:11:06 +02:00
Jef Driesen
3230387fff Add the transport type to the I/O stream
Add a function to query the underlying transport type. This allows the
dive computer backends to implement transport specific behaviour where
necessary.

For the built-in I/O implementations, the transport type is obviously
always hardcoded, but for a custom I/O implementation the application
needs to provide the correct type. Hence the transport type can't be
hardcoded in the vtable and needs to be passed as a parameter.
2018-04-03 21:11:06 +02:00
Jef Driesen
38ff1f75dd Remove the half-duplex emulation from the I/O api
Now that the half-duplex emulation code isn't used anymore, it can be
removed from the I/O stream api.
2018-03-05 09:08:21 +01:00
Jef Driesen
f87720dff9 Add support for semi-closed circuit diving
Add a new type to distinguish between closed circuit (CCR) and
semi-closed circuit (SCR) diving. Some dive computers from HW and
DiveSystem/Ratio support this.

Because the CCR/SCR abbreviations are more commonly used, let's take the
opportunity to also rename the existing DC_DIVEMODE_CC. To preserve
backwards compatibility, a macro is added to map the old name to the new
one.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-30 09:03:46 +01:00
Jef Driesen
3ca27995e1 Add a new abstract I/O interface
The purpose of the new I/O interface is to provide a common interface
for all existing I/O implementations (serial, IrDA, bluetooth and USB
HID). With a common interface the dive computer backends can more easily
use different I/O implementations at runtime, without needing
significant code changes. For example bluetooth enabled devices can
easily switch between native bluetooth communication and serial port
emulation mode.

The new interface is modelled after the existing serial communication
api. Implementations where some of those functions are meaningless (e.g.
IrDA, bluetooth and USB), can just leave those functions unimplemented
(causing the call to fail with DC_STATUS_UNSUPPORTED), or implement it
as a no-op (always return DC_STATUS_SUCCESS).
2017-11-25 10:26:49 +01:00
Jef Driesen
156f54302d Add basic timezone support
Allthough most dive computers always use local time and don't support
timezones at all, there are a few exceptions. There are two different
sources of timezone information:

 - Some of the newer Uwatec/Scubapro devices use UTC internally and also
   support a timezone setting. This UTC offset is currently taken into
   account to obtain the dive date/time, but the UTC offset itself is
   lost.

 - Uwatec/Scubapro and Reefnet devices rely on the clock of the host
   system to synchronize the internal device clock and calculate the
   dive date/time. The consequence is that the resulting date/time is
   always in the timezone of the host system.

In order to preserve this timezone information, the dc_datetime_t
structure is extended with a new "timezone" field, containing the UTC
offset in seconds. Devices without timezone support will set the field
to the special value DC_TIMEZONE_NONE.

The dc_datetime_localtime() and dc_datetime_gmtime() functions will
automatically populate the new field with respectively the local
timezone offset and zero. The dc_datetime_mktime() function will take
into account the new timezone field for the conversion to UTC. The
special value DC_TIMEZONE_NONE is interpreted as zero.
2017-08-18 23:26:45 +02:00
Jef Driesen
22e0ab3d2b Implement the new api for the HW devices
The Heinrichs-Weikamp devices already supported clock synchronization by
means of a device specific function. This is now replaced with the new
api.
2017-08-18 23:17:33 +02:00
Jef Driesen
acb4a187fb Add support for synchronizing the device clock
Being able to synchronize the dive computer clock with the host system
is a very useful feature. Add the infrastructure to support this feature
through the public api.
2017-08-18 23:17:33 +02:00
Jef Driesen
4e0c2e4650 Remove non-existing function from header
The dc_device_version() function has been removed from the public api
long time ago.
2017-08-11 08:22:53 +02:00
Linus Torvalds
f107d7c0d8 Add initial Scubapro G2 frontend
The back-end parser seems to be the same as for the Uwatec Smart (aka
Galileo Sol).  At least that's the assumption right now.

The downloader just uses USB HID (very similar to EON Steel) rather than
the horrible IrDA thing.

There's also eventually a BLE thing, but that's for the future.

This is an unholy mixture of the Uwatec Smart downloader logic and the
EON Steel usbhid transfer code.  The back-end is pure Uwatec Smart
(model 0x11, same as Galileo Sol).

I'm not at all sure this gets everything right, but it downloads
*something*.

[Jef Driesen: Renamed the backend to uwatec, and made some smaller
              cosmetic changes to match the existing coding style.]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 15:32:39 +02:00
Jef Driesen
37392a03f2 Add a separate transport type for USB HID 2017-06-02 12:11:39 +02:00
Jef Driesen
58eebf4ece Add a bluetooth transport type 2017-06-02 12:11:39 +02:00
Jef Driesen
d1a06e784c Remove deprecated functions from the public api
The vendor_product_parser_create() and vendor_product_device_open()
functions should be called indirectly, through the generic
dc_device_open() and dc_parser_new() functions. And the
vendor_product_extract_dives() functions are internal functions that
should never have been part of the public api in the first place.
2017-04-18 08:41:10 +02:00
Jef Driesen
8735071fac Use a more efficient download algorithm
The current algorithm always downloads a full memory dump, and extracts
the dives afterwards. For the typical scenario where only a few dives
are being downloaded, this is inefficient because most of the data isn't
needed. This can easily be avoided by downloading the data on the fly.
2017-02-27 08:20:49 +01:00
Jef Driesen
07dcc8998b Add support for the Cressi Drake
The Cressi Drake is a mainly a freedive computer. The data format is
almost identical to the Leonardo. The main difference is that a single
dive now contains an entire freedive session. Each freedive in the
session is delimited with a 4 byte header containing the surface
interval and a special marker.
2016-12-30 22:25:14 +01:00
Jef Driesen
7714a57c44 Add missing header files to the Makefiles.
To be able to generate a distribution tarball, all files need to be
listed explicitely.
2016-09-28 14:49:52 +02:00
Jef Driesen
2829f7ebf9 Add an ostc3 specific function with the model number.
To be able to pass the OSTC 3 model number to the parser, and preserve
backwards compatibility, we need a new function. The new function should
also be used for the Frog, by passing zero as the model number.

Using the hw_ostc_parser_create() function with the hwos parameter set
to one, is now deprecated but will remain supported for backwards
compatibility.
2016-07-23 23:14:13 +02:00
Jef Driesen
29caab0673 Rename the frog parameter and field to hwos.
The frog parameter and field are not only used for the Frog, but also
for all hwOS based models. Therefore, using the more generic hwos as the
name is more meaningful.
2016-07-23 23:11:30 +02:00
Jef Driesen
ad2257569c Add a new dc_parser_new2 convenience function.
For applications supporting offline parsing (like libdivecomputer's own
dctool application), some device specific knowledge is still required in
order to map a particular model to the corresponding backend. The new
convenience function will take care of that internally.

The already existing dc_parser_new() function does the same, but
requires an open device handle, which makes it unsuitable for offline
parsing.
2016-07-22 21:14:33 +02:00
Jef Driesen
b41ecd0c15 Add a parameter with the model number. 2016-07-11 21:47:29 +02:00