summaryrefslogtreecommitdiffstats
path: root/core/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-04-16 18:14:59 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-04-24 17:54:08 -0700
commit13f5c75ac49d88bd1d1f45e798a5e75b6426aa81 (patch)
tree8f8e4021f34dca2551aca707f41b8ef3c509d444 /core/libdivecomputer.c
parentc07faa90f33fac895e8a0b3326adb298a1845063 (diff)
downloadsubsurface-13f5c75ac49d88bd1d1f45e798a5e75b6426aa81.tar.gz
Convert our custom IO model to new libdivecomputer IO model
This converts our old custom IO model to the new model that libdivecomputer introduced. This is partly based on Jef's rough patch to make things build, with further work by me. The FTDI code is temporarily disabled here, because it will need to be integrated with the new way of opening devices. The ble_serial code goes away entirely, since now libdivecomputer knows about BLE transport natively, and doesn't need to have any serial wrapper around it. Signed-off-by: Jef Driesen <jef@libdivecomputer.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/libdivecomputer.c')
-rw-r--r--core/libdivecomputer.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index a666ca667..ed5158c69 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -18,11 +18,6 @@
#include "libdivecomputer.h"
#include "core/version.h"
-#if !defined(SSRF_LIBDC_VERSION) || SSRF_LIBDC_VERSION < 2
-#pragma message "Subsurface requires a reasonably current version of the Subsurface-branch"
-#pragma message "of libdivecomputer (at least version 2 of our API)."
-#pragma message "Please get it from http://github.com/Subsurface-divelog/libdc Subsurface-branch"
-#endif
//
// If we have an old libdivecomputer, it doesn't
// have the new DC_TANKINFO bits, but just volume
@@ -1076,6 +1071,7 @@ const char *do_libdivecomputer_import(device_data_t *data)
first_temp_is_air = 0;
data->device = NULL;
data->context = NULL;
+ data->iostream = NULL;
if (data->libdc_log && logfile_name)
fp = subsurface_fopen(logfile_name, "w");
@@ -1095,27 +1091,16 @@ const char *do_libdivecomputer_import(device_data_t *data)
err = translate("gettextFromC", "Unable to open %s %s (%s)");
-#if defined(SSRF_CUSTOM_IO)
if (data->bluetooth_mode) {
-#if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_IO)
- rc = dc_context_set_custom_io(data->context, get_qt_serial_ops(), data);
-#endif
-#ifdef SERIAL_FTDI
- } else if (!strcmp(data->devname, "ftdi")) {
- rc = dc_context_set_custom_io(data->context, &serial_ftdi_ops, data);
- INFO(0, "setting up ftdi ops");
-#else
- INFO(0, "FTDI disabled");
+#if defined(BT_SUPPORT)
+ rc = ble_packet_open(&data->iostream, data->context, data->devname, data);
#endif
}
if (rc != DC_STATUS_SUCCESS) {
report_error(errmsg(rc));
} else {
-#else
- {
-#endif
- rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
+ rc = dc_device_open(&data->device, data->context, data->descriptor, data->iostream);
INFO(0, "dc_deveice_open error value of %d", rc);
if (rc != DC_STATUS_SUCCESS && subsurface_access(data->devname, R_OK | W_OK) != 0)
err = translate("gettextFromC", "Error opening the device %s %s (%s).\nIn most cases, in order to debug this issue, a libdivecomputer logfile will be useful.\nYou can create this logfile by selecting the corresponding checkbox in the download dialog.");
@@ -1126,6 +1111,8 @@ const char *do_libdivecomputer_import(device_data_t *data)
/* TODO: Show the logfile to the user on error. */
dc_device_close(data->device);
data->device = NULL;
+ dc_iostream_close(data->iostream);
+ data->iostream = NULL;
if (!downloadTable.nr)
dev_info(data, translate("gettextFromC", "No new dives downloaded from dive computer"));
}