This commit add an API set which can be used by the application to get the detected
sensor information of the sensor using sensor handle.
Change-Id: I10dec7bd427ab5d616bb6860f68e4d318d1234fe
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
ua_registered_dev_cb foreach_cb,
void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets sensor's timestamp.
+ * @since_tizen 5.5
+ *
+ * @param[in] sensor_handle The sensor handle
+ * @param[out] timestamp The sensor's timestamp.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ */
+int ua_sensor_get_timestamp(
+ ua_sensor_h sensor_handle,
+ long int *timestamp);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets sensor's information values count.
+ * @since_tizen 5.5
+ *
+ * @param[in] sensor_handle The sensor handle
+ * @param[out] info_count The sensor's information count.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ */
+int ua_sensor_get_info_count(
+ ua_sensor_h sensor_handle,
+ int *info_count);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets sensor's information values.
+ * @since_tizen 5.5
+ *
+ * @param[in] sensor_handle The sensor handle
+ * @param[out] info_values The sensor's information values.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ */
+GSList *ua_sensor_get_info_values(
+ ua_sensor_h sensor_handle);
+
/**
* @}
*/
Name: capi-network-ua
Summary: User Awareness Framework CAPI
-Version: 0.10.3
+Version: 0.10.4
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
FUNC_EXIT;
return ret;
}
+
+int ua_sensor_get_timestamp(
+ ua_sensor_h sensor_handle,
+ long int *timestamp)
+{
+ FUNC_ENTRY;
+ ua_sensor_info_s *sensor;
+
+ UA_VALIDATE_INPUT_PARAMETER(sensor_handle);
+ UA_INFO("Sensor Handle [%p]", sensor_handle);
+ sensor = (ua_sensor_info_s *)sensor_handle;
+
+ *timestamp = sensor->timestamp;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_sensor_get_info_count(
+ ua_sensor_h sensor_handle,
+ int *count)
+{
+ FUNC_ENTRY;
+ ua_sensor_info_s *sensor;
+
+ UA_VALIDATE_INPUT_PARAMETER(sensor_handle);
+ UA_INFO("Sensor Handle [%p]", sensor_handle);
+ sensor = (ua_sensor_info_s *)sensor_handle;
+
+ *count = sensor->count;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+GSList *ua_sensor_get_info_values(
+ ua_sensor_h sensor_handle)
+{
+ FUNC_ENTRY;
+ unsigned int i = 0;
+ GSList *values = NULL;
+ ua_sensor_info_s *sensor;
+
+ if (!sensor_handle) {
+ goto done;
+ }
+ UA_INFO("Sensor Handle [%p]", sensor_handle);
+ sensor = (ua_sensor_info_s *)sensor_handle;
+
+ if (!sensor->values) {
+ goto done;
+ }
+
+ for(i = 0; i < UA_SENSOR_MAX_VALUES; i++) {
+ values = g_slist_append(values, &sensor->values[i]);
+ }
+
+done:
+ FUNC_EXIT;
+ return values;
+}
g_free(mac);
}
-static void __sensor_presence_detected_sensor_info(ua_sensor_h sensor_handle)
+static void __sensor_presence_detected_sensor_info(ua_sensor_e sensor, ua_sensor_h sensor_handle)
{
-/*
+ int ret;
char buf[MENU_DATA_SIZE] = {0, };
char final_buf[MENU_DATA_SIZE * 4] = {0, };
- for (int i = 0; i < info->count ; i++) {
- if (i >= 4)
- break;
- snprintf(buf, MENU_DATA_SIZE, "%lF ", info->values[i]);
+ long int timestamp;
+ int info_count = 0;
+ GSList *values = NULL;
+ double *value;
+ GSList *l = 0;
+
+ ret = ua_sensor_get_timestamp(sensor_handle, ×tamp);
+ if (UA_ERROR_NONE != ret) {
+ msg(" - ua_sensor_get_timestamp() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+ }
+
+ ret = ua_sensor_get_info_count(sensor_handle, &info_count);
+ if (UA_ERROR_NONE != ret) {
+ msg(" - ua_sensor_get_info_count() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+ }
+
+ values = ua_sensor_get_info_values(sensor_handle);
+ if (NULL == values) {
+ msg(" - ua_sensor_get_info_values() failed");
+ }
+
+ for (l = values; l; l = g_slist_next(l)) {
+ value = (double *)l->data;
+ snprintf(buf, MENU_DATA_SIZE, "%lF ", *value);
strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
memset(buf, 0, MENU_DATA_SIZE);
}
msgb("[%s] information detected at timestamp [%ld] value [%s]",
- uat_get_sensor_bitmask_str(info->bitmask), info->timestamp,
+ uat_get_sensor_bitmask_str(sensor), timestamp,
final_buf);
-*/
+
+ g_slist_free(values);
}
static void __sensor_presence_detected_cb(int result, ua_monitor_h monitor,
__sensor_presence_detected_device(device_handle);
/* For sensor information */
if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION)))
- __sensor_presence_detected_sensor_info(sensor_handle);
+ __sensor_presence_detected_sensor_info(sensor, sensor_handle);
}
static void __sensor_absence_detected_cb(int result, ua_monitor_h monitor,
}
/* For sensor information */
if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION)))
- __sensor_presence_detected_sensor_info(sensor_handle);
+ __sensor_presence_detected_sensor_info(sensor, sensor_handle);
}
void __ua_test_scan_completed_cb(ua_active_scan_type_e result, ua_monitor_h handle,