2045 Commits

Author SHA1 Message Date
Nick Shore
76d225dcfc Add support for the EON Steel Black 2021-04-20 09:30:01 +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
1418766a1a Fix an overflow in the progress events
The maximum value for the progress events is based on the amount of the
flash memory available for storing the dives. But the 8 byte serial
number is not stored inside the dive data, and is added dynamically
during the data transfer. This extra data needs to be taken into account
to avoid overflowing the progress events and trigger an assert in the
code.
2021-04-08 17:27:43 +02:00
Jef Driesen
752a064bb3 Use a common sleep implementation
Implement a common sleep function to eliminate some conditional
compilation in the rest of the code.
2021-03-24 17:17:57 +01:00
Jef Driesen
a4d771956a Fix the clang compiler flag detection
The clang compiler accepts *any* compiler flags, and just reports
an annoying warning instead:

  warning: unknown warning option '-Wsomething' [-Wunknown-warning-option]

Use -Werror=unknown-warning-option to change this warning into an error,
and detect the unsupported flag. Since this is a clang specific option,
it can't be used unconditionally with other compilers. The option is
also only used for checking the compiler flags, and not for compiling
the code.
2021-03-11 16:41:53 +01:00
Jef Driesen
007a2bc835 Add Github Actions CI builds and releases
The new Github Actions offers similar functionality as the Travis CI
integration, but with some interesting extra features:

The build action is almost equivalent to the existing Travis build
configuration. But as an extra feature, the build artifacts are now
available for download.

The release action does automatically build a distribution tarball and
create a Github release, whenever a new version is tagged and pushed.
2021-03-09 22:49:08 +01:00
Jef Driesen
6b576da5ef Show a summary after configuration 2021-03-07 21:24:15 +01:00
Jef Driesen
6bb13a564f Extend the OS detection to non Windows platforms
At the moment, only the Windows platform needs some special handling,
but this can easily be extended to detect and handle other platforms as
well.
2021-03-07 21:23:44 +01:00
Jef Driesen
bf482f6025 Merge branch 'vtpro' 2021-03-04 12:47:20 +01:00
Jef Driesen
d49a8a3e64 Implement the ndl/deco sample 2021-03-04 12:44:42 +01:00
Jef Driesen
95920af7b7 Fix the maximum depth
The upper bits appear to contain some other (currently unknown)
information. The Oceanic VT Pro specifications list a maximum depth of
399 ft (120 m), which requires only 9 bits. The Oceanic application also
ignores the higher bits.
2021-03-04 12:43:31 +01:00
Jef Driesen
3d3271abe1 Mark the McLean Extreme as supporting BLE
The McLean Extreme uses a dual stack Bluetooth module from Microchip
which supports both Bluetooth Classic and Low Energy.

Reported-by: David Carron <david_de_carron@hotmail.com>
2021-02-26 14:33:31 +01:00
Jef Driesen
b713136a00 Fix -Wcast-qual compiler warning
The CBC initialization vector is passed as a const pointer, and then
cast to a non-const pointer to store it in the aes state struct. This
cast can easily be avoided by changing the struct field into a const
pointer.
2021-02-24 12:00:05 +01:00
Jef Driesen
03ddc84384 Mark the new iX3M 2021 models as supporting BLE
The new iX3M 2021 models with bluetooth do support BLE communication.
Bluetooth Classic (rfcomm), which was the only supported bluetooth
variant in the previous models, is not available.
2021-02-16 11:43:53 +01:00
Jef Driesen
580e1d5fc5 Add support for the Sherwood Beacon
The Sherwood Beacon appears to be compatible with the Sherwood Sage. For
the BLE communication the handshake also fails and is disabled.
2021-02-16 09:54:52 +01:00
Jef Driesen
f42df2d846 Remove the infinite timeout
When an Uwatec Aladin is connected, but the transfer hasn't been started
yet, we receive a continuous stream of zero bytes. Approximately every
7-8ms a new zero byte is received. But when the dive computer is
(temporary) disconnected, the stream of zero bytes also ends.

