diff options
-rwxr-xr-x | include/user-awareness-util.h | 24 | ||||
-rw-r--r-- | include/user-awareness.h | 22 | ||||
-rw-r--r-- | packaging/capi-network-ua.spec | 2 | ||||
-rw-r--r-- | src/user-awareness-monitors.c | 7 | ||||
-rw-r--r-- | src/user-awareness-util.c | 38 | ||||
-rw-r--r-- | test/uat-common.c | 2 | ||||
-rw-r--r-- | test/uat-init.c | 55 |
7 files changed, 145 insertions, 5 deletions
diff --git a/include/user-awareness-util.h b/include/user-awareness-util.h index 1534e60..8b23af7 100755 --- a/include/user-awareness-util.h +++ b/include/user-awareness-util.h @@ -243,6 +243,30 @@ int ua_sensor_get_by_sensor_info( /** * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Gets sensor handle by sensor info. + * @since_tizen 5.5 + * + * @remarks The @a sensor_handle should not be released. + * @remarks The @a sensor_handle can be used only in the function. + * + * @param[in] sensor_bitmask The detected sensors bitmask + * @param[out] sensor_handle The sensor handles list + * + * @return 0 on success, otherwise a negative error value + * @retval #UA_ERROR_NONE Successful + * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory + * + * @exception + * @pre + * @post + * + */ +GSList *ua_sensor_get_sensor_handle_list( + unsigned int sensor_bitmask); + +/** + * @ingroup CAPI_NETWORK_UA_MODULE * @brief Releases sensor info. * @since_tizen 5.5 * diff --git a/include/user-awareness.h b/include/user-awareness.h index b36d510..88c6388 100644 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -470,6 +470,7 @@ typedef void (*ua_presence_user_detected_cb)( ua_monitor_h handle, ua_user_h user_handle, GSList *device_handles, + GSList *sensor_handle, void *user_data); /** @@ -2753,6 +2754,27 @@ int ua_sensor_get_timestamp( /** * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Gets sensor's timestamp. + * @since_tizen 5.5 + * + * @param[in] sensor_handle The sensor handle + * @param[out] bitmask The sensor's bitmask. + * + * @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_bitmask( + ua_sensor_h sensor_handle, + ua_sensor_e *bitmask); + +/** + * @ingroup CAPI_NETWORK_UA_MODULE * @brief Gets sensor's information values count. * @since_tizen 5.5 * diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec index a09984f..64d76ec 100644 --- a/packaging/capi-network-ua.spec +++ b/packaging/capi-network-ua.spec @@ -1,6 +1,6 @@ Name: capi-network-ua Summary: User Awareness Framework CAPI -Version: 0.11.0 +Version: 0.11.1 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index fcbdd77..d0a3ba6 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -250,6 +250,7 @@ static void __ua_monitor_send_user_presence_cb(ua_monitor_s *monitor, gboolean or_condition = 0; gboolean condition_result = 0; ua_dev_info_s *dev = 0; + GSList *sensors = 0; ret_if(NULL == user_state); @@ -300,6 +301,9 @@ static void __ua_monitor_send_user_presence_cb(ua_monitor_s *monitor, return; } + /** Get sensor list*/ + sensors = ua_sensor_get_sensor_handle_list(monitor->presence_detected_bitmask); + /** * Filter the list of found_devices according to sensors mentioned in * AND/OR conditions. @@ -318,12 +322,13 @@ static void __ua_monitor_send_user_presence_cb(ua_monitor_s *monitor, ((ua_presence_user_detected_cb)monitor->presence_user_cb.callback)( UA_ERROR_NONE, monitor, user_handle, - devices, + devices, sensors, monitor->presence_user_cb.user_data); user_state->cb_sent = TRUE; g_slist_free(devices); + g_slist_free(sensors); FUNC_EXIT; return; diff --git a/src/user-awareness-util.c b/src/user-awareness-util.c index 415acef..5e113f3 100644 --- a/src/user-awareness-util.c +++ b/src/user-awareness-util.c @@ -338,6 +338,27 @@ done: return ret; } +GSList *ua_sensor_get_sensor_handle_list( + unsigned int bitmask) +{ + FUNC_ENTRY; + GSList *sensors = NULL; + GSList *l; + ua_sensor_info_s *sensor; + + for (l = ua_sensors_list; NULL != l; l = g_slist_next(l)) { + sensor = (ua_sensor_info_s *)l->data; + + if (bitmask & sensor->bitmask) { + UA_INFO("Sensor info found, sensor bitmask[%d]", sensor->bitmask); + sensors = g_slist_append(sensors, sensor->handle); + } + } + + FUNC_EXIT; + return sensors; +} + int ua_sensor_get_timestamp( ua_sensor_h sensor_handle, long int *timestamp) @@ -355,6 +376,23 @@ int ua_sensor_get_timestamp( return UA_ERROR_NONE; } +int ua_sensor_get_bitmask( + ua_sensor_h sensor_handle, + ua_sensor_e *bitmask) +{ + 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; + + *bitmask = sensor->bitmask; + + FUNC_EXIT; + return UA_ERROR_NONE; +} + int ua_sensor_get_info_count( ua_sensor_h sensor_handle, int *count) diff --git a/test/uat-common.c b/test/uat-common.c index 4b9b838..466a757 100644 --- a/test/uat-common.c +++ b/test/uat-common.c @@ -151,5 +151,3 @@ char* uat_get_time() return pbuf; } - - diff --git a/test/uat-init.c b/test/uat-init.c index 640b913..2381cfd 100644 --- a/test/uat-init.c +++ b/test/uat-init.c @@ -101,8 +101,58 @@ static void __user_presence_detected_foreach_devices(gpointer data, g_free(mac); } +static void __user_presence_detected_foreach_sensors(gpointer data, + gpointer user_data) +{ + int ret; + char buf[MENU_DATA_SIZE] = {0, }; + char final_buf[MENU_DATA_SIZE * 4] = {0, }; + long int timestamp; + int info_count = 0; + GSList *values = NULL; + double *value; + GSList *l = 0; + ua_sensor_e bitmask; + ua_device_h sensor_handle = (ua_sensor_h)data; + + ret = ua_sensor_get_bitmask(sensor_handle, &bitmask); + if (UA_ERROR_NONE != ret) { + msg(" - ua_sensor_get_bitmask() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + } + + 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(bitmask), timestamp, + final_buf); + + g_slist_free(values); +} + static void __user_presence_detected_cb(int result, ua_monitor_h monitor, - ua_user_h user_handle, GSList *device_handles, + ua_user_h user_handle, GSList *device_handles, GSList *sensor_handles, void *user_data) { int ret; @@ -122,6 +172,9 @@ static void __user_presence_detected_cb(int result, ua_monitor_h monitor, __user_presence_detected_foreach_devices, account); + g_slist_foreach(sensor_handles, + __user_presence_detected_foreach_sensors, NULL); + g_free(account); } |