Change dive computer family detection

Following suggestions on the mailing list, this changes the
method used to detect the dive computer family. Detection is
now done using: dc_device_get_type.

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
Joseph W. Joshua 2014-06-04 07:25:41 +03:00 committed by Thiago Macieira
parent 3e127a059f
commit a08d239af5

View file

@ -83,13 +83,12 @@ ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data)
void ReadSettingsThread::run() void ReadSettingsThread::run()
{ {
QString vendor = data->vendor;
dc_status_t rc; dc_status_t rc;
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
if (rc == DC_STATUS_SUCCESS) { if (rc == DC_STATUS_SUCCESS) {
if (vendor.trimmed() == "Heinrichs Weikamp") { if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) {
unsigned char hw_data[10]; unsigned char hw_data[10];
hw_frog_device_version(data->device, hw_data, 10); hw_ostc3_device_version(data->device, hw_data, 10);
QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this
} else { } else {
lastError = tr("This feature is not yet available for the selected dive computer."); lastError = tr("This feature is not yet available for the selected dive computer.");
@ -112,18 +111,21 @@ void WriteSettingsThread::run()
{ {
bool supported = false; bool supported = false;
dc_status_t rc; dc_status_t rc;
QString product = data->product;
QString vendor = data->vendor;
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
if (rc == DC_STATUS_SUCCESS) { if (rc == DC_STATUS_SUCCESS) {
dc_status_t result; dc_status_t result;
if (product.trimmed() == "OSTC 3") { if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) {
if (m_settingName == "Name") { if (m_settingName == "Name") {
supported = true; supported = true;
result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data()); result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data());
} }
} else if ( dc_device_get_type(data->device) == DC_FAMILY_HW_FROG ) {
if (m_settingName == "Name") {
supported = true;
result = hw_frog_device_customtext(data->device, m_settingValue.toByteArray().data());
}
} }
if (vendor.trimmed() == "Heinrichs Weikamp" && m_settingName == "DateAndTime") { if ( dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3 && m_settingName == "DateTime" ) {
supported = true; supported = true;
QDateTime timeToSet = m_settingValue.toDateTime(); QDateTime timeToSet = m_settingValue.toDateTime();
dc_datetime_t time; dc_datetime_t time;