The consequence is that due to the use of blocking read call with an
infinite timeout, the application becomes unresponsive, without any
chance to abort the communication. This can eaily be avoided by using a
timeout instead. Receiving the main 2048 byte packet takes about 1050ms.
Thus a 3000ms timeout should be long enough to not cause the main data
transfer to timeout, but still short enough to cancel reasonable fast.
2021-02-12 13:54:40 +01:00
Jef Driesen
ecc23a5a76 Simplify the loop for reading the packet header
The for loop construct without an increment statement is a bit unusual
and thus easy to miss. With an equivalent while loop, the intent becomes
a bit more obvious.
2021-02-12 13:54:40 +01:00
Jef Driesen
d63c6cd04e Add a new Perdix AI hardware type 2021-02-12 13:52:52 +01:00
Jef Driesen
034819cd2d Fix the McLean Extreme fingerprint feature
Currently the fingerprint feature uses the first 7 bytes of the computer
configuration data. Since this information does not uniquely identify a
dive, and is actually often identical for several dives, no new dives
are detected anymore. Fixed by using the date/time timestamp at the
start of the dive configuration data instead.

Reported-by: David Carron <david_de_carron@hotmail.com>
2021-02-08 11:01:24 +01:00
Jef Driesen
0f677fcaac Perform the check for the NULL key earlier
The previous commit added a check for a NULL key inside the filter
functions, but it's more efficient to handle it early on, before even
calling the filter function.
2021-02-05 14:25:53 +01:00
Jef Driesen
efc9236fbc Fix the return value for a NULL key
An example where the filter functions can be called with a NULL key is
when a bluetooth discovery fails to retrieve the name of the remote
device. In such case, we have no information to detect whether the
bluetooth device matches a known dive computer or not, and thus it
shouldn't be filtered out.
2021-01-25 16:51:04 +01:00
Jef Driesen
b9a99de158 Fix the oceanic filter function
The matching functions expect a pointer to the value as argument, and
not the value itself. Since a C string is already a pointer (to a NULL
terminated character array), an extra pointer indirection is required.
2021-01-25 09:39:05 +01:00
Jef Driesen
939470df52 Wait before sending the firmware data
Without the small delay, sending the first frame often fails. Trying to
read the ACK response byte just fails with a timeout, and no data is
received at all. The bootloader is probably not ready to receive data
yet.
2021-01-15 09:33:28 +01:00
Jef Driesen
0239329f06 Add support for the new iX3M 2021 models
The new iX3M 2021 models (refered to as 'iX3M with Sequared Buttons' in
the Ratio support section) identify as iX5M in the Bluetooth name.

Reported-by: Damian Zaremba <damian@damianzaremba.co.uk>
2021-01-15 08:59:46 +01:00
Jef Driesen
d5dffb70be Avoid generating the SIGPIPE signal
Handling the SIGPIPE signal in a library is tricky, because installing a
signal handler does affects the entire application. But we can at least
try to avoid generating the SIGPIPE signal ourselves. On Linux, that
requires the use of the MSG_NOSIGNAL flag, and on Mac and BSD setting
the SO_NOSIGPIPE socket option.
2021-01-07 21:39:47 +01:00
Jef Driesen
4ffd45c126 Merge branch 'warnings' 2021-01-05 13:01:48 +01:00
Jef Driesen
ba6a8a43f7 Use an unsigned value to represent the undefined state
This fixes some more -Wsign-compare compiler warnings.
2021-01-05 09:32:45 +01:00
Jef Driesen
5eddaeade6 Use an unsigned integer for the number of dives
Because the dive_count variable is decremented, it doesn't contain the
total number of dives, but the index of the last dive. A negative number
indicates no dives. The same result can be obtained by using the total
number of dives directly. That's not only more intuitive, but also fixes
a -Wsign-compare compiler warning.
2021-01-05 09:32:45 +01:00
Jef Driesen
fc76b4a258 Use the cross-platform socket file descriptor type
Windows and unix use a diferent data type for representing socket file
descriptors (SOCKET vs int). This mismatch results in a compiler warning
when comparing to S_INVALID.
2021-01-05 09:32:45 +01:00
Jef Driesen
b0cce363f1 Limit the size to INT_MAX
Allthough the input buffer size has type 'size_t', the return value of
the function has only type 'int'. Hence the function can't support input
buffers larger than INT_MAX.

This allows to fix a -Wsign-compare compiler warning: operand of ?:
changes signedness from ‘int’ to ‘size_t’ due to unsignedness of other
operand.
2021-01-05 09:32:45 +01: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
0688b74099 Use an unsigned integer for the length
This avoids -Wsign-compare compiler warnings due to comparison of
integer expressions of different signedness.
2021-01-05 09:32:45 +01:00
Jef Driesen
1130b7eade Fix -Wsign-compare compiler warnings
Comparing signed and unsigned integer expressions can have unexpected
results because the signed integer will get promoted to an unsigned
integer. To avoid the warning, add an explicit cast to the unsigned
type, along with a check to catch negative values.
2021-01-05 09:32:45 +01:00
Jef Driesen
8f383ac531 Fix -Wshadow compiler warnings
Rename a few variables, parameters and functions to avoid shadowing
others.
2021-01-05 09:32:45 +01:00
Jef Driesen
7c9726da64 Fix -Wcast-qual compiler warning
String literals have the type 'char[N]' by default. Allthough they are
not really 'const', modifying a string literal is undefined behaviour.
Therefore, to avoid mistakes, libdivecomputer uses the -Wwrite-strings
compiler option to change the default type to 'const char[N]'.

