39 Commits

Author SHA1 Message Date
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
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
bfd7301945 Replace the deco events with a deco sample 2017-04-08 08:56:15 +02:00
Jef Driesen
390b5fe553 Report the initial gas mix on the first sample
For dives with multiple gas mixes, an application doesn't have enough
info to figure out which one is the initial gas mix. Usually it's the
first gas mix, but that's not guaranteed. Reporting the intial gas mix
on the first sample avoids this problem.
2016-11-04 19:26:21 +01:00
Jef Driesen
ff29d218bb Use helper functions to allocate and free objects.
Both the allocation and initialization of the object data structure is
now moved to a single function. The corresponding deallocation function
is intended to free objects that have been allocated, but are not fully
initialized yet. The public cleanup function shouldn't be used in such
case, because it may try to release resources that haven't been
initialized yet.
2016-01-05 20:40:21 +01:00
Jef Driesen
9bc14dca10 Remove some boilerplate code from the cleanup functions.
Instead of freeing the object data structure in the backend specific
cleanup function, the memory is now freed automatically in the base
class function. This reduces the amount of boilerplate code in the
backends. Backends that don't allocate any additional resources, do no
longer require a cleanup function at all.
2016-01-05 20:40:21 +01:00
Jef Driesen
c647a27c27 Implement tank pressure samples for the Nemo Air.
The tank pressure is stored every third sample as a delta value.
2015-06-13 12:18:46 +02:00
Jef Driesen
bfd91a733c Implement the tank field for the Nemo and Puck Air. 2015-06-13 12:08:09 +02:00
Jef Driesen
88159c6fe4 Implement the dive mode for several devices.
The new dive mode field is now supported by devices from these
manufacturers:

 * Atomic Aquatics
 * Heinrichs Weikamp
 * Mares
 * Reefnet
 * Suunto
2014-11-07 22:12:05 +01:00
Jef Driesen
c95ab19e6a Use symbolic constants for the dive mode. 2014-11-07 22:04:16 +01:00
Jef Driesen
52cac91b18 Implement the temperature support for several devices.
The new temperature fields are now supported by devices from these
manufacturers:

 * Atomic Aquatics
 * Heinrichs Weikamp
 * Mares
 * Suunto
 * Uwatec
2014-11-07 21:58:49 +01:00
Jef Driesen
ed2b9d34d5 Fix the dive mode detection for the Mares Nemo Air.
For the Nemo Air, a dive mode with the value 2 indicates gauge mode
instead of freedive mode. With this change, all models from the puck
family now use the same values.
2014-08-03 15:49:16 +02:00
Florian Klink
fc008312b5 Remove trailing whitespaces
Most of them appear in the disclaimers, but some are in the code as
well.
2014-03-19 09:16:07 +01:00
Jef Driesen
6419e189a4 Add a single isinstance function per object type.
Currently, each backend has it's own function to verify whether the
object vtable pointer is the expected one. All these functions can be
removed in favor of a single isintance function in the base class,
which takes the expected vtable pointer as a parameter.

Functions which are called through the vtable, don't need to verify the
vtable pointer, and those checks are removed.
2013-04-16 12:18:54 +02:00
Jef Driesen
007479fc92 Rename the backend structure to vtable.
The term "backend" can be confusing because it can refer to both the
virtual function table and the device/parser backends. The use of the
term "vtable" avoids this.
2013-04-16 12:18:53 +02:00
Jef Driesen
cd31ff9dff Properly store the context pointer internally.
I forgot to update the device and parser initialization functions to
store the context pointer into the objects. As a result, the internal
context pointers were always NULL.
2012-08-28 08:44:47 +02:00
Jef Driesen
53e9d72a40 Integrate the context object in the library.
The public api is changed to require a context object for all
operations. Because other library objects store the context pointer
internally, only the constructor functions need an explicit context
object as a parameter.
2012-08-27 23:08:38 +02:00
Jef Driesen
c821d40144 Introduce a namespace prefix for the high-level public api.
Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
2012-06-21 21:42:37 +02:00
Jef Driesen
163d383332 Use a common backend type for the device and parser layers. 2012-06-21 21:42:37 +02:00
Jef Driesen
9136a52835 Use common status codes for the device and parser layers. 2012-06-21 21:42:34 +02:00
Jef Driesen
e65025b501 Separate private and public headers.
The public header files are moved to a new subdirectory, to separate
the definition of the public interface from the actual implementation.
Using an identical directory layout as the final installation has the
advantage that the example code can be build outside the project tree
without any modifications to the #include statements.
2012-06-21 21:39:24 +02:00
Jef Driesen
bb4a498302 Fix the freedive mode detection for the Mares Puck Air. 2012-04-10 20:53:38 +02:00
Björn Spruck
407c40ed38 Fix the oxygen percentage for air dives.
When the dive mode setting is set to air, the oxygen percentage stored
in the header is different from the expected 21%. It might be the last
used nitrox percentage.
2012-03-29 21:41:41 +02:00
Jef Driesen
b57423cc54 Fix the depth decoding for the Mares Nemo Wide.
The depth is reduced to a 11 bit value. The meaning of the now unused
bit is still unknown.
2011-10-04 21:08:11 +02:00
Jef Driesen
608008cd33 Use symbolic constants for the model numbers. 2011-07-09 12:19:10 +02:00
Jef Driesen
4bce24e5fa Implement the new field api for the Mares devices. 2011-01-13 22:14:53 +01:00
Jef Driesen
90e60fecee Add a new function to the public api to retrieve the dive metadata. 2011-01-13 22:14:53 +01:00
Jef Driesen
154f767a9c Convert assertions into error codes. 2011-01-08 23:40:15 +01:00
Jef Driesen
82a0fc97a0 Add support for the Mares Nemo Apneist.
The total memory size is hardcoded again because the protocol does not
allow to retrieve the correct memory layout in advance. As long as there
is no device with a different amount of memory, that should be fine.
2010-07-27 13:38:56 +02:00
Jef Driesen
8d0acf3e9e Parse the tank pressure for the Mares Puck Air. 2010-07-15 16:01:08 +02:00
Jef Driesen
5875941641 Add support for the Mares Puck Air. 2010-07-13 09:09:14 +02:00
Jef Driesen
54695f1022 Fix the freedive mode detection for the Mares Nemo Wide. 2010-03-24 08:08:42 +00:00
Jef Driesen
f14b40e99e Fix the freedive mode detection. 2010-03-10 12:12:46 +00:00
Jef Driesen
1e7a1b8194 Use the correct freedive mode for each model. 2010-02-26 14:41:25 +00:00
Jef Driesen
9b1a89582c Add support for the Mares Nemo Air data format.
The Nemo Air contains an extra header which can be detected due to the
presence of a three byte marker sequence. The sample size is larger too.
2010-02-26 14:41:10 +00:00
Jef Driesen
a8116a0aec Add datetime support to the parsers. 2010-02-02 15:04:46 +00:00
Jef Driesen
a4247b7505 Define the WARNING macro only once. 2009-08-06 14:15:52 +00:00
Jef Driesen
ce705f8244 Use the new byte order functions everywhere. 2009-03-11 10:18:28 +00:00
Jef Driesen
6242ba9a13 Added a parser for the Mares Nemo. 2008-12-23 17:38:26 +00:00