2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-05-30 06:56:27 +00:00
|
|
|
#include "configuredivecomputer.h"
|
2015-01-08 22:14:18 +00:00
|
|
|
#include <QTextStream>
|
2014-06-10 16:19:28 +00:00
|
|
|
#include <QFile>
|
2014-06-11 06:37:27 +00:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/parserInternals.h>
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#include <libxslt/transform.h>
|
|
|
|
#include <QStringList>
|
2014-07-06 03:53:42 +00:00
|
|
|
#include <QXmlStreamWriter>
|
2017-09-28 03:00:58 +00:00
|
|
|
#include "core/version.h"
|
2014-06-10 16:19:28 +00:00
|
|
|
|
2014-12-29 04:56:58 +00:00
|
|
|
ConfigureDiveComputer::ConfigureDiveComputer() : readThread(0),
|
2014-10-17 22:33:47 +00:00
|
|
|
writeThread(0),
|
2014-10-20 20:58:21 +00:00
|
|
|
resetThread(0),
|
|
|
|
firmwareThread(0)
|
2014-05-30 06:56:27 +00:00
|
|
|
{
|
|
|
|
setState(INITIAL);
|
|
|
|
}
|
|
|
|
|
2014-06-10 15:25:25 +00:00
|
|
|
void ConfigureDiveComputer::readSettings(device_data_t *data)
|
2014-05-30 06:56:27 +00:00
|
|
|
{
|
|
|
|
setState(READING);
|
|
|
|
|
|
|
|
if (readThread)
|
|
|
|
readThread->deleteLater();
|
|
|
|
|
2014-06-10 15:25:25 +00:00
|
|
|
readThread = new ReadSettingsThread(this, data);
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(readThread, SIGNAL(finished()),
|
2014-07-22 16:38:30 +00:00
|
|
|
this, SLOT(readThreadFinished()), Qt::QueuedConnection);
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
|
2014-12-29 04:56:58 +00:00
|
|
|
connect(readThread, SIGNAL(devicedetails(DeviceDetails *)), this,
|
|
|
|
SIGNAL(deviceDetailsChanged(DeviceDetails *)));
|
2015-01-21 18:05:22 +00:00
|
|
|
connect(readThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
|
2014-05-30 06:56:27 +00:00
|
|
|
|
|
|
|
readThread->start();
|
|
|
|
}
|
|
|
|
|
2014-06-10 15:25:25 +00:00
|
|
|
void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_data_t *data)
|
2014-05-30 07:49:58 +00:00
|
|
|
{
|
2014-06-10 15:25:25 +00:00
|
|
|
setState(WRITING);
|
2014-05-30 07:49:58 +00:00
|
|
|
|
2014-06-10 15:25:25 +00:00
|
|
|
if (writeThread)
|
|
|
|
writeThread->deleteLater();
|
|
|
|
|
|
|
|
writeThread = new WriteSettingsThread(this, data);
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(writeThread, SIGNAL(finished()),
|
2014-07-22 16:38:30 +00:00
|
|
|
this, SLOT(writeThreadFinished()), Qt::QueuedConnection);
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
|
2015-01-21 18:05:22 +00:00
|
|
|
connect(writeThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
|
2014-06-10 15:25:25 +00:00
|
|
|
|
|
|
|
writeThread->setDeviceDetails(details);
|
|
|
|
writeThread->start();
|
2014-06-07 18:56:44 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 15:51:38 +00:00
|
|
|
bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data)
|
2014-06-10 16:19:28 +00:00
|
|
|
{
|
|
|
|
QString xml = "";
|
|
|
|
QString vendor = data->vendor;
|
|
|
|
QString product = data->product;
|
2014-07-06 03:53:42 +00:00
|
|
|
QXmlStreamWriter writer(&xml);
|
|
|
|
writer.setAutoFormatting(true);
|
|
|
|
|
|
|
|
writer.writeStartDocument();
|
|
|
|
writer.writeStartElement("DiveComputerSettingsBackup");
|
|
|
|
writer.writeStartElement("DiveComputer");
|
|
|
|
writer.writeTextElement("Vendor", vendor);
|
|
|
|
writer.writeTextElement("Product", product);
|
|
|
|
writer.writeEndElement();
|
|
|
|
writer.writeStartElement("Settings");
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeTextElement("CustomText", details->customText);
|
2014-06-21 06:31:19 +00:00
|
|
|
//Add gasses
|
|
|
|
QString gas1 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->gas1.oxygen),
|
|
|
|
QString::number(details->gas1.helium),
|
|
|
|
QString::number(details->gas1.type),
|
|
|
|
QString::number(details->gas1.depth));
|
2014-06-21 06:31:19 +00:00
|
|
|
QString gas2 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->gas2.oxygen),
|
|
|
|
QString::number(details->gas2.helium),
|
|
|
|
QString::number(details->gas2.type),
|
|
|
|
QString::number(details->gas2.depth));
|
2014-06-21 06:31:19 +00:00
|
|
|
QString gas3 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->gas3.oxygen),
|
|
|
|
QString::number(details->gas3.helium),
|
|
|
|
QString::number(details->gas3.type),
|
|
|
|
QString::number(details->gas3.depth));
|
2014-06-21 06:31:19 +00:00
|
|
|
QString gas4 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->gas4.oxygen),
|
|
|
|
QString::number(details->gas4.helium),
|
|
|
|
QString::number(details->gas4.type),
|
|
|
|
QString::number(details->gas4.depth));
|
2014-06-21 06:31:19 +00:00
|
|
|
QString gas5 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->gas5.oxygen),
|
|
|
|
QString::number(details->gas5.helium),
|
|
|
|
QString::number(details->gas5.type),
|
|
|
|
QString::number(details->gas5.depth));
|
2014-07-06 03:53:42 +00:00
|
|
|
writer.writeTextElement("Gas1", gas1);
|
|
|
|
writer.writeTextElement("Gas2", gas2);
|
|
|
|
writer.writeTextElement("Gas3", gas3);
|
|
|
|
writer.writeTextElement("Gas4", gas4);
|
|
|
|
writer.writeTextElement("Gas5", gas5);
|
2014-06-21 06:31:19 +00:00
|
|
|
//
|
2014-06-21 06:53:05 +00:00
|
|
|
//Add dil values
|
|
|
|
QString dil1 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->dil1.oxygen),
|
|
|
|
QString::number(details->dil1.helium),
|
|
|
|
QString::number(details->dil1.type),
|
|
|
|
QString::number(details->dil1.depth));
|
2014-06-21 06:53:05 +00:00
|
|
|
QString dil2 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->dil2.oxygen),
|
|
|
|
QString::number(details->dil2.helium),
|
|
|
|
QString::number(details->dil2.type),
|
|
|
|
QString::number(details->dil2.depth));
|
2014-06-21 06:53:05 +00:00
|
|
|
QString dil3 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->dil3.oxygen),
|
|
|
|
QString::number(details->dil3.helium),
|
|
|
|
QString::number(details->dil3.type),
|
|
|
|
QString::number(details->dil3.depth));
|
2014-06-21 06:53:05 +00:00
|
|
|
QString dil4 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->dil4.oxygen),
|
|
|
|
QString::number(details->dil4.helium),
|
|
|
|
QString::number(details->dil4.type),
|
|
|
|
QString::number(details->dil4.depth));
|
2014-06-21 06:53:05 +00:00
|
|
|
QString dil5 = QString("%1,%2,%3,%4")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->dil5.oxygen),
|
|
|
|
QString::number(details->dil5.helium),
|
|
|
|
QString::number(details->dil5.type),
|
|
|
|
QString::number(details->dil5.depth));
|
2014-07-06 03:53:42 +00:00
|
|
|
writer.writeTextElement("Dil1", dil1);
|
|
|
|
writer.writeTextElement("Dil2", dil2);
|
|
|
|
writer.writeTextElement("Dil3", dil3);
|
|
|
|
writer.writeTextElement("Dil4", dil4);
|
|
|
|
writer.writeTextElement("Dil5", dil5);
|
2017-03-06 12:36:42 +00:00
|
|
|
|
|
|
|
//Add setpoint values
|
2014-06-21 07:22:47 +00:00
|
|
|
QString sp1 = QString("%1,%2")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->sp1.sp),
|
|
|
|
QString::number(details->sp1.depth));
|
2014-06-21 07:22:47 +00:00
|
|
|
QString sp2 = QString("%1,%2")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->sp2.sp),
|
|
|
|
QString::number(details->sp2.depth));
|
2014-06-21 07:22:47 +00:00
|
|
|
QString sp3 = QString("%1,%2")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->sp3.sp),
|
|
|
|
QString::number(details->sp3.depth));
|
2014-06-21 07:22:47 +00:00
|
|
|
QString sp4 = QString("%1,%2")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->sp4.sp),
|
|
|
|
QString::number(details->sp4.depth));
|
2014-06-21 07:22:47 +00:00
|
|
|
QString sp5 = QString("%1,%2")
|
2015-09-02 21:59:59 +00:00
|
|
|
.arg(QString::number(details->sp5.sp),
|
|
|
|
QString::number(details->sp5.depth));
|
2014-07-06 03:53:42 +00:00
|
|
|
writer.writeTextElement("SetPoint1", sp1);
|
|
|
|
writer.writeTextElement("SetPoint2", sp2);
|
|
|
|
writer.writeTextElement("SetPoint3", sp3);
|
|
|
|
writer.writeTextElement("SetPoint4", sp4);
|
|
|
|
writer.writeTextElement("SetPoint5", sp5);
|
2014-06-21 07:22:47 +00:00
|
|
|
|
|
|
|
//Other Settings
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeTextElement("DiveMode", QString::number(details->diveMode));
|
|
|
|
writer.writeTextElement("Saturation", QString::number(details->saturation));
|
|
|
|
writer.writeTextElement("Desaturation", QString::number(details->desaturation));
|
|
|
|
writer.writeTextElement("LastDeco", QString::number(details->lastDeco));
|
|
|
|
writer.writeTextElement("Brightness", QString::number(details->brightness));
|
|
|
|
writer.writeTextElement("Units", QString::number(details->units));
|
|
|
|
writer.writeTextElement("SamplingRate", QString::number(details->samplingRate));
|
|
|
|
writer.writeTextElement("Salinity", QString::number(details->salinity));
|
|
|
|
writer.writeTextElement("DiveModeColor", QString::number(details->diveModeColor));
|
|
|
|
writer.writeTextElement("Language", QString::number(details->language));
|
|
|
|
writer.writeTextElement("DateFormat", QString::number(details->dateFormat));
|
|
|
|
writer.writeTextElement("CompassGain", QString::number(details->compassGain));
|
|
|
|
writer.writeTextElement("SafetyStop", QString::number(details->safetyStop));
|
|
|
|
writer.writeTextElement("GfHigh", QString::number(details->gfHigh));
|
|
|
|
writer.writeTextElement("GfLow", QString::number(details->gfLow));
|
|
|
|
writer.writeTextElement("PressureSensorOffset", QString::number(details->pressureSensorOffset));
|
|
|
|
writer.writeTextElement("PpO2Min", QString::number(details->ppO2Min));
|
|
|
|
writer.writeTextElement("PpO2Max", QString::number(details->ppO2Max));
|
|
|
|
writer.writeTextElement("FutureTTS", QString::number(details->futureTTS));
|
|
|
|
writer.writeTextElement("CcrMode", QString::number(details->ccrMode));
|
|
|
|
writer.writeTextElement("DecoType", QString::number(details->decoType));
|
|
|
|
writer.writeTextElement("AGFSelectable", QString::number(details->aGFSelectable));
|
|
|
|
writer.writeTextElement("AGFHigh", QString::number(details->aGFHigh));
|
|
|
|
writer.writeTextElement("AGFLow", QString::number(details->aGFLow));
|
|
|
|
writer.writeTextElement("CalibrationGas", QString::number(details->calibrationGas));
|
|
|
|
writer.writeTextElement("FlipScreen", QString::number(details->flipScreen));
|
|
|
|
writer.writeTextElement("SetPointFallback", QString::number(details->setPointFallback));
|
2015-09-02 22:00:00 +00:00
|
|
|
writer.writeTextElement("LeftButtonSensitivity", QString::number(details->leftButtonSensitivity));
|
|
|
|
writer.writeTextElement("RightButtonSensitivity", QString::number(details->rightButtonSensitivity));
|
|
|
|
writer.writeTextElement("BottomGasConsumption", QString::number(details->bottomGasConsumption));
|
|
|
|
writer.writeTextElement("DecoGasConsumption", QString::number(details->decoGasConsumption));
|
|
|
|
writer.writeTextElement("ModWarning", QString::number(details->modWarning));
|
|
|
|
writer.writeTextElement("DynamicAscendRate", QString::number(details->dynamicAscendRate));
|
|
|
|
writer.writeTextElement("GraphicalSpeedIndicator", QString::number(details->graphicalSpeedIndicator));
|
|
|
|
writer.writeTextElement("AlwaysShowppO2", QString::number(details->alwaysShowppO2));
|
2014-07-06 03:53:42 +00:00
|
|
|
|
2014-10-12 14:51:27 +00:00
|
|
|
// Suunto vyper settings.
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeTextElement("Altitude", QString::number(details->altitude));
|
|
|
|
writer.writeTextElement("PersonalSafety", QString::number(details->personalSafety));
|
|
|
|
writer.writeTextElement("TimeFormat", QString::number(details->timeFormat));
|
2014-10-12 14:51:27 +00:00
|
|
|
|
|
|
|
writer.writeStartElement("Light");
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeAttribute("enabled", QString::number(details->lightEnabled));
|
|
|
|
writer.writeCharacters(QString::number(details->light));
|
2014-10-12 14:51:27 +00:00
|
|
|
writer.writeEndElement();
|
|
|
|
|
|
|
|
writer.writeStartElement("AlarmTime");
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeAttribute("enabled", QString::number(details->alarmTimeEnabled));
|
|
|
|
writer.writeCharacters(QString::number(details->alarmTime));
|
2014-10-12 14:51:27 +00:00
|
|
|
writer.writeEndElement();
|
|
|
|
|
|
|
|
writer.writeStartElement("AlarmDepth");
|
2015-09-02 21:59:59 +00:00
|
|
|
writer.writeAttribute("enabled", QString::number(details->alarmDepthEnabled));
|
|
|
|
writer.writeCharacters(QString::number(details->alarmDepth));
|
2014-10-12 14:51:27 +00:00
|
|
|
writer.writeEndElement();
|
|
|
|
|
2014-07-06 03:53:42 +00:00
|
|
|
writer.writeEndElement();
|
|
|
|
writer.writeEndElement();
|
|
|
|
|
|
|
|
writer.writeEndDocument();
|
2014-06-10 16:19:28 +00:00
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::WriteOnly)) {
|
2014-07-31 15:51:38 +00:00
|
|
|
lastError = tr("Could not save the backup file %1. Error Message: %2")
|
2014-12-29 04:56:58 +00:00
|
|
|
.arg(fileName, file.errorString());
|
2014-06-10 16:19:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//file open successful. write data and save.
|
|
|
|
QTextStream out(&file);
|
|
|
|
out << xml;
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-31 15:51:38 +00:00
|
|
|
bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details)
|
2014-06-11 06:37:27 +00:00
|
|
|
{
|
2014-07-22 16:38:30 +00:00
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::ReadOnly)) {
|
2014-07-31 15:51:38 +00:00
|
|
|
lastError = tr("Could not open backup file: %1").arg(file.errorString());
|
2014-06-11 06:37:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-22 16:38:30 +00:00
|
|
|
QString xml = file.readAll();
|
|
|
|
|
|
|
|
QXmlStreamReader reader(xml);
|
|
|
|
while (!reader.atEnd()) {
|
|
|
|
if (reader.isStartElement()) {
|
|
|
|
QString settingName = reader.name().toString();
|
2014-10-12 14:51:27 +00:00
|
|
|
QXmlStreamAttributes attributes = reader.attributes();
|
2014-07-22 16:38:30 +00:00
|
|
|
reader.readNext();
|
|
|
|
QString keyString = reader.text().toString();
|
|
|
|
|
|
|
|
if (settingName == "CustomText")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->customText = keyString;
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Gas1") {
|
|
|
|
QStringList gasData = keyString.split(",");
|
|
|
|
gas gas1;
|
|
|
|
gas1.oxygen = gasData.at(0).toInt();
|
|
|
|
gas1.helium = gasData.at(1).toInt();
|
|
|
|
gas1.type = gasData.at(2).toInt();
|
|
|
|
gas1.depth = gasData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gas1 = gas1;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
2014-06-11 06:37:27 +00:00
|
|
|
|
2014-07-22 16:38:30 +00:00
|
|
|
if (settingName == "Gas2") {
|
|
|
|
QStringList gasData = keyString.split(",");
|
|
|
|
gas gas2;
|
|
|
|
gas2.oxygen = gasData.at(0).toInt();
|
|
|
|
gas2.helium = gasData.at(1).toInt();
|
|
|
|
gas2.type = gasData.at(2).toInt();
|
|
|
|
gas2.depth = gasData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gas2 = gas2;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Gas3") {
|
|
|
|
QStringList gasData = keyString.split(",");
|
|
|
|
gas gas3;
|
|
|
|
gas3.oxygen = gasData.at(0).toInt();
|
|
|
|
gas3.helium = gasData.at(1).toInt();
|
|
|
|
gas3.type = gasData.at(2).toInt();
|
|
|
|
gas3.depth = gasData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gas3 = gas3;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Gas4") {
|
|
|
|
QStringList gasData = keyString.split(",");
|
|
|
|
gas gas4;
|
|
|
|
gas4.oxygen = gasData.at(0).toInt();
|
|
|
|
gas4.helium = gasData.at(1).toInt();
|
|
|
|
gas4.type = gasData.at(2).toInt();
|
|
|
|
gas4.depth = gasData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gas4 = gas4;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Gas5") {
|
|
|
|
QStringList gasData = keyString.split(",");
|
|
|
|
gas gas5;
|
|
|
|
gas5.oxygen = gasData.at(0).toInt();
|
|
|
|
gas5.helium = gasData.at(1).toInt();
|
|
|
|
gas5.type = gasData.at(2).toInt();
|
|
|
|
gas5.depth = gasData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gas5 = gas5;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Dil1") {
|
|
|
|
QStringList dilData = keyString.split(",");
|
|
|
|
gas dil1;
|
|
|
|
dil1.oxygen = dilData.at(0).toInt();
|
|
|
|
dil1.helium = dilData.at(1).toInt();
|
|
|
|
dil1.type = dilData.at(2).toInt();
|
|
|
|
dil1.depth = dilData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dil1 = dil1;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Dil2") {
|
|
|
|
QStringList dilData = keyString.split(",");
|
|
|
|
gas dil2;
|
|
|
|
dil2.oxygen = dilData.at(0).toInt();
|
|
|
|
dil2.helium = dilData.at(1).toInt();
|
|
|
|
dil2.type = dilData.at(2).toInt();
|
|
|
|
dil2.depth = dilData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dil1 = dil2;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Dil3") {
|
|
|
|
QStringList dilData = keyString.split(",");
|
|
|
|
gas dil3;
|
|
|
|
dil3.oxygen = dilData.at(0).toInt();
|
|
|
|
dil3.helium = dilData.at(1).toInt();
|
|
|
|
dil3.type = dilData.at(2).toInt();
|
|
|
|
dil3.depth = dilData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dil3 = dil3;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Dil4") {
|
|
|
|
QStringList dilData = keyString.split(",");
|
|
|
|
gas dil4;
|
|
|
|
dil4.oxygen = dilData.at(0).toInt();
|
|
|
|
dil4.helium = dilData.at(1).toInt();
|
|
|
|
dil4.type = dilData.at(2).toInt();
|
|
|
|
dil4.depth = dilData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dil4 = dil4;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
2014-06-11 06:37:27 +00:00
|
|
|
|
2014-07-22 16:38:30 +00:00
|
|
|
if (settingName == "Dil5") {
|
|
|
|
QStringList dilData = keyString.split(",");
|
|
|
|
gas dil5;
|
|
|
|
dil5.oxygen = dilData.at(0).toInt();
|
|
|
|
dil5.helium = dilData.at(1).toInt();
|
|
|
|
dil5.type = dilData.at(2).toInt();
|
|
|
|
dil5.depth = dilData.at(3).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dil5 = dil5;
|
2014-06-11 06:37:27 +00:00
|
|
|
}
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "SetPoint1") {
|
|
|
|
QStringList spData = keyString.split(",");
|
|
|
|
setpoint sp1;
|
|
|
|
sp1.sp = spData.at(0).toInt();
|
|
|
|
sp1.depth = spData.at(1).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->sp1 = sp1;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "SetPoint2") {
|
|
|
|
QStringList spData = keyString.split(",");
|
|
|
|
setpoint sp2;
|
|
|
|
sp2.sp = spData.at(0).toInt();
|
|
|
|
sp2.depth = spData.at(1).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->sp2 = sp2;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "SetPoint3") {
|
|
|
|
QStringList spData = keyString.split(",");
|
|
|
|
setpoint sp3;
|
|
|
|
sp3.sp = spData.at(0).toInt();
|
|
|
|
sp3.depth = spData.at(1).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->sp3 = sp3;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "SetPoint4") {
|
|
|
|
QStringList spData = keyString.split(",");
|
|
|
|
setpoint sp4;
|
|
|
|
sp4.sp = spData.at(0).toInt();
|
|
|
|
sp4.depth = spData.at(1).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->sp4 = sp4;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "SetPoint5") {
|
|
|
|
QStringList spData = keyString.split(",");
|
|
|
|
setpoint sp5;
|
|
|
|
sp5.sp = spData.at(0).toInt();
|
|
|
|
sp5.depth = spData.at(1).toInt();
|
2015-09-02 21:59:59 +00:00
|
|
|
details->sp5 = sp5;
|
2014-07-22 16:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "Saturation")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->saturation = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Desaturation")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->desaturation = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "DiveMode")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->diveMode = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "LastDeco")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->lastDeco = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Brightness")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->brightness = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Units")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->units = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "SamplingRate")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->samplingRate = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Salinity")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->salinity = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "DiveModeColour")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->diveModeColor = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "Language")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->language = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "DateFormat")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->dateFormat = keyString.toInt();
|
2014-07-22 16:38:30 +00:00
|
|
|
|
|
|
|
if (settingName == "CompassGain")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->compassGain = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
|
2014-10-17 22:33:46 +00:00
|
|
|
if (settingName == "SafetyStop")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->safetyStop = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "GfHigh")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gfHigh = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "GfLow")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->gfLow = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "PressureSensorOffset")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->pressureSensorOffset = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "PpO2Min")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->ppO2Min = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "PpO2Max")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->ppO2Max = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "FutureTTS")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->futureTTS = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "CcrMode")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->ccrMode = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "DecoType")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->decoType = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "AGFSelectable")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->aGFSelectable = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "AGFHigh")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->aGFHigh = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "AGFLow")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->aGFLow = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "CalibrationGas")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->calibrationGas = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "FlipScreen")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->flipScreen = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
|
|
|
if (settingName == "SetPointFallback")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->setPointFallback = keyString.toInt();
|
2014-10-17 22:33:46 +00:00
|
|
|
|
2015-09-02 22:00:00 +00:00
|
|
|
if (settingName == "LeftButtonSensitivity")
|
|
|
|
details->leftButtonSensitivity = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "RightButtonSensitivity")
|
|
|
|
details->rightButtonSensitivity = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "BottomGasConsumption")
|
|
|
|
details->bottomGasConsumption = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "DecoGasConsumption")
|
|
|
|
details->decoGasConsumption = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "ModWarning")
|
|
|
|
details->modWarning = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "DynamicAscendRate")
|
|
|
|
details->dynamicAscendRate = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "GraphicalSpeedIndicator")
|
|
|
|
details->graphicalSpeedIndicator = keyString.toInt();
|
|
|
|
|
|
|
|
if (settingName == "AlwaysShowppO2")
|
|
|
|
details->alwaysShowppO2 = keyString.toInt();
|
|
|
|
|
2014-10-12 14:51:27 +00:00
|
|
|
if (settingName == "Altitude")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->altitude = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
|
|
|
|
if (settingName == "PersonalSafety")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->personalSafety = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
|
|
|
|
if (settingName == "TimeFormat")
|
2015-09-02 21:59:59 +00:00
|
|
|
details->timeFormat = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
|
|
|
|
if (settingName == "Light") {
|
|
|
|
if (attributes.hasAttribute("enabled"))
|
2015-09-02 21:59:59 +00:00
|
|
|
details->lightEnabled = attributes.value("enabled").toString().toInt();
|
|
|
|
details->light = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "AlarmDepth") {
|
|
|
|
if (attributes.hasAttribute("enabled"))
|
2015-09-02 21:59:59 +00:00
|
|
|
details->alarmDepthEnabled = attributes.value("enabled").toString().toInt();
|
|
|
|
details->alarmDepth = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settingName == "AlarmTime") {
|
|
|
|
if (attributes.hasAttribute("enabled"))
|
2015-09-02 21:59:59 +00:00
|
|
|
details->alarmTimeEnabled = attributes.value("enabled").toString().toInt();
|
|
|
|
details->alarmTime = keyString.toInt();
|
2014-10-12 14:51:27 +00:00
|
|
|
}
|
2014-06-11 06:37:27 +00:00
|
|
|
}
|
2014-07-22 16:38:30 +00:00
|
|
|
reader.readNext();
|
2014-06-11 06:37:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-31 15:51:38 +00:00
|
|
|
void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data)
|
2014-06-23 15:16:27 +00:00
|
|
|
{
|
2014-10-20 20:58:21 +00:00
|
|
|
setState(FWUPDATE);
|
|
|
|
if (firmwareThread)
|
|
|
|
firmwareThread->deleteLater();
|
|
|
|
|
|
|
|
firmwareThread = new FirmwareUpdateThread(this, data, fileName);
|
|
|
|
connect(firmwareThread, SIGNAL(finished()),
|
|
|
|
this, SLOT(firmwareThreadFinished()), Qt::QueuedConnection);
|
|
|
|
connect(firmwareThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
|
2015-01-21 18:05:22 +00:00
|
|
|
connect(firmwareThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
|
2015-01-20 21:40:52 +00:00
|
|
|
|
2014-10-20 20:58:21 +00:00
|
|
|
firmwareThread->start();
|
2014-06-23 15:16:27 +00:00
|
|
|
}
|
|
|
|
|
2014-10-17 22:33:47 +00:00
|
|
|
void ConfigureDiveComputer::resetSettings(device_data_t *data)
|
|
|
|
{
|
|
|
|
setState(RESETTING);
|
|
|
|
|
|
|
|
if (resetThread)
|
|
|
|
resetThread->deleteLater();
|
|
|
|
|
|
|
|
resetThread = new ResetSettingsThread(this, data);
|
|
|
|
connect(resetThread, SIGNAL(finished()),
|
|
|
|
this, SLOT(resetThreadFinished()), Qt::QueuedConnection);
|
|
|
|
connect(resetThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
|
2015-01-21 18:05:22 +00:00
|
|
|
connect(resetThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
|
2014-10-17 22:33:47 +00:00
|
|
|
|
|
|
|
resetThread->start();
|
|
|
|
}
|
|
|
|
|
2015-01-20 21:40:52 +00:00
|
|
|
void ConfigureDiveComputer::progressEvent(int percent)
|
|
|
|
{
|
|
|
|
emit progress(percent);
|
|
|
|
}
|
|
|
|
|
2014-05-30 06:56:27 +00:00
|
|
|
void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState)
|
|
|
|
{
|
|
|
|
currentState = newState;
|
|
|
|
emit stateChanged(currentState);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputer::setError(QString err)
|
|
|
|
{
|
|
|
|
lastError = err;
|
|
|
|
emit error(err);
|
|
|
|
}
|
|
|
|
|
2014-05-30 07:49:58 +00:00
|
|
|
void ConfigureDiveComputer::readThreadFinished()
|
2014-05-30 06:56:27 +00:00
|
|
|
{
|
2014-05-30 07:49:58 +00:00
|
|
|
setState(DONE);
|
2015-05-27 19:19:11 +00:00
|
|
|
if (lastError.isEmpty()) {
|
2014-12-07 22:32:08 +00:00
|
|
|
//No error
|
|
|
|
emit message(tr("Dive computer details read successfully"));
|
|
|
|
}
|
2014-05-30 06:56:27 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 07:49:58 +00:00
|
|
|
void ConfigureDiveComputer::writeThreadFinished()
|
2014-05-30 06:56:27 +00:00
|
|
|
{
|
|
|
|
setState(DONE);
|
2015-05-27 19:19:11 +00:00
|
|
|
if (lastError.isEmpty()) {
|
2014-05-30 07:49:58 +00:00
|
|
|
//No error
|
|
|
|
emit message(tr("Setting successfully written to device"));
|
|
|
|
}
|
2014-05-30 06:56:27 +00:00
|
|
|
}
|
2014-10-17 22:33:47 +00:00
|
|
|
|
2014-10-20 20:58:21 +00:00
|
|
|
void ConfigureDiveComputer::firmwareThreadFinished()
|
|
|
|
{
|
|
|
|
setState(DONE);
|
2015-05-27 19:19:11 +00:00
|
|
|
if (lastError.isEmpty()) {
|
2014-10-20 20:58:21 +00:00
|
|
|
//No error
|
|
|
|
emit message(tr("Device firmware successfully updated"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-17 22:33:47 +00:00
|
|
|
void ConfigureDiveComputer::resetThreadFinished()
|
|
|
|
{
|
|
|
|
setState(DONE);
|
2015-05-27 19:19:11 +00:00
|
|
|
if (lastError.isEmpty()) {
|
2014-10-17 22:33:47 +00:00
|
|
|
//No error
|
2014-11-01 00:07:14 +00:00
|
|
|
emit message(tr("Device settings successfully reset"));
|
2014-10-17 22:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-12 20:37:34 +00:00
|
|
|
|
|
|
|
QString ConfigureDiveComputer::dc_open(device_data_t *data)
|
|
|
|
{
|
|
|
|
FILE *fp = NULL;
|
|
|
|
dc_status_t rc;
|
|
|
|
|
|
|
|
if (data->libdc_log)
|
|
|
|
fp = subsurface_fopen(logfile_name, "w");
|
|
|
|
|
|
|
|
data->libdc_logfile = fp;
|
|
|
|
|
|
|
|
rc = dc_context_new(&data->context);
|
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
|
|
|
return tr("Unable to create libdivecomputer context");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fp) {
|
|
|
|
dc_context_set_loglevel(data->context, DC_LOGLEVEL_ALL);
|
|
|
|
dc_context_set_logfunc(data->context, logfunc, fp);
|
2017-09-28 03:00:58 +00:00
|
|
|
fprintf(data->libdc_logfile, "Subsurface: v%s, ", subsurface_git_version());
|
|
|
|
fprintf(data->libdc_logfile, "built with libdivecomputer v%s\n", dc_version(NULL));
|
2015-09-12 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
2017-06-18 06:50:37 +00:00
|
|
|
#if defined(SSRF_CUSTOM_IO)
|
2015-09-12 20:37:35 +00:00
|
|
|
if (data->bluetooth_mode) {
|
2017-06-18 06:50:37 +00:00
|
|
|
#if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_IO)
|
Switch over to SSRF_CUSTOM_IO v2
I hate changing the IO interfaces this often, but when I converted the
custom serial interface to the more generic custom IO interface, I
intentionally left the legacy serial operations alone, because I didn't
want to change something I didn't care about.
But it turns out that leaving them with the old calling convention
caused extra problems when converting the bluetooth serial code to have
the BLE GATT packet fall-back, which requires mixing two kinds of
operations.
Also, the packet_open() routine was passed a copy of the 'dc_context_t',
which makes it possible to update the 'dc_custom_io_t' field on the fly
at open time. That makes a lot of chaining operations much simpler,
since now you can chain the 'custom_io_t' at open time and then
libdivecomputer will automatically call the new routines instead of the
old ones.
That dc_context_t availability gets rid of all the
if (device && device->ops)
return device->ops->serial_xyz(..);
hackery inside the rfcomm routines - now we can just at open time do a simple
dc_context_set_custom_io(context, &ble_serial_ops);
to switch things over to the BLE version of the serial code instead.
Finally, SSRF_CUSTOM_IO v2 added an opaque "dc_user_device_t" pointer
argument to the custom_io descriptor, which gets filled in as the
custom_io is registered with the download context. Note that unlike
most opaque pointers, this one is opaque to *libdivecomputer*, and the
type is supposed to be supplied by the user.
We define the "dc_user_device_t" as our old "struct device_data_t",
making it "struct user_device_t" instead. That means that the IO
routines now get passed the device info showing what device they are
supposed to download for.
That, in turn, means that now our BLE GATT open code can take the device
type it opens for into account if it wants to. And it will want to,
since the rules for Shearwater are different from the rules for Suunto,
for example.
NOTE! Because of the interface change with libdivecomputer, this will
need a flag-day again where libdivecomputer and subsurface are updated
together. It may not be the last time, either.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 18:59:11 +00:00
|
|
|
rc = dc_context_set_custom_io(data->context, get_qt_serial_ops(), data);
|
2015-10-26 13:05:27 +00:00
|
|
|
#endif
|
2015-09-12 20:37:35 +00:00
|
|
|
#ifdef SERIAL_FTDI
|
|
|
|
} else if (!strcmp(data->devname, "ftdi")) {
|
Switch over to SSRF_CUSTOM_IO v2
I hate changing the IO interfaces this often, but when I converted the
custom serial interface to the more generic custom IO interface, I
intentionally left the legacy serial operations alone, because I didn't
want to change something I didn't care about.
But it turns out that leaving them with the old calling convention
caused extra problems when converting the bluetooth serial code to have
the BLE GATT packet fall-back, which requires mixing two kinds of
operations.
Also, the packet_open() routine was passed a copy of the 'dc_context_t',
which makes it possible to update the 'dc_custom_io_t' field on the fly
at open time. That makes a lot of chaining operations much simpler,
since now you can chain the 'custom_io_t' at open time and then
libdivecomputer will automatically call the new routines instead of the
old ones.
That dc_context_t availability gets rid of all the
if (device && device->ops)
return device->ops->serial_xyz(..);
hackery inside the rfcomm routines - now we can just at open time do a simple
dc_context_set_custom_io(context, &ble_serial_ops);
to switch things over to the BLE version of the serial code instead.
Finally, SSRF_CUSTOM_IO v2 added an opaque "dc_user_device_t" pointer
argument to the custom_io descriptor, which gets filled in as the
custom_io is registered with the download context. Note that unlike
most opaque pointers, this one is opaque to *libdivecomputer*, and the
type is supposed to be supplied by the user.
We define the "dc_user_device_t" as our old "struct device_data_t",
making it "struct user_device_t" instead. That means that the IO
routines now get passed the device info showing what device they are
supposed to download for.
That, in turn, means that now our BLE GATT open code can take the device
type it opens for into account if it wants to. And it will want to,
since the rules for Shearwater are different from the rules for Suunto,
for example.
NOTE! Because of the interface change with libdivecomputer, this will
need a flag-day again where libdivecomputer and subsurface are updated
together. It may not be the last time, either.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 18:59:11 +00:00
|
|
|
rc = dc_context_set_custom_io(data->context, &serial_ftdi_ops, data);
|
2015-09-12 20:37:35 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
2016-09-17 15:27:56 +00:00
|
|
|
report_error(errmsg(rc));
|
2015-09-12 20:37:35 +00:00
|
|
|
} else {
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
|
|
|
|
}
|
|
|
|
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
|
|
|
return tr("Could not a establish connection to the dive computer.");
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(OPEN);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputer::dc_close(device_data_t *data)
|
|
|
|
{
|
|
|
|
if (data->device)
|
|
|
|
dc_device_close(data->device);
|
|
|
|
data->device = NULL;
|
|
|
|
if (data->context)
|
|
|
|
dc_context_free(data->context);
|
|
|
|
data->context = NULL;
|
|
|
|
|
|
|
|
if (data->libdc_logfile)
|
|
|
|
fclose(data->libdc_logfile);
|
|
|
|
|
|
|
|
setState(INITIAL);
|
|
|
|
}
|