Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG

Pull upstream libdivecomputer updates from Jef Driesen:

 - fix lack of "end of deco" on DiveSystem iDive computers by reporting
   long NDL values

 - clean up handling of Oceanic empty logbugger

 - fix BLE download for Oceanic Pro Plus X that doesn't like the serial
   number handshake.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Pass infinite NDL values to the application
  Clear the buffer if no dives are present
  Report an error for invalid ringbuffer pointers
  Improve the empty logbook ringbuffer detection
  Skip the BLE handshake for the Pro Plus X
This commit is contained in:
Linus Torvalds 2020-02-27 16:25:31 -08:00
commit 0714e327b7
3 changed files with 26 additions and 19 deletions

View File

@ -477,28 +477,20 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
decostop = array_uint16_le (data + offset + 21); decostop = array_uint16_le (data + offset + 21);
decotime = array_uint16_le (data + offset + 23); decotime = array_uint16_le (data + offset + 23);
tts = array_uint16_le (data + offset + 25); tts = array_uint16_le (data + offset + 25);
if (tts == 0x7FFF) {
tts = INVALID;
}
} else { } else {
decostop = array_uint16_le (data + offset + 21); decostop = array_uint16_le (data + offset + 21);
tts = array_uint16_le (data + offset + 23); tts = array_uint16_le (data + offset + 23);
if (tts == 0xFFFF) {
tts = INVALID;
}
} }
if (tts != INVALID) { if (decostop) {
if (decostop) { sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.depth = decostop / 10.0;
sample.deco.depth = decostop / 10.0; sample.deco.time = apos4 ? decotime : tts;
sample.deco.time = apos4 ? decotime : tts; } else {
} else { sample.deco.type = DC_DECO_NDL;
sample.deco.type = DC_DECO_NDL; sample.deco.depth = 0.0;
sample.deco.depth = 0.0; sample.deco.time = tts;
sample.deco.time = tts;
}
if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
} }
if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
// CNS // CNS
unsigned int cns = array_uint16_le (data + offset + 29); unsigned int cns = array_uint16_le (data + offset + 29);

View File

@ -920,7 +920,8 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream
goto error_free; goto error_free;
} }
if (dc_iostream_get_transport (device->iostream) == DC_TRANSPORT_BLE) { if (dc_iostream_get_transport (device->iostream) == DC_TRANSPORT_BLE &&
model != PROPLUSX) {
status = oceanic_atom2_ble_handshake(device); status = oceanic_atom2_ble_handshake(device);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
goto error_free; goto error_free;

View File

@ -281,6 +281,7 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr
// entries first. If an already downloaded entry is identified (by means // entries first. If an already downloaded entry is identified (by means
// of its fingerprint), the transfer is aborted immediately to reduce // of its fingerprint), the transfer is aborted immediately to reduce
// the transfer time. // the transfer time.
unsigned int count = 0;
unsigned int nbytes = 0; unsigned int nbytes = 0;
unsigned int offset = rb_logbook_size; unsigned int offset = rb_logbook_size;
while (nbytes < rb_logbook_size) { while (nbytes < rb_logbook_size) {
@ -312,13 +313,19 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr
offset += layout->rb_logbook_entry_size; offset += layout->rb_logbook_entry_size;
break; break;
} }
count++;
} }
// Update and emit a progress event. // Update and emit a progress event.
progress->maximum -= rb_logbook_size - nbytes; progress->maximum -= rb_logbook_size - nbytes;
device_event_emit (abstract, DC_EVENT_PROGRESS, progress); device_event_emit (abstract, DC_EVENT_PROGRESS, progress);
dc_buffer_slice (logbook, offset, rb_logbook_size - offset); if (count) {
dc_buffer_slice (logbook, offset, rb_logbook_size - offset);
} else {
dc_buffer_clear (logbook);
}
dc_rbstream_free (rbstream); dc_rbstream_free (rbstream);
@ -330,6 +337,7 @@ dc_status_t
oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progress, dc_buffer_t *logbook, dc_dive_callback_t callback, void *userdata) oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progress, dc_buffer_t *logbook, dc_dive_callback_t callback, void *userdata)
{ {
oceanic_common_device_t *device = (oceanic_common_device_t *) abstract; oceanic_common_device_t *device = (oceanic_common_device_t *) abstract;
dc_status_t status = DC_STATUS_SUCCESS;
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
assert (device != NULL); assert (device != NULL);
@ -379,6 +387,7 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr
{ {
ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%06x 0x%06x).", ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%06x 0x%06x).",
rb_entry_first, rb_entry_last); rb_entry_first, rb_entry_last);
status = DC_STATUS_DATAFORMAT;
break; break;
} }
@ -417,6 +426,11 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr
progress->maximum -= (layout->rb_profile_end - layout->rb_profile_begin) - rb_profile_size; progress->maximum -= (layout->rb_profile_end - layout->rb_profile_begin) - rb_profile_size;
device_event_emit (abstract, DC_EVENT_PROGRESS, progress); device_event_emit (abstract, DC_EVENT_PROGRESS, progress);
// Exit if there are no dives.
if (rb_profile_size == 0) {
return status;
}
// Create the ringbuffer stream. // Create the ringbuffer stream.
dc_rbstream_t *rbstream = NULL; dc_rbstream_t *rbstream = NULL;
rc = dc_rbstream_new (&rbstream, abstract, PAGESIZE, PAGESIZE * device->multipage, layout->rb_profile_begin, layout->rb_profile_end, rb_profile_end); rc = dc_rbstream_new (&rbstream, abstract, PAGESIZE, PAGESIZE * device->multipage, layout->rb_profile_begin, layout->rb_profile_end, rb_profile_end);