On Fri, May 30, 2014 at 12:21 PM, Joshua Joseph <[email protected]> wrote:

>
> On Fri, May 30, 2014 at 11:47 AM, Jef Driesen <[email protected]>
> wrote:
>
>> On 2014-05-30 09:52, Joshua Joseph wrote:
>>
>>> Please check and see if I am on the right track.
>>>
>>
>> I quickly checked the patched, and noticed one libdivecomputer related
>> mistake: you shouldn't use the vendor or product strings to check the
>> device type. There are much better ways to do this. The strings are mainly
>> intended for display in the user interface.
>>
>> The solution to both of these problems, is to check the family type
>> instead, using the dc_device_get_type or dc_descriptor_get_type function:
>>
>> if (dc_device_get_type(data->device) == DC_FAMILY_HW_FROG) {
>>    ...
>>    hw_frog_device_version(data->device, hw_data, 10);
>>    ...
>> }
>>
>> Jef
>>
>
> Thanks, Jef.
>
> I will apply this correction.
>
> --
> Thanks,
>
> I had forgotten to send in this.

This patch implements Jef's suggestion on the previous patches.
-- 
Thanks,
Joshua
From 354916e3d121ca873f1827462c31a7ba1e12ae79 Mon Sep 17 00:00:00 2001
From: "Joseph W. Joshua" <[email protected]>
Date: Tue, 3 Jun 2014 11:31:03 +0300
Subject: [PATCH 5/5] 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 <[email protected]>
---
 qt-ui/configuredivecomputer.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp
index fcd8fbc..34b3665 100644
--- a/qt-ui/configuredivecomputer.cpp
+++ b/qt-ui/configuredivecomputer.cpp
@@ -83,11 +83,10 @@ ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data)
 
 void ReadSettingsThread::run()
 {
-	QString vendor = data->vendor;
 	dc_status_t rc;
 	rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
 	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];
 			hw_frog_device_version(data->device, hw_data, 10);
 			QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this
@@ -112,18 +111,21 @@ void WriteSettingsThread::run()
 {
 	bool supported = false;
 	dc_status_t rc;
-	QString product = data->product;
-	QString vendor = data->vendor;
 	rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
 	if (rc == DC_STATUS_SUCCESS) {
 		dc_status_t result;
-		if (product.trimmed() == "OSTC 3") {
+		if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) {
 			if (m_settingName == "Name") {
 				supported = true;
 				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;
 			QDateTime timeToSet = m_settingValue.toDateTime();
 			dc_datetime_t time;
-- 
2.0.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to