I attached some patches for the QtBluetooth serial implementation.

The UI exposes the following functionalities:
- read information about the local device and its state
- scan for remote devices
- pair/unpair with a remote device (it doesn't work for custom PIN codes)
- turn on/off the local device
- logging
- data transfer (dive logs import)

For the moment the *qt_serial_bluetooth* implementation works
only with *hw_ostc3* and *hw_ostc* (hopefully :-) ). After you agree with
the modifications and the design of libdivecomputer project I will
start to add support for other vendors.

Known issues:
- during the installation of libdivecomputer, the *custom_serial* header
is not copied
- the pair command doesn't work with devices which require a specific PIN
code
- the design of the UI is ugly :-)

Cheers,
Claudiu
From 22b5410764b67556b7a928e0367ac949e7547147 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 03:13:53 +0300
Subject: [PATCH 1/9] Add checkbox and button for Bluetooth download mode

The checkbox will be used to enable the Bluetooth
downloading mode. The button will be used to create
a dialog selection where the user will be able to
scan and select remote devices.

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 qt-ui/downloadfromdivecomputer.cpp | 20 ++++++++++++++++++++
 qt-ui/downloadfromdivecomputer.h   |  2 ++
 qt-ui/downloadfromdivecomputer.ui  | 17 +++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index c5d57e6..838a9e5 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -99,6 +99,9 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
 	ui.ok->setEnabled(false);
 	ui.downloadCancelRetryButton->setEnabled(true);
 	ui.downloadCancelRetryButton->setText(tr("Download"));
+	ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
+	connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
+	connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice()));
 }
 
 void DownloadFromDCWidget::updateProgressBar()
@@ -493,6 +496,8 @@ void DownloadFromDCWidget::markChildrenAsDisabled()
 	ui.chooseDumpFile->setEnabled(false);
 	ui.selectAllButton->setEnabled(false);
 	ui.unselectAllButton->setEnabled(false);
+	ui.bluetoothMode->setEnabled(false);
+	ui.chooseBluetoothDevice->setEnabled(false);
 }
 
 void DownloadFromDCWidget::markChildrenAsEnabled()
@@ -512,6 +517,21 @@ void DownloadFromDCWidget::markChildrenAsEnabled()
 	ui.chooseDumpFile->setEnabled(true);
 	ui.selectAllButton->setEnabled(true);
 	ui.unselectAllButton->setEnabled(true);
+	ui.bluetoothMode->setEnabled(true);
+	ui.chooseBluetoothDevice->setEnabled(true);
+}
+
+void DownloadFromDCWidget::selectRemoteBluetoothDevice()
+{
+	qWarning() << "Selecting a remote Bluetooth device...";
+	//TODO add implementation
+}
+
+void DownloadFromDCWidget::enableBluetoothMode(int state)
+{
+	ui.chooseBluetoothDevice->setEnabled(state == Qt::Checked);
+	if (state == Qt::Checked)
+		selectRemoteBluetoothDevice();
 }
 
 static void fillDeviceList(const char *name, void *data)
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index 92db09d..0b63d28 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -77,8 +77,10 @@ slots:
 	void updateProgressBar();
 	void checkLogFile(int state);
 	void checkDumpFile(int state);
+	void enableBluetoothMode(int state);
 	void pickDumpFile();
 	void pickLogFile();
+	void selectRemoteBluetoothDevice();
 
 private:
 	void markChildrenAsDisabled();
diff --git a/qt-ui/downloadfromdivecomputer.ui b/qt-ui/downloadfromdivecomputer.ui
index ff80935..f232967 100644
--- a/qt-ui/downloadfromdivecomputer.ui
+++ b/qt-ui/downloadfromdivecomputer.ui
@@ -116,6 +116,23 @@
            </property>
           </widget>
          </item>
+         <item row="11" column="0">
+          <widget class="QCheckBox" name="bluetoothMode">
+           <property name="text">
+            <string>Choose Bluetooth Download mode</string>
+           </property>
+          </widget>
+         </item>
+         <item row="11" column="1">
+          <widget class="QToolButton" name="chooseBluetoothDevice">
+           <property name="toolTip">
+            <string>Select a remote Bluetooth device.</string>
+           </property>
+           <property name="text">
+            <string>...</string>
+           </property>
+          </widget>
+         </item>
          <item row="0" column="0" colspan="2">
           <widget class="QLabel" name="label">
            <property name="text">
-- 
2.1.4

From 99acdca1b852a0ffa8e1c339bdd6f4efffae9d28 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 03:18:08 +0300
Subject: [PATCH 2/9] Implement temporaty UI design for Bluetooth selection
 dialog

Implement a temporary UI design for Bluetooth selection dialog.
Functionalities of the widget:
- expose information about the local device
- scan for remote devices
- pair/unpair with a remote device
- turn on/off the local device
- logging
- save the selected device

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 qt-ui/btdeviceselectiondialog.cpp | 257 ++++++++++++++++++++++++++++++++++++++
 qt-ui/btdeviceselectiondialog.h   |  48 +++++++
 qt-ui/btdeviceselectiondialog.ui  | 211 +++++++++++++++++++++++++++++++
 3 files changed, 516 insertions(+)
 create mode 100644 qt-ui/btdeviceselectiondialog.cpp
 create mode 100644 qt-ui/btdeviceselectiondialog.h
 create mode 100644 qt-ui/btdeviceselectiondialog.ui

diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp
new file mode 100644
index 0000000..49f8f58
--- /dev/null
+++ b/qt-ui/btdeviceselectiondialog.cpp
@@ -0,0 +1,257 @@
+#include <QShortcut>
+#include <QDebug>
+#include <QMessageBox>
+#include <QMenu>
+
+#include "ui_btdeviceselectiondialog.h"
+#include "btdeviceselectiondialog.h"
+
+BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
+	QDialog(parent),
+	localDevice(new QBluetoothLocalDevice),
+	ui(new Ui::BtDeviceSelectionDialog)
+{
+	/* Check if Bluetooth is available on this device */
+	if (!localDevice->isValid()) {
+		QMessageBox::warning(this, tr("Warning"),
+				     "Your local Bluetooth device cannot be accessed. Please check if you have installed qtconnectivity library.");
+		return;
+	}
+
+	ui->setupUi(this);
+
+	/* Quit button callbacks*/
+	QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
+	connect(quit, SIGNAL(activated()), this, SLOT(close()));
+	connect(ui->quit, SIGNAL(clicked()), this, SLOT(close()));
+
+	/* Disable the save button because there is no device selected */
+	ui->save->setEnabled(false);
+
+	connect(ui->discoveredDevicesList, SIGNAL(itemActivated(QListWidgetItem*)),
+		this, SLOT(itemActivated(QListWidgetItem*)));
+
+	/* Set UI information about the local device */
+	ui->deviceAddress->setText(localDevice->address().toString());
+	ui->deviceName->setText(localDevice->name());
+
+	connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
+		this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
+
+	/* Initialize the state of the local device and activate/deactive the scan button */
+	hostModeStateChanged(localDevice->hostMode());
+
+	/* Intialize the discovery agent */
+	remoteDeviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent();
+
+	connect(remoteDeviceDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
+		this, SLOT(addRemoteDevice(QBluetoothDeviceInfo)));
+	connect(remoteDeviceDiscoveryAgent, SIGNAL(finished()),
+		this, SLOT(remoteDeviceScanFinished()));
+
+	/* Add context menu for devices to be able to pair them */
+	ui->discoveredDevicesList->setContextMenuPolicy(Qt::CustomContextMenu);
+	connect(ui->discoveredDevicesList, SIGNAL(customContextMenuRequested(QPoint)),
+		this, SLOT(displayPairingMenu(QPoint)));
+	connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress, QBluetoothLocalDevice::Pairing)),
+		this, SLOT(pairingFinished(QBluetoothAddress, QBluetoothLocalDevice::Pairing)));
+
+	connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)),
+		this, SLOT(error(QBluetoothLocalDevice::Error)));
+}
+
+BtDeviceSelectionDialog::~BtDeviceSelectionDialog()
+{
+	delete ui;
+}
+
+void BtDeviceSelectionDialog::on_changeDeviceState_clicked()
+{
+	if (localDevice->hostMode() == QBluetoothLocalDevice::HostPoweredOff) {
+		ui->dialogStatus->setText("Trying to turn on the local Bluetooth device...");
+		localDevice->powerOn();
+	} else {
+		ui->dialogStatus->setText("Trying to turn off the local Bluetooth device...");
+		localDevice->setHostMode(QBluetoothLocalDevice::HostPoweredOff);
+	}
+}
+
+void BtDeviceSelectionDialog::on_save_clicked()
+{
+	qDebug() << "Saving the selected device";
+
+	/* Get the selected device. There will be always a selected device if the save button is enabled. */
+	QListWidgetItem *currentItem = ui->discoveredDevicesList->currentItem();
+	QBluetoothDeviceInfo remoteDeviceInfo = currentItem->data(Qt::UserRole).value<QBluetoothDeviceInfo>();
+
+	/* Save the selected device */
+	selectedRemoteDeviceInfo = QSharedPointer<QBluetoothDeviceInfo>(new QBluetoothDeviceInfo(remoteDeviceInfo));
+
+	/* Emit the signal */
+	emit selectedRemoteDeviceSaved(getSelectedDeviceAddress());
+
+	/* Close the device selection dialog */
+	close();
+}
+
+void BtDeviceSelectionDialog::on_clear_clicked()
+{
+	ui->dialogStatus->setText("Remote devices list was cleaned.");
+	ui->discoveredDevicesList->clear();
+	ui->save->setEnabled(false);
+}
+
+void BtDeviceSelectionDialog::on_scan_clicked()
+{
+	ui->dialogStatus->setText("Scanning for remote devices...");
+	remoteDeviceDiscoveryAgent->start();
+	ui->scan->setEnabled(false);
+}
+
+void BtDeviceSelectionDialog::remoteDeviceScanFinished()
+{
+	ui->dialogStatus->setText("Scanning finished.");
+	ui->scan->setEnabled(true);
+}
+
+void BtDeviceSelectionDialog::hostModeStateChanged(QBluetoothLocalDevice::HostMode mode)
+{
+	bool on = !(mode == QBluetoothLocalDevice::HostPoweredOff);
+
+	ui->dialogStatus->setText(QString("The local Bluetooth device was turned %1.")
+				  .arg(on? "ON" : "OFF"));
+	ui->deviceState->setChecked(on);
+	ui->scan->setEnabled(on);
+}
+
+void BtDeviceSelectionDialog::addRemoteDevice(const QBluetoothDeviceInfo &remoteDeviceInfo)
+{
+	//TODO use a QTableView
+	QString deviceLable = QString("%1  (%2)").arg(remoteDeviceInfo.name()).arg(remoteDeviceInfo.address().toString());
+	QList<QListWidgetItem *> itemsWithSameSignature = ui->discoveredDevicesList->findItems(deviceLable, Qt::MatchStartsWith);
+
+	/* Check if the remote device is already in the list */
+	if (itemsWithSameSignature.empty()) {
+		QListWidgetItem *item = new QListWidgetItem(deviceLable);
+		QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(remoteDeviceInfo.address());
+		item->setData(Qt::UserRole, QVariant::fromValue(remoteDeviceInfo));
+
+		if (pairingStatus == QBluetoothLocalDevice::Paired) {
+			item->setText(QString("%1   [State: PAIRED]").arg(item->text()));
+			item->setBackgroundColor(QColor(Qt::gray));
+		} else if (pairingStatus == QBluetoothLocalDevice::AuthorizedPaired) {
+			item->setText(QString("%1   [State: AUTHORIZED_PAIRED]").arg(item->text()));
+			item->setBackgroundColor(QColor(Qt::blue));
+		} else {
+			item->setText(QString("%1   [State: UNPAIRED]").arg(item->text()));
+			item->setTextColor(QColor(Qt::black));
+		}
+
+		ui->discoveredDevicesList->addItem(item);
+	}
+}
+
+void BtDeviceSelectionDialog::itemActivated(QListWidgetItem *item)
+{
+	QBluetoothDeviceInfo remoteDeviceInfo = item->data(Qt::UserRole).value<QBluetoothDeviceInfo>();
+	QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(remoteDeviceInfo.address());
+
+	if (pairingStatus == QBluetoothLocalDevice::Unpaired) {
+		ui->dialogStatus->setText(QString("The device %1 must be paired in order to be used. Please use the context menu for pairing options.")
+					  .arg(remoteDeviceInfo.address().toString()));
+		ui->save->setEnabled(false);
+	} else {
+		ui->dialogStatus->setText(QString("The device %1 can be used for connection. You can press the Save button.")
+					  .arg(remoteDeviceInfo.address().toString()));
+		ui->save->setEnabled(true);
+	}
+}
+
+void BtDeviceSelectionDialog::displayPairingMenu(const QPoint &pos)
+{
+	QMenu menu(this);
+	QAction *pairAction = menu.addAction("Pair");
+	QAction *removePairAction = menu.addAction("Remove Pairing");
+	QAction *chosenAction = menu.exec(ui->discoveredDevicesList->viewport()->mapToGlobal(pos));
+	QListWidgetItem *currentItem = ui->discoveredDevicesList->currentItem();
+	QBluetoothDeviceInfo currentRemoteDeviceInfo = currentItem->data(Qt::UserRole).value<QBluetoothDeviceInfo>();
+	QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(currentRemoteDeviceInfo.address());
+
+	//TODO: disable the actions
+	if (pairingStatus == QBluetoothLocalDevice::Unpaired) {
+		pairAction->setEnabled(true);
+		removePairAction->setEnabled(false);
+	} else {
+		pairAction->setEnabled(false);
+		removePairAction->setEnabled(true);
+	}
+
+	if (chosenAction == pairAction) {
+		ui->dialogStatus->setText(QString("Trying to pair device %1")
+					  .arg(currentRemoteDeviceInfo.address().toString()));
+		localDevice->requestPairing(currentRemoteDeviceInfo.address(), QBluetoothLocalDevice::Paired);
+	} else if (chosenAction == removePairAction) {
+		ui->dialogStatus->setText(QString("Trying to unpair device %1")
+					  .arg(currentRemoteDeviceInfo.address().toString()));
+		localDevice->requestPairing(currentRemoteDeviceInfo.address(), QBluetoothLocalDevice::Unpaired);
+	}
+}
+
+void BtDeviceSelectionDialog::pairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing)
+{
+	QString remoteDeviceStringAddress = address.toString();
+	QList<QListWidgetItem *> items = ui->discoveredDevicesList->findItems(remoteDeviceStringAddress, Qt::MatchContains);
+
+	if (pairing == QBluetoothLocalDevice::Paired || pairing == QBluetoothLocalDevice::Paired ) {
+		ui->dialogStatus->setText(QString("Device %1 was paired.")
+					  .arg(remoteDeviceStringAddress));
+
+		for (int i = 0; i < items.count(); ++i) {
+			QListWidgetItem *item = items.at(i);
+
+			item->setText(QString("%1   [State: PAIRED]").arg(remoteDeviceStringAddress));
+			item->setBackgroundColor(QColor(Qt::gray));
+		}
+
+		QListWidgetItem *currentItem = ui->discoveredDevicesList->currentItem();
+
+		if (currentItem != NULL && currentItem->text().contains(remoteDeviceStringAddress, Qt::CaseInsensitive)) {
+			ui->dialogStatus->setText(QString("The device %1 can now be used for connection. You can press the Save button.")
+						  .arg(remoteDeviceStringAddress));
+			ui->save->setEnabled(true);
+		}
+	} else {
+		ui->dialogStatus->setText(QString("Device %1 was unpaired.")
+					  .arg(remoteDeviceStringAddress));
+
+		for (int i = 0; i < items.count(); ++i) {
+			QListWidgetItem *item = items.at(i);
+
+			item->setText(QString("%1   [State: UNPAIRED]").arg(remoteDeviceStringAddress));
+			item->setBackgroundColor(QColor(Qt::white));
+		}
+
+		QListWidgetItem *currentItem = ui->discoveredDevicesList->currentItem();
+
+		if (currentItem != NULL && currentItem->text().contains(remoteDeviceStringAddress, Qt::CaseInsensitive)) {
+			ui->dialogStatus->setText(QString("The device %1 must be paired in order to be used. Please use the context menu for pairing options.")
+						  .arg(remoteDeviceStringAddress));
+			ui->save->setEnabled(false);
+		}
+	}
+}
+
+void BtDeviceSelectionDialog::error(QBluetoothLocalDevice::Error error)
+{
+	ui->dialogStatus->setText(QString("Local device error: %1.")
+				  .arg((error == QBluetoothLocalDevice::PairingError)? "Pairing error" : "Unknown error"));
+}
+
+QString BtDeviceSelectionDialog::getSelectedDeviceAddress()
+{
+	if (selectedRemoteDeviceInfo) {
+		return selectedRemoteDeviceInfo.data()->address().toString();
+	}
+
+	return QString();
+}
diff --git a/qt-ui/btdeviceselectiondialog.h b/qt-ui/btdeviceselectiondialog.h
new file mode 100644
index 0000000..317f679
--- /dev/null
+++ b/qt-ui/btdeviceselectiondialog.h
@@ -0,0 +1,48 @@
+#ifndef BTDEVICESELECTIONDIALOG_H
+#define BTDEVICESELECTIONDIALOG_H
+
+#include <QDialog>
+#include <QListWidgetItem>
+#include <QPointer>
+#include <QtBluetooth/QBluetoothLocalDevice>
+#include <QtBluetooth/qbluetoothglobal.h>
+#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
+
+Q_DECLARE_METATYPE(QBluetoothDeviceInfo)
+
+namespace Ui {
+	class BtDeviceSelectionDialog;
+}
+
+class BtDeviceSelectionDialog : public QDialog {
+	Q_OBJECT
+
+public:
+	explicit BtDeviceSelectionDialog(QWidget *parent = 0);
+	~BtDeviceSelectionDialog();
+	QString getSelectedDeviceAddress();
+
+signals:
+	void selectedRemoteDeviceSaved(QString deviceAddress);
+
+private slots:
+	void on_changeDeviceState_clicked();
+	void on_save_clicked();
+	void on_clear_clicked();
+	void on_scan_clicked();
+	void remoteDeviceScanFinished();
+	void hostModeStateChanged(QBluetoothLocalDevice::HostMode mode);
+	void addRemoteDevice(const QBluetoothDeviceInfo &remoteDeviceInfo);
+	void itemActivated(QListWidgetItem *item);
+	void displayPairingMenu(const QPoint &pos);
+	void pairingFinished(const QBluetoothAddress &address,QBluetoothLocalDevice::Pairing pairing);
+	void error(QBluetoothLocalDevice::Error error);
+
+private:
+	Ui::BtDeviceSelectionDialog *ui;
+	QBluetoothLocalDevice *localDevice;
+	QBluetoothDeviceDiscoveryAgent *remoteDeviceDiscoveryAgent;
+	QSharedPointer<QBluetoothDeviceInfo> selectedRemoteDeviceInfo;
+};
+
+#endif // BTDEVICESELECTIONDIALOG_H
diff --git a/qt-ui/btdeviceselectiondialog.ui b/qt-ui/btdeviceselectiondialog.ui
new file mode 100644
index 0000000..345cd13
--- /dev/null
+++ b/qt-ui/btdeviceselectiondialog.ui
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BtDeviceSelectionDialog</class>
+ <widget class="QDialog" name="BtDeviceSelectionDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>735</width>
+    <height>460</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Remote Bluetooth device selection</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="discoveredDevicesLabel">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="font">
+      <font>
+       <weight>75</weight>
+       <bold>true</bold>
+      </font>
+     </property>
+     <property name="text">
+      <string>Discovered devices</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <layout class="QHBoxLayout" name="dialogControls">
+     <item>
+      <widget class="QPushButton" name="save">
+       <property name="text">
+        <string>Save</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="quit">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Quit</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0" rowspan="2">
+    <layout class="QVBoxLayout" name="remoteDevicesSection">
+     <item>
+      <widget class="QListWidget" name="discoveredDevicesList">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="scanningControls">
+       <item>
+        <widget class="QPushButton" name="scan">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Scan</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="clear">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Clear</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="1">
+    <widget class="QGroupBox" name="localDeviceDetails">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="font">
+      <font>
+       <weight>75</weight>
+       <bold>true</bold>
+      </font>
+     </property>
+     <property name="title">
+      <string>Local Bluetooth device details</string>
+     </property>
+     <property name="flat">
+      <bool>false</bool>
+     </property>
+     <layout class="QFormLayout" name="formLayout_2">
+      <item row="0" column="0">
+       <widget class="QLabel" name="deviceNameLable">
+        <property name="text">
+         <string>Name: </string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLineEdit" name="deviceName">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="deviceAddressLable">
+        <property name="text">
+         <string>Address:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLineEdit" name="deviceAddress">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QCheckBox" name="deviceState">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="text">
+         <string>Bluetooth powered on</string>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1">
+       <widget class="QPushButton" name="changeDeviceState">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <weight>50</weight>
+          <bold>false</bold>
+         </font>
+        </property>
+        <property name="text">
+         <string>Turn On/Off</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="dialogStatus">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
-- 
2.1.4

