mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core/bluetooth: switch to use libdivecomputer rfcomm support
The Qt based implementation apparently got broken at some point and now fails to connect to rfcomm dive computers like the Shearwater Petrel. This uses the libdivecomputer rfcomm backend. Tested to work with bluez on Linux as well as with the native Windows implementation. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9e50ab87dc
commit
e1befbea0a
2 changed files with 29 additions and 1 deletions
|
@ -154,6 +154,9 @@ endif()
|
||||||
pkg_config_library(LIBZIP libzip REQUIRED)
|
pkg_config_library(LIBZIP libzip REQUIRED)
|
||||||
|
|
||||||
if(NOT ANDROID)
|
if(NOT ANDROID)
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
pkg_config_library(BLUEZ bluez REQUIRED)
|
||||||
|
endif()
|
||||||
pkg_config_library(LIBUSB libusb-1.0 QUIET)
|
pkg_config_library(LIBUSB libusb-1.0 QUIET)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <libdivecomputer/usb.h>
|
#include <libdivecomputer/usb.h>
|
||||||
#include <libdivecomputer/serial.h>
|
#include <libdivecomputer/serial.h>
|
||||||
#include <libdivecomputer/irda.h>
|
#include <libdivecomputer/irda.h>
|
||||||
|
#include <libdivecomputer/bluetooth.h>
|
||||||
|
|
||||||
#include "libdivecomputer.h"
|
#include "libdivecomputer.h"
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
@ -1340,6 +1341,30 @@ static dc_status_t irda_device_open(dc_iostream_t **iostream, dc_context_t *cont
|
||||||
return dc_irda_open(&data->iostream, context, address, 1);
|
return dc_irda_open(&data->iostream, context, address, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static dc_status_t bluetooth_device_open(dc_iostream_t **iostream, dc_context_t *context, device_data_t *data)
|
||||||
|
{
|
||||||
|
dc_bluetooth_address_t address = 0;
|
||||||
|
dc_iterator_t *iterator = NULL;
|
||||||
|
dc_bluetooth_device_t *device = NULL;
|
||||||
|
|
||||||
|
// Try to find the rfcomm device address
|
||||||
|
dc_bluetooth_iterator_new (&iterator, context, data->descriptor);
|
||||||
|
while (dc_iterator_next (iterator, &device) == DC_STATUS_SUCCESS) {
|
||||||
|
address = dc_bluetooth_device_get_address (device);
|
||||||
|
dc_bluetooth_device_free (device);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dc_iterator_free (iterator);
|
||||||
|
|
||||||
|
if (!address) {
|
||||||
|
report_error("No rfcomm device found");
|
||||||
|
return DC_STATUS_NODEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_info(data, "Opening rfcomm address %u", address);
|
||||||
|
return dc_bluetooth_open(&data->iostream, context, address, 0);
|
||||||
|
}
|
||||||
|
|
||||||
dc_status_t divecomputer_device_open(device_data_t *data)
|
dc_status_t divecomputer_device_open(device_data_t *data)
|
||||||
{
|
{
|
||||||
dc_status_t rc;
|
dc_status_t rc;
|
||||||
|
@ -1358,7 +1383,7 @@ dc_status_t divecomputer_device_open(device_data_t *data)
|
||||||
#ifdef BT_SUPPORT
|
#ifdef BT_SUPPORT
|
||||||
if (transports & DC_TRANSPORT_BLUETOOTH) {
|
if (transports & DC_TRANSPORT_BLUETOOTH) {
|
||||||
dev_info(data, "Opening rfcomm stream %s", data->devname);
|
dev_info(data, "Opening rfcomm stream %s", data->devname);
|
||||||
rc = rfcomm_stream_open(&data->iostream, context, data->devname);
|
rc = bluetooth_device_open(&data->iostream, context, data);
|
||||||
if (rc == DC_STATUS_SUCCESS)
|
if (rc == DC_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue