summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configuredivecomputer.cpp23
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp34
-rw-r--r--qt-ui/configuredivecomputerdialog.h8
-rw-r--r--qt-ui/configuredivecomputerdialog.ui5
4 files changed, 65 insertions, 5 deletions
diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp
index 9e03bc66e..1262492de 100644
--- a/configuredivecomputer.cpp
+++ b/configuredivecomputer.cpp
@@ -632,7 +632,28 @@ QString ConfigureDiveComputer::dc_open(device_data_t *data)
dc_context_set_logfunc(data->context, logfunc, fp);
}
- rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
+#if defined(SSRF_CUSTOM_SERIAL)
+ dc_serial_t *serial_device = NULL;
+
+ if (data->bluetooth_mode) {
+ rc = dc_serial_qt_open(&serial_device, data->context, data->devname);
+#ifdef SERIAL_FTDI
+ } else if (!strcmp(data->devname, "ftdi")) {
+ rc = dc_serial_ftdi_open(&serial_device, data->context);
+#endif
+ }
+
+ if (rc != DC_STATUS_SUCCESS) {
+ return errmsg(rc);
+ } else if (serial_device) {
+ rc = dc_device_custom_open(&data->device, data->context, data->descriptor, serial_device);
+ } else {
+#else
+ {
+#endif
+ rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
+ }
+
if (rc != DC_STATUS_SUCCESS) {
return tr("Could not a establish connection to the dive computer.");
}
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index 537b23121..acebcfa33 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -115,7 +115,8 @@ void GasTypeComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemMod
ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent),
config(0),
- deviceDetails(0)
+ deviceDetails(0),
+ btDeviceSelectionDialog(0)
{
ui.setupUi(this);
@@ -133,6 +134,11 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia
connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int)));
connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(dc_open()));
connect(ui.disconnectButton, SIGNAL(clicked()), this, SLOT(dc_close()));
+#if BT_SUPPORT
+ connect(ui.bluetoothMode, SIGNAL(clicked(bool)), this, SLOT(selectRemoteBluetoothDevice()));
+#else
+ ui.bluetoothMode->setVisible(false);
+#endif
memset(&device_data, 0, sizeof(device_data));
fill_computer_list();
@@ -1173,6 +1179,30 @@ void ConfigureDiveComputerDialog::pickLogFile()
}
}
+#ifdef BT_SUPPORT
+void ConfigureDiveComputerDialog::selectRemoteBluetoothDevice()
+{
+ if (!btDeviceSelectionDialog) {
+ btDeviceSelectionDialog = new BtDeviceSelectionDialog(this);
+ connect(btDeviceSelectionDialog, SIGNAL(finished(int)),
+ this, SLOT(bluetoothSelectionDialogIsFinished(int)));
+ }
+
+ btDeviceSelectionDialog->show();
+}
+
+void ConfigureDiveComputerDialog::bluetoothSelectionDialogIsFinished(int result)
+{
+ if (result == QDialog::Accepted) {
+ ui.device->setCurrentText(btDeviceSelectionDialog->getSelectedDeviceAddress());
+ device_data.bluetooth_mode = true;
+
+ ui.progressBar->setFormat("Connecting to device...");
+ dc_open();
+ }
+}
+#endif
+
void ConfigureDiveComputerDialog::dc_open()
{
getDeviceData();
@@ -1188,6 +1218,7 @@ void ConfigureDiveComputerDialog::dc_open()
ui.disconnectButton->setEnabled(true);
ui.restoreBackupButton->setEnabled(true);
ui.connectButton->setEnabled(false);
+ ui.bluetoothMode->setEnabled(false);
ui.DiveComputerList->setEnabled(false);
ui.logToFile->setEnabled(false);
if (fw_upgrade_possible)
@@ -1204,6 +1235,7 @@ void ConfigureDiveComputerDialog::dc_close()
ui.updateFirmwareButton->setEnabled(false);
ui.disconnectButton->setEnabled(false);
ui.connectButton->setEnabled(true);
+ ui.bluetoothMode->setEnabled(true);
ui.backupButton->setEnabled(false);
ui.saveSettingsPushButton->setEnabled(false);
ui.restoreBackupButton->setEnabled(false);
diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h
index d11726873..7092e9708 100644
--- a/qt-ui/configuredivecomputerdialog.h
+++ b/qt-ui/configuredivecomputerdialog.h
@@ -8,6 +8,7 @@
#include "configuredivecomputer.h"
#include <QStyledItemDelegate>
#include <QNetworkAccessManager>
+#include "btdeviceselectiondialog.h"
class GasSpinBoxItemDelegate : public QStyledItemDelegate {
Q_OBJECT
@@ -84,6 +85,11 @@ slots:
void dc_open();
void dc_close();
+#if BT_SUPPORT
+ void bluetoothSelectionDialogIsFinished(int result);
+ void selectRemoteBluetoothDevice();
+#endif
+
private:
Ui::ConfigureDiveComputerDialog ui;
@@ -112,6 +118,8 @@ private:
QString selected_vendor;
QString selected_product;
bool fw_upgrade_possible;
+
+ BtDeviceSelectionDialog *btDeviceSelectionDialog;
};
class OstcFirmwareCheck : QObject {
diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui
index edc24e29e..bdfe8473c 100644
--- a/qt-ui/configuredivecomputerdialog.ui
+++ b/qt-ui/configuredivecomputerdialog.ui
@@ -42,9 +42,9 @@
</widget>
</item>
<item>
- <widget class="QToolButton" name="search">
+ <widget class="QPushButton" name="bluetoothMode">
<property name="text">
- <string>...</string>
+ <string>Connect via bluetooth</string>
</property>
</widget>
</item>
@@ -2602,7 +2602,6 @@
</widget>
<tabstops>
<tabstop>device</tabstop>
- <tabstop>search</tabstop>
<tabstop>retrieveDetails</tabstop>
<tabstop>saveSettingsPushButton</tabstop>
<tabstop>backupButton</tabstop>