From 2b9b5dad9cd7861896f4ea777cbacf9836cf77b6 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 03:38:33 +0300
Subject: [PATCH 3/9] Add dependencies for Qt Bluetooth libraries and for
 BtSelectionDialog sources

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c262959..cbe4592 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,8 +139,8 @@ endif()
 if(SUBSURFACE_MOBILE)
 	set(QT_QUICK Quick)
 endif()
-find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network WebKitWidgets PrintSupport Svg Test LinguistTools ${QT_QUICK})
-set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::WebKitWidgets Qt5::PrintSupport Qt5::Svg)
+find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network WebKitWidgets PrintSupport Svg Test LinguistTools ${QT_QUICK} Bluetooth)
+set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::WebKitWidgets Qt5::PrintSupport Qt5::Svg Qt5::Bluetooth)
 if(SUBSURFACE_MOBILE)
 	set(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Quick)
 endif()
@@ -326,6 +326,7 @@ source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS})
 set(SUBSURFACE_INTERFACE
 	qt-ui/updatemanager.cpp
 	qt-ui/about.cpp
+	qt-ui/btdeviceselectiondialog.cpp
 	qt-ui/divecomputermanagementdialog.cpp
 	qt-ui/divelistview.cpp
 	qt-ui/diveplanner.cpp
-- 
2.1.4

From 634489b8f11f6c5644fb6e8a44ae1ae56edb96c2 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 03:40:24 +0300
Subject: [PATCH 4/9] Create a Bluetooth device selection dialog

Create a Bluetooth device selection dialog when the
bluetoothMode checkbox is enabled or the button is
pressed.

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 qt-ui/downloadfromdivecomputer.cpp | 17 +++++++++++++++--
 qt-ui/downloadfromdivecomputer.h   |  3 +++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 838a9e5..8791aa3 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -99,6 +99,8 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
 	ui.ok->setEnabled(false);
 	ui.downloadCancelRetryButton->setEnabled(true);
 	ui.downloadCancelRetryButton->setText(tr("Download"));
+
+	btDeviceSelectionDialog = 0;
 	ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
 	connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
 	connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice()));
