]> pilppa.com Git - libplpdevicebus.git/commitdiff
device list read fixes
authorMika Laitio <lamikr@pilppa.org>
Tue, 14 Aug 2012 22:52:13 +0000 (01:52 +0300)
committerMika Laitio <lamikr@pilppa.org>
Tue, 14 Aug 2012 22:52:13 +0000 (01:52 +0300)
- changes required by api changes
- fix for the device list handling in cases
  that sensor device does not have any data to return.
  (only the config file)

Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src_client/DeviceManagerClient.cc
src_server/DeviceManagerServer.cc

index fb4e62e457c0fa4cc43c35fae66be3467c960cfa..b318d88176d95789c287d28dcaf85490842c6783 100644 (file)
@@ -73,7 +73,6 @@ DataRange *DeviceManagerClient::parse_device_data_msg(BusMessage *msg_param,
                data_str        = msg_param->get_string_parameter(RSP__GET_LATEST_DATA__VALUE, err_flg);
                data            = Data::parse_string(data_str);
                ret_val         = new DataRange(data);
-               log_info("date: %s\n", data->get_date().to_string().c_str());
                log_debug("latest data\n");
                data->printout();
 
@@ -140,7 +139,7 @@ list<Device *> *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param
                        key << RSP__DEVICE_LIST__ID << ii;
                        id      = msg_param->get_string_parameter(key.str(), err_flg);
                        if (*err_flg != PLP_OK) {
-                               log_error("Failed to parse device id\n");
+                               log_error("Failed to parse device id.\n");
                                break;
                        }
 
@@ -148,7 +147,7 @@ list<Device *> *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param
                        key << RSP__DEVICE_LIST__NAME << ii;
                        name    = msg_param->get_string_parameter(key.str(), err_flg);
                        if (*err_flg != PLP_OK) {
-                               log_error("Failed to parse device name\n");
+                               log_error("Failed to parse name for the device: %s\n", id.c_str());
                                break;
                        }
 
@@ -156,7 +155,7 @@ list<Device *> *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param
                        key << RSP__DEVICE_LIST__TYPE << ii;
                        type    = msg_param->get_string_parameter(key.str(), err_flg);
                        if (*err_flg != PLP_OK) {
-                               log_error("Failed to parse device type\n");
+                               log_error("Failed to parse type for the device: %s\n", id.c_str());
                                break;
                        }
 
@@ -164,7 +163,7 @@ list<Device *> *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param
                        key << RSP__DEVICE_LIST__LF_STATE << ii;
                        state_i = msg_param->get_int_parameter(key.str(), err_flg);
                        if (*err_flg != PLP_OK) {
-                               log_error("Failed to parse device's life cycle state\n");
+                               log_error("Failed to parse life cycle state for the device: %s\n", id.c_str());
                                break;
                        }
                        state   = (EnumDeviceLifeCycleStatus)state_i;
@@ -172,16 +171,17 @@ list<Device *> *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param
                        key.str("");
                        key << RSP__DEVICE_LIST__DATA << ii;
                        datastr = msg_param->get_string_parameter(key.str(), err_flg);
-                       if (*err_flg != PLP_OK) {
-                               log_error("Failed to parse device's data\n");
-                               break;
+                       if (*err_flg == PLP_OK) {
+                               data    = Data::parse_string(datastr);
+                               if (data == NULL) {
+                                       log_error("Failed to parse data items for the device: %s\n", id.c_str());
+                                       *err_flg = PLP_ERR;
+                                       break;
+                               }
                        }
-
-                       data    = Data::parse_string(datastr);
-                       if (data == NULL) {
-                               log_error("Failed to parse device's data items.\n");
-                               *err_flg = PLP_ERR;
-                               break;
+                       else {
+                               log_error("No data available for the device: %s\n", id.c_str());
+                               data    = new Data(0);
                        }
                        dev     = new DeviceData(id, type, name, state, data);
                        ret_val->push_back(dev);
index 3eb8a0106526a191691584934f7c2f11ad78f89c..052234b11f0b80c90c930bcc75ba43dc6f96ef4a 100644 (file)
@@ -200,7 +200,7 @@ void DeviceManagerServer::get_latest_data(BusMessage *msg_req_param,
                if (dev != NULL) {
                        sensor  = dynamic_cast<SensorDevice *>(dev);
                        if (sensor != NULL) {
-                               reader  = sensor->get_device_data();
+                               reader  = sensor->get_datareader();
                                decode_data_to_busmessage(ret_val, reader);
                        }
                }