for (auto it = info.attributes_str.begin(); it != info.attributes_str.end(); ++it) {
int attribute = it->first;
const char *value = it->second->get();
- int value_len = it->second->size();
- if (!cmd_channel->cmd_set_attribute_str(attribute, value, value_len)) {
+ int len = it->second->size();
+ if (!cmd_channel->cmd_set_attribute_str(attribute, value, len)) {
_E("Failed to send cmd_set_attribute_str(%d, %d, %s) for %s",
- client_id, value_len, value, get_client_name());
+ client_id, len, value, get_client_name());
return false;
}
}
return true;
}
-bool command_channel::cmd_set_attribute_str(int attribute, const char* value, int value_len)
+bool command_channel::cmd_set_attribute_str(int attribute, const char* value, int len)
{
cpacket *packet;
cmd_set_attribute_str_t *cmd_set_attribute_str;
cmd_done_t *cmd_done;
- packet = new(std::nothrow) cpacket(sizeof(cmd_set_attribute_str_t) + value_len);
+ packet = new(std::nothrow) cpacket(sizeof(cmd_set_attribute_str_t) + len);
retvm_if(!packet, false, "Failed to allocate memory");
packet->set_cmd(CMD_SET_ATTRIBUTE_STR);
cmd_set_attribute_str = (cmd_set_attribute_str_t*)packet->data();
cmd_set_attribute_str->attribute = attribute;
- cmd_set_attribute_str->value_len = value_len;
- memcpy(cmd_set_attribute_str->value, value, value_len);
+ cmd_set_attribute_str->len = len;
+ memcpy(cmd_set_attribute_str->value, value, len);
_I("%s send cmd_set_attribute_str(client_id=%d, attribute = %#x, value_len = %d, value = %#x)",
- get_client_name(), m_client_id, attribute, value_len, value);
+ get_client_name(), m_client_id, attribute, len, value);
if (!command_handler(packet, (void **)&cmd_done)) {
_E("%s failed to send/receive command with client_id [%d]",
bool cmd_unset_batch(void);
bool cmd_get_data(unsigned int type, sensor_data_t *values);
bool cmd_set_attribute_int(int attribute, int value);
- bool cmd_set_attribute_str(int attribute, const char *value, int value_len);
+ bool cmd_set_attribute_str(int attribute, const char *value, int len);
bool cmd_flush(void);
private:
* @retval -EINVAL Invalid parameter
* @retval -EPERM Operation not permitted
*/
-int sensord_set_attribute_str(int handle, int attribute, const char *value, int value_len);
+int sensord_set_attribute_str(int handle, int attribute, const char *value, int len);
/**
* @brief Send data to sensorhub
{
return true;
}
- virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, int value_len)
+ virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, int len)
{
return true;
}
goto out;
}
- ret_value = m_module->add_attribute(m_client_id, cmd->attribute, cmd->value, cmd->value_len);
+ ret_value = m_module->add_attribute(m_client_id, cmd->attribute, cmd->value, cmd->len);
out:
if (!send_cmd_done(ret_value))
return OP_SUCCESS;
}
-int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len)
+int physical_sensor::set_attribute(int32_t attribute, char *value, int len)
{
AUTOLOCK(m_mutex);
if (!m_sensor_device)
return OP_ERROR;
- if (!m_sensor_device->set_attribute_str(m_info->id, attribute, value, value_len))
+ if (!m_sensor_device->set_attribute_str(m_info->id, attribute, value, len))
return OP_ERROR;
return OP_SUCCESS;
virtual bool on_start(void);
virtual bool on_stop(void);
virtual int set_attribute(int32_t attribute, int32_t value);
- virtual int set_attribute(int32_t attribute, char *value, int value_len);
+ virtual int set_attribute(int32_t attribute, char *value, int len);
virtual bool set_interval(unsigned long interval);
virtual bool set_batch_latency(unsigned long latency);
virtual bool get_sensor_info(sensor_info &info);
typedef struct {
int attribute;
- int value_len;
+ int len;
char value[0];
} cmd_set_attribute_str_t;