@@ -523,8 +525,19 @@ void DownloadFromDCWidget::markChildrenAsEnabled()
 
 void DownloadFromDCWidget::selectRemoteBluetoothDevice()
 {
-	qWarning() << "Selecting a remote Bluetooth device...";
-	//TODO add implementation
+	if (!btDeviceSelectionDialog) {
+		btDeviceSelectionDialog = new BtDeviceSelectionDialog(this);
+		connect(btDeviceSelectionDialog, SIGNAL(selectedRemoteDeviceSaved(QString)),
+			this, SLOT(saveRemoteBluetoothDevice(QString)));
+	}
+
+	btDeviceSelectionDialog->show();
+}
+
+void DownloadFromDCWidget::saveRemoteBluetoothDevice(QString deviceAddress)
+{
+	/* Make the selected Bluetooth device default */
+	ui.device->setCurrentText(deviceAddress);
 }
 
 void DownloadFromDCWidget::enableBluetoothMode(int state)
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index 0b63d28..464f56f 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -10,6 +10,7 @@
 #include "libdivecomputer.h"
 #include "configuredivecomputerdialog.h"
 #include "ui_downloadfromdivecomputer.h"
+#include "btdeviceselectiondialog.h"
 
 class QStringListModel;
 
@@ -81,6 +82,7 @@ slots:
 	void pickDumpFile();
 	void pickLogFile();
 	void selectRemoteBluetoothDevice();
+	void saveRemoteBluetoothDevice(QString deviceAddress);
 
 private:
 	void markChildrenAsDisabled();
@@ -106,6 +108,7 @@ private:
 	bool dumpWarningShown;
 	OstcFirmwareCheck *ostcFirmwareCheck;
 	DiveImportedModel *diveImportedModel;
+	BtDeviceSelectionDialog *btDeviceSelectionDialog;
 
 public:
 	bool preferDownloaded();
-- 
2.1.4

From befbd753da20621aa7ab730c5cb585ed3d29bcd2 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 04:07:01 +0300
Subject: [PATCH 5/9] Add a skelet for Bluetooth serial communication

Create the structure of the Bluetooth serial communication.

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 CMakeLists.txt        |  1 +
 qtserialbluetooth.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
 create mode 100644 qtserialbluetooth.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbe4592..a3e2807 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -288,6 +288,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
 	windowtitleupdate.cpp
 	divelogexportlogic.cpp
 	qt-init.cpp
+	qtserialbluetooth.cpp
 	${PLATFORM_SRC}
 )
 source_group("Subsurface Core" FILES ${SUBSURFACE_CORE_LIB_SRCS})
diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
new file mode 100644
index 0000000..648482e
--- /dev/null
+++ b/qtserialbluetooth.cpp
@@ -0,0 +1,54 @@
+#include <libdivecomputer/custom_serial.h>
+
+static int qt_serial_open(serial_t **device, dc_context_t *context, const char* devaddr)
+{
+	return 0;
+}
+
+static int qt_serial_close(serial_t *device)
+{
+	return 0;
+}
+
+static int qt_serial_read(serial_t *device, void* data, unsigned int size)
+{
+	return 0;
+}
+
+static int qt_serial_write(serial_t *device, const void* data, unsigned int size)
+{
+	return 0;
+}
+
+static int qt_serial_flush(serial_t *device, int queue)
+{
+	return 0;
+}
+
+static int qt_serial_get_received(serial_t *device)
+{
+	return 0;
+}
+
+static int qt_serial_get_transmitted(serial_t *device)
+{
+	return 0;
+}
+
+
+const dc_serial_operations_t qt_serial_ops = {
+	.open = qt_serial_open,
+	.close = qt_serial_close,
+	.read = qt_serial_read,
+	.write = qt_serial_write,
+	.flush = qt_serial_flush,
+	.get_received = qt_serial_get_received,
+	.get_transmitted = qt_serial_get_transmitted
+};
+
+extern void dc_serial_init (dc_serial_t *serial, void *data, const dc_serial_operations_t *ops);
+
+dc_status_t dc_serial_qt_open(dc_serial_t **out, dc_context_t *context, const char *devaddr)
+{
+	return DC_STATUS_SUCCESS;
+}
-- 
2.1.4

From 66bc1f02f9fcce65ab0fb40bdeb229696abb5cc0 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 04:10:47 +0300
Subject: [PATCH 6/9] Implement the Qt Bluetooth serial communication

Implement the functions needed for a basic Bluetooth serial
communication.

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 qtserialbluetooth.cpp | 175 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 167 insertions(+), 8 deletions(-)

diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index 648482e..5842c2a 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -1,38 +1,170 @@
+#include <errno.h>
+
+#include <QtBluetooth/QBluetoothAddress>
+#include <QtBluetooth/QBluetoothSocket>
+#include <QEventLoop>
+
 #include <libdivecomputer/custom_serial.h>
 
-static int qt_serial_open(serial_t **device, dc_context_t *context, const char* devaddr)
+typedef struct serial_t {
+	/* Library context. */
+	dc_context_t *context;
+	/*
+	 * RFCOMM socket used for Bluetooth Serial communication.
+	 */
+	QBluetoothSocket *socket;
+	long timeout;
+} serial_t;
+
+static int qt_serial_open(serial_t **out, dc_context_t *context, const char* devaddr)
 {
-	return 0;
+	if (out == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	// Allocate memory.
+	serial_t *device = (serial_t *) malloc (sizeof (serial_t));
+	if (device == NULL) {
+		return DC_STATUS_NOMEMORY;
+	}
+
+	// Library context.
+	device->context = context;
+
+	// Default to blocking reads.
+	device->timeout = -1;
+
+	// Create a RFCOMM socket
+	device->socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
+
+	// Wait until the connection succeeds or until an error occurs
+	QEventLoop loop;
+	loop.connect(device->socket, SIGNAL(connected()), SLOT(quit()));
+	loop.connect(device->socket, SIGNAL(error(QBluetoothSocket::SocketError)), SLOT(quit()));
+	// Try to connect to the Serial Port Profile service
+	device->socket->connectToService(QBluetoothAddress(devaddr), QBluetoothUuid::SerialPort);
+	loop.exec();
+
+	if (device->socket->socketDescriptor() == -1) {
+		free (device);
+
+		// Get the latest error and try to match it with one from libdivecomputer
+		QBluetoothSocket::SocketError err = device->socket->error();
+		switch(err) {
+		case QBluetoothSocket::HostNotFoundError:
+		case QBluetoothSocket::ServiceNotFoundError:
+			return DC_STATUS_NODEVICE;
+		case QBluetoothSocket::UnsupportedProtocolError:
+			return DC_STATUS_PROTOCOL;
+		case QBluetoothSocket::OperationError:
+			return DC_STATUS_UNSUPPORTED;
+		case QBluetoothSocket::NetworkError:
+			return DC_STATUS_IO;
+		default:
+			return QBluetoothSocket::UnknownSocketError;
+		}
+	}
+
+	*out = device;
+
+	return DC_STATUS_SUCCESS;
 }
 
 static int qt_serial_close(serial_t *device)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_SUCCESS;
+
+	device->socket->close();
+
+	delete device->socket;
+	free(device);
+
+	return DC_STATUS_SUCCESS;
 }
 
 static int qt_serial_read(serial_t *device, void* data, unsigned int size)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	unsigned int nbytes = 0, rc;
+
+	while(nbytes < size)
+	{
+		device->socket->waitForReadyRead(device->timeout);
+
+		rc = device->socket->read((char *) data + nbytes, size - nbytes);
+
+		if (rc < 0) {
+			if (errno == EINTR)
+			    continue; // Retry.
+
+			return -1; // Something really bad happened :-(
+		} else if (rc == 0) {
+			// Wait until the device is available for read operations
+			QEventLoop loop;
+			loop.connect(device->socket, SIGNAL(readyRead()), SLOT(quit()));
+			loop.exec();
+		}
+
+		nbytes += rc;
+	}
+
+	return nbytes;
 }
 
 static int qt_serial_write(serial_t *device, const void* data, unsigned int size)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	unsigned int nbytes = 0, rc;
+
+	while(nbytes < size)
+	{
+		device->socket->waitForBytesWritten(device->timeout);
+
+		rc = device->socket->write((char *) data + nbytes, size - nbytes);
+
+		if (rc < 0) {
+			if (errno == EINTR || errno == EAGAIN)
+			    continue; // Retry.
+
+			return -1; // Something really bad happened :-(
+		} else if (rc == 0) {
+			break;
+		}
+
+		nbytes += rc;
+	}
+
+	return nbytes;
 }
 
 static int qt_serial_flush(serial_t *device, int queue)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	//TODO: add implementation
+
+	return DC_STATUS_SUCCESS;
 }
 
 static int qt_serial_get_received(serial_t *device)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	return device->socket->bytesAvailable();
 }
 
 static int qt_serial_get_transmitted(serial_t *device)
 {
-	return 0;
+	if (device == NULL || device->socket == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	return device->socket->bytesToWrite();
 }
 
 
@@ -50,5 +182,32 @@ extern void dc_serial_init (dc_serial_t *serial, void *data, const dc_serial_ope
 
 dc_status_t dc_serial_qt_open(dc_serial_t **out, dc_context_t *context, const char *devaddr)
 {
+	if (out == NULL)
+		return DC_STATUS_INVALIDARGS;
+
+	// Allocate memory.
+	dc_serial_t *serial_device = (dc_serial_t *) malloc (sizeof (dc_serial_t));
+
+	if (serial_device == NULL) {
+		return DC_STATUS_NOMEMORY;
+	}
+
+	serial_t *port;
+
+	// Open the serial device.
+	int rc = qt_serial_open (&port, context, devaddr);
+	if (rc == -1) {
+		free (serial_device);
+		return DC_STATUS_IO;
+	}
+
+	// Initialize data and function pointers
+	dc_serial_init(serial_device, (void*)port, &qt_serial_ops);
+
+	// Set the type of the device
+	serial_device->type = DC_TRANSPORT_BLUETOOTH;
+
+	*out = serial_device;
+
 	return DC_STATUS_SUCCESS;
 }
-- 
2.1.4

From 8095c8d061da104715469e8c7e10d4848a179c31 Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 04:13:45 +0300
Subject: [PATCH 7/9] Make the qt_serial_open method callable from C

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 qtserialbluetooth.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index 5842c2a..5a2b3be 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -6,6 +6,7 @@
 
 #include <libdivecomputer/custom_serial.h>
 
+extern "C" {
 typedef struct serial_t {
 	/* Library context. */
 	dc_context_t *context;
@@ -211,3 +212,4 @@ dc_status_t dc_serial_qt_open(dc_serial_t **out, dc_context_t *context, const ch
 
 	return DC_STATUS_SUCCESS;
 }
+}
-- 
2.1.4

From f18a25a44053167485fa6ed9a312e1f87a57c4cc Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 04:28:31 +0300
Subject: [PATCH 8/9] Use the Qt Bluetooth serial implementation when it is
 activated

When the Bluetooth mode checkbox is enabled open our custom
implementation of the serial communication.

Signed-off-by: Claudiu Olteanu <olteanu.clau...@ymail.com>
---
 libdivecomputer.c                  | 22 +++++++++++++++++++---
 libdivecomputer.h                  |  3 +++
 qt-ui/downloadfromdivecomputer.cpp |  1 +
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/libdivecomputer.c b/libdivecomputer.c
index ef6e4f8..f027886 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -917,14 +917,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->bluetoothMode) {
+		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;
diff --git a/libdivecomputer.h b/libdivecomputer.h
index dfb6267..f1a04c6 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -37,6 +37,7 @@ typedef struct device_data_t
 	bool create_new_trip;
 	bool libdc_log;
 	bool libdc_dump;
+	bool bluetoothMode;
 	FILE *libdc_logfile;
 	struct dive_table *download_table;
 } device_data_t;
@@ -53,6 +54,8 @@ extern double progress_bar_fraction;
 extern char *logfile_name;
 extern char *dumpfile_name;
 
+extern dc_status_t dc_serial_qt_open(dc_serial_t **out, dc_context_t *context, const char *devaddr);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 8791aa3..d9d1c65 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -330,6 +330,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
 	data.create_new_trip = ui.createNewTrip->isChecked();
 	data.trip = NULL;
 	data.deviceid = data.diveid = 0;
+	data.bluetoothMode = ui.bluetoothMode->isChecked();
 	set_default_dive_computer(data.vendor, data.product);
 	set_default_dive_computer_device(data.devname);
 
-- 
2.1.4

From 4bac95ad4129beb41d2cc3510bd82defaea5751b Mon Sep 17 00:00:00 2001
From: Claudiu Olteanu <olteanu.clau...@ymail.com>
Date: Fri, 26 Jun 2015 04:35:39 +0300
Subject: [PATCH 9/9] Fake the custom open function for OSTC 2N devices

If 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.clau...@ymail.com>
---
 configuredivecomputerthreads.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index 5c610db..e074660 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -82,6 +82,16 @@ static dc_status_t local_dc_device_open(dc_device_t **out, dc_context_t *context
 }
 #define dc_device_open local_dc_device_open
 
+// Fake the custom open function
+static dc_status_t local_dc_device_custom_open(dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, dc_serial_t *serial)
+{
+	if (strcmp(dc_descriptor_get_vendor(descriptor), "Heinrichs Weikamp") == 0 &&strcmp(dc_descriptor_get_product(descriptor), "OSTC 2N") == 0)
+		return DC_STATUS_SUCCESS;
+	else
+		return dc_device_custom_open(out, context, descriptor, serial);
+}
+#define dc_device_custom_open local_dc_device_custom_open
+
 static dc_status_t local_hw_ostc_device_eeprom_read(void *ignored, unsigned char bank, unsigned char data[], unsigned int data_size)
 {
 	FILE *f;
-- 
2.1.4

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to