The cast that triggers the -Wcast-qual warning can be avoided by using a
character array instead of string literal.
2021-01-04 20:20:52 +01:00
Jef Driesen
548fce69f8 Fix -Wswitch compiler warning
Add a default label to prevent warnings for all enum values not handled
in the switch statement. It's intentional in this piece of code.
2021-01-04 20:20:52 +01:00
Jef Driesen
b97acabb01 Remove unused variables 2021-01-04 20:20:52 +01:00
Jef Driesen
6c9a758648 Implement the rbt sample
The name of the RBT (Remaining Bottom Time) sample was taken from the
Uwatec dive computers. The actual definition depends on the dive
computer, but it usually corresponds to the air time remaining (with or
without some additional factors taken into account).
2021-01-04 20:20:03 +01:00
Jef Driesen
e592c7e7b7 Use some more descriptive variable names 2021-01-04 20:20:03 +01:00
Jef Driesen
cebf4089cc Verify the oxygen and helium percentage
The oxygen and helium percentage in the gas change event should
correspond to the percentages indicated in the dive header.
2021-01-04 20:20:03 +01:00
Jef Driesen
099fda0d2b Merge branch 'horizon' 2020-12-24 14:06:03 +01:00
Jef Driesen
8b06f2c31d Add support for the Mares Horizon
The Mares Horizon is a variant of the Mares Genius, with a few changes
to support SCR dives:

The dive header is slightly modified. There is an extra 8 byte field at
offset 0x18, which causes all later fields to have moved up with the
same amount. This difference is indicated in both the object minor
version (with a change from v0.0 to v0.1), and the logformat.

For the profile data, there is a new SDPT sample type which contains a
bit more information compared to the existing DPRS sample type. This
difference is indicated with a change in the object type (from 0 to 1).

The current implementation assumes a fixed order for the record types (a
DSTR record, a TISS record, zero or more DPRS/SDPT records with an AIRS
record every 4 sample, and finally a DEND record), and either only DPRS
or SDPT records but never a mixture of the two. If these assumptions
turns out to be incorrect, the implementation will need to be changed
significantly. Note that the assumption of the fixed order was already
present for the Genius.

Bluetooth support is currently disabled in the Horizon firmware, but
might be re-enabled in the future.
2020-12-24 13:52:47 +01:00
Jef Driesen
484e9dcdc3 Swap the object major and minor version 2020-12-24 11:33:18 +01:00
Jef Driesen
9438064afc Fix the Mares Genius memory layout
The Mares Genius appears to have 16M of flash memory, and it also
supports 4K packets.
2020-12-24 11:28:03 +01:00
Jef Driesen
6ab4ac7f7f Merge branch 'oceanic-ringbuffer-pointers' 2020-12-24 11:16:09 +01:00
Jef Driesen
9eddbe88be Skip logbook entries with invalid pointers
Since logbook entries with invalid ringbuffer pointers are considered a
fatal error, the download is aborted. The result is that any remaining
entries, located after the invalid entry, can't be downloaded at all.

This can be avoided by skipping the problematic entry instead of
aborting the download.
2020-12-01 11:05:37 +01:00
Jef Driesen
e53e7cf961 Re-use the common error handling code
There is no need to duplicate the error cleanup code everywhere. Break
out of the while loop and cleanup at the end of the function.
2020-12-01 11:04:56 +01:00
Jef Driesen
90a08ad845 Add support for the Sherwood Sage
The Sherwood Sage appears to be very similar to the Aeris A300CS. For
the BLE communication the handshake fails and is disabled.

Reported-By: Nick Shore <support@mac-dive.com>
2020-11-26 14:13:57 +01:00
Jef Driesen
7f553c1276 Merge branch 'oceanic-firmware-version' 2020-10-27 11:14:29 +01:00
Jef Driesen
b7850e9cbf Report the firmware version in the devinfo event 2020-10-27 10:54:40 +01:00