mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Implement the custom Bluetooth serial communication and use it
Create a custom Bluetooth serial communication using the QTBluetooth API and use it when the Bluetooth download mode is enabled. First try to connect on RFCOMM channel 1 because this is the default RFCOMM channel of SPP service for most devices. If this doesn't work try again on RFCOMM channel number 5 because it could be a Petrel2 device. Add a fake open function for the custom implementation. This is used when the selected device is HW OSTC 2N and the Bluetooth mode is activated, then fake the open call of the serial device. Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
dff4e5f33e
commit
198cc41959
5 changed files with 271 additions and 3 deletions
|
|
@ -923,14 +923,30 @@ const char *do_libdivecomputer_import(device_data_t *data)
|
|||
}
|
||||
|
||||
err = translate("gettextFromC", "Unable to open %s %s (%s)");
|
||||
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
|
||||
|
||||
if (data->bluetooth_mode) {
|
||||
dc_serial_t *serial_device;
|
||||
|
||||
rc = dc_serial_qt_open(&serial_device, data->context, data->devname);
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
rc = dc_device_custom_open(&data->device, data->context, data->descriptor, serial_device);
|
||||
} else {
|
||||
report_error(errmsg(rc));
|
||||
}
|
||||
|
||||
} else {
|
||||
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
|
||||
|
||||
if (rc != DC_STATUS_SUCCESS && subsurface_access(data->devname, R_OK | W_OK) != 0)
|
||||
err = translate("gettextFromC", "Insufficient privileges to open the device %s %s (%s)");
|
||||
}
|
||||
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
err = do_device_import(data);
|
||||
/* TODO: Show the logfile to the user on error. */
|
||||
dc_device_close(data->device);
|
||||
data->device = NULL;
|
||||
} else if (subsurface_access(data->devname, R_OK | W_OK) != 0)
|
||||
err = translate("gettextFromC", "Insufficient privileges to open the device %s %s (%s)");
|
||||
}
|
||||
|
||||
dc_context_free(data->context);
|
||||
data->context = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue