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>
This commit is contained in:
Linus Torvalds 2018-04-16 18:14:59 -07:00 committed by Dirk Hohndel
parent c07faa90f3
commit 13f5c75ac4
9 changed files with 169 additions and 374 deletions

View file

@ -635,24 +635,16 @@ QString ConfigureDiveComputer::dc_open(device_data_t *data)
fprintf(data->libdc_logfile, "built with libdivecomputer v%s\n", dc_version(NULL));
}
#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);
#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);
}
if (rc != DC_STATUS_SUCCESS) {
@ -672,6 +664,8 @@ void ConfigureDiveComputer::dc_close(device_data_t *data)
if (data->context)
dc_context_free(data->context);
data->context = NULL;
dc_iostream_close(data->iostream);
data->iostream = NULL;
if (data->libdc_logfile)
fclose(data->libdc_logfile);