mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Connect up custom serial in dc configuration
This connects up the custom serial code in the configure dive computer dialogs. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a42df06dbf
commit
5472036931
4 changed files with 65 additions and 5 deletions
|
@ -632,7 +632,28 @@ QString ConfigureDiveComputer::dc_open(device_data_t *data)
|
||||||
dc_context_set_logfunc(data->context, logfunc, fp);
|
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) {
|
if (rc != DC_STATUS_SUCCESS) {
|
||||||
return tr("Could not a establish connection to the dive computer.");
|
return tr("Could not a establish connection to the dive computer.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,8 @@ void GasTypeComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemMod
|
||||||
|
|
||||||
ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent),
|
ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent),
|
||||||
config(0),
|
config(0),
|
||||||
deviceDetails(0)
|
deviceDetails(0),
|
||||||
|
btDeviceSelectionDialog(0)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
@ -133,6 +134,11 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia
|
||||||
connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int)));
|
connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int)));
|
||||||
connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(dc_open()));
|
connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(dc_open()));
|
||||||
connect(ui.disconnectButton, SIGNAL(clicked()), this, SLOT(dc_close()));
|
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));
|
memset(&device_data, 0, sizeof(device_data));
|
||||||
fill_computer_list();
|
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()
|
void ConfigureDiveComputerDialog::dc_open()
|
||||||
{
|
{
|
||||||
getDeviceData();
|
getDeviceData();
|
||||||
|
@ -1188,6 +1218,7 @@ void ConfigureDiveComputerDialog::dc_open()
|
||||||
ui.disconnectButton->setEnabled(true);
|
ui.disconnectButton->setEnabled(true);
|
||||||
ui.restoreBackupButton->setEnabled(true);
|
ui.restoreBackupButton->setEnabled(true);
|
||||||
ui.connectButton->setEnabled(false);
|
ui.connectButton->setEnabled(false);
|
||||||
|
ui.bluetoothMode->setEnabled(false);
|
||||||
ui.DiveComputerList->setEnabled(false);
|
ui.DiveComputerList->setEnabled(false);
|
||||||
ui.logToFile->setEnabled(false);
|
ui.logToFile->setEnabled(false);
|
||||||
if (fw_upgrade_possible)
|
if (fw_upgrade_possible)
|
||||||
|
@ -1204,6 +1235,7 @@ void ConfigureDiveComputerDialog::dc_close()
|
||||||
ui.updateFirmwareButton->setEnabled(false);
|
ui.updateFirmwareButton->setEnabled(false);
|
||||||
ui.disconnectButton->setEnabled(false);
|
ui.disconnectButton->setEnabled(false);
|
||||||
ui.connectButton->setEnabled(true);
|
ui.connectButton->setEnabled(true);
|
||||||
|
ui.bluetoothMode->setEnabled(true);
|
||||||
ui.backupButton->setEnabled(false);
|
ui.backupButton->setEnabled(false);
|
||||||
ui.saveSettingsPushButton->setEnabled(false);
|
ui.saveSettingsPushButton->setEnabled(false);
|
||||||
ui.restoreBackupButton->setEnabled(false);
|
ui.restoreBackupButton->setEnabled(false);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "configuredivecomputer.h"
|
#include "configuredivecomputer.h"
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
#include "btdeviceselectiondialog.h"
|
||||||
|
|
||||||
class GasSpinBoxItemDelegate : public QStyledItemDelegate {
|
class GasSpinBoxItemDelegate : public QStyledItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -84,6 +85,11 @@ slots:
|
||||||
void dc_open();
|
void dc_open();
|
||||||
void dc_close();
|
void dc_close();
|
||||||
|
|
||||||
|
#if BT_SUPPORT
|
||||||
|
void bluetoothSelectionDialogIsFinished(int result);
|
||||||
|
void selectRemoteBluetoothDevice();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConfigureDiveComputerDialog ui;
|
Ui::ConfigureDiveComputerDialog ui;
|
||||||
|
|
||||||
|
@ -112,6 +118,8 @@ private:
|
||||||
QString selected_vendor;
|
QString selected_vendor;
|
||||||
QString selected_product;
|
QString selected_product;
|
||||||
bool fw_upgrade_possible;
|
bool fw_upgrade_possible;
|
||||||
|
|
||||||
|
BtDeviceSelectionDialog *btDeviceSelectionDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OstcFirmwareCheck : QObject {
|
class OstcFirmwareCheck : QObject {
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="search">
|
<widget class="QPushButton" name="bluetoothMode">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>Connect via bluetooth</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -2602,7 +2602,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>device</tabstop>
|
<tabstop>device</tabstop>
|
||||||
<tabstop>search</tabstop>
|
|
||||||
<tabstop>retrieveDetails</tabstop>
|
<tabstop>retrieveDetails</tabstop>
|
||||||
<tabstop>saveSettingsPushButton</tabstop>
|
<tabstop>saveSettingsPushButton</tabstop>
|
||||||
<tabstop>backupButton</tabstop>
|
<tabstop>backupButton</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue