]> pilppa.com Git - lib1wire.git/commitdiff
Support for seting and changing values from device specific config
authorMika Laitio <lamikr@pilppa.org>
Wed, 22 Dec 2010 00:15:37 +0000 (02:15 +0200)
committerMika Laitio <lamikr@pilppa.org>
Wed, 22 Dec 2010 00:15:37 +0000 (02:15 +0200)
files.

Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/Data.cc
src/DeviceConfig.hh
src/Factory.cc
src/W1Device.cc

index 388dbefa71471c3910b680972abba3ac2361b6e6..29325b73d0d6fdaa077ba227e0c2b58eb7326bf7 100644 (file)
@@ -105,9 +105,7 @@ Data *Data::parse_data_string(const string& dataline) {
                        // parse date
                        date    = W1Util::parse_date_str(item);
                }
-               // skip the device type and device id fields
-               // TODO: store device type and id to own file
-               else if (ii >= 3) {
+               else if (ii >= 1) {
                        suc_flg = string_to_number<double>(val, item, dec);
                        if (suc_flg) {
                                //log_debug("adding number: %f\n", val);
index c2cfb31512fbce5f2619a3b405bf4339f2e59b8c..cd86954dfb02826085c49cab390153ea51fccc68 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
 #define DEVICE_CONFIG__SECTION_TYPE            "device"
 #define DEVICE_CONFIG__SECTION_NAME            "base_data"
 #define DEVICE_CONFIG_VALUE_KEY__TYPE          "type"
+#define DEVICE_CONFIG_VALUE_KEY__ID            "id"
 #define DEVICE_CONFIG_VALUE_KEY__NAME          "name"
 
 namespace w1 {
index e9637a4bd7101487cf4f2cf83d27dd4e04ddd415..c81dbe198e3a37c4e423da65fa76611b34632fb6 100644 (file)
@@ -53,6 +53,7 @@ W1Device *Factory::get_device(int family_code,
                        if (type.empty() == true) {
                                type    = ret_val->get_device_type();
                                config->set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, type);
+                               config->set_cfg_value(DEVICE_CONFIG_VALUE_KEY__ID, ret_val->get_id());
                        }
                }
        }
index 467a3359685eb7a432ee606259684fe4d79e687b..46e5b7046e7e173e0ddc54a64ac319c304de31fa 100644 (file)
@@ -84,7 +84,7 @@ string W1Device::get_formatted_value() {
 string W1Device::get_formatted_value(string value) {
        string ret_val;
 
-       ret_val = get_time() + "|" + get_device_type() + "|" + id + "|" + value + " " + get_unit();
+       ret_val = get_time() + "|" + value + " " + get_unit();
        add_to_memory_cache(ret_val);
        return ret_val;
 }