diff options
author | Abhay Agarwal <ay.agarwal@samsung.com> | 2019-09-23 19:03:45 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-09-26 15:47:06 +0900 |
commit | 3a1ec14f8d657ae6109f85a57d1c60b7cda52638 (patch) | |
tree | fca5581b814691a9073869c37ff117b305dcf3b3 | |
parent | 0a5ca7fc858c4bd32da501f57b202cf820191773 (diff) | |
download | user-awareness-3a1ec14f8d657ae6109f85a57d1c60b7cda52638.tar.gz user-awareness-3a1ec14f8d657ae6109f85a57d1c60b7cda52638.tar.bz2 user-awareness-3a1ec14f8d657ae6109f85a57d1c60b7cda52638.zip |
Modified test app for sensor info in callback
Change-Id: I79de27fcc552a788f348ffca6ad63c3edcec2539
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r-- | include/user-awareness-private.h | 8 | ||||
-rw-r--r-- | include/user-awareness-util.h | 19 | ||||
-rw-r--r-- | include/user-awareness.h | 12 | ||||
-rw-r--r-- | packaging/capi-network-ua.spec | 2 | ||||
-rw-r--r-- | src/user-awareness-event-handler.c | 16 | ||||
-rw-r--r-- | src/user-awareness-monitors.c | 11 | ||||
-rw-r--r-- | src/user-awareness-util.c | 29 | ||||
-rw-r--r-- | test/uat-detections.c | 11 |
8 files changed, 93 insertions, 15 deletions
diff --git a/include/user-awareness-private.h b/include/user-awareness-private.h index 07cb6fa..41b52d2 100644 --- a/include/user-awareness-private.h +++ b/include/user-awareness-private.h @@ -130,6 +130,12 @@ extern "C" { #define UA_MIN_DETECTION_CYCLE 60 /**< 1 min */ /** + * @brief Maximum sensor values count. + * @since_tizen 5.5 + */ +#define UA_SENSOR_MAX_VALUES 4 /**< 4 values */ + +/** * @brief Default service name. * @since_tizen 5.5 */ @@ -321,7 +327,7 @@ void _ua_monitor_handle_scan_complete(int result); * @pre * @post */ -void _ua_monitor_handle_user_presence_detected(unsigned int bitmask, +void _ua_monitor_handle_user_presence_detected(uam_sensor_info_s *sensor_info, char *service, char *account, long timestamp, char *device_id); diff --git a/include/user-awareness-util.h b/include/user-awareness-util.h index 0f93d13..6a70257 100644 --- a/include/user-awareness-util.h +++ b/include/user-awareness-util.h @@ -197,6 +197,25 @@ ua_sensor_e _ua_dev_type_to_sensor(ua_mac_type_e type); */ ua_sensor_e _uam_to_ua_sensor(uam_sensor_bitmask_e bitmask); +/** + * @ingroup CAPI_NETWORK_UA_MODULE + * @internal + * @brief Converts uam sensor info to ua sensor info. + * @since_tizen 5.5 + * + * @remarks The returned value can be used until return call function is valid. + * + * @param[in] Struct uam sensor info to be converted. + * + * @return Sensor info struct + * + * @exception + * @pre + * @post + * + */ +ua_sensor_info_s* _uam_to_ua_sensor_info(uam_sensor_info_s *info); + #ifdef __cplusplus } #endif diff --git a/include/user-awareness.h b/include/user-awareness.h index 2831e4c..ad5b34c 100644 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -245,6 +245,18 @@ typedef enum { } ua_condition_conjunction_e; /** + * @brief sensor info data structure. + * @since_tizen 5.5 + */ +typedef struct { + ua_sensor_e bitmask; + long int timestamp; + int accuracy; + int count; + double *values; +} ua_sensor_info_s; + +/** * @ingroup CAPI_NETWORK_UA_MODULE * @brief The handle of user presence/absence monitor. * @since_tizen 5.5 diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec index 3ab6d7f..56f1ec1 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.9.4 +Version: 0.10.0 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/user-awareness-event-handler.c b/src/user-awareness-event-handler.c index 1498865..0b3af80 100644 --- a/src/user-awareness-event-handler.c +++ b/src/user-awareness-event-handler.c @@ -43,6 +43,7 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param, void *u switch (event) { case UAM_EVENT_USER_PRESENCE_DETECTED: { uam_detection_event_data_s *event_data = NULL; + uam_sensor_info_s *sensor_info = NULL; event_data = event_param->data; ret_if(NULL == event_data); @@ -51,8 +52,9 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param, void *u ret_if(0 == event_data->timestamp); ret_if(NULL == event_data->device_id); + sensor_info->sensor_bitmask = event_data->sensor_bitmask; _ua_monitor_handle_user_presence_detected( - event_data->sensor_bitmask, event_data->service, + sensor_info, event_data->service, event_data->account, event_data->timestamp, event_data->device_id); @@ -73,15 +75,15 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param, void *u break; } case UAM_EVENT_PRESENCE_DETECTED: { - uam_sensor_info_s *event_data = NULL; + uam_sensor_info_s *sensor_info = NULL; - event_data = event_param->data; - ret_if(NULL == event_data); + sensor_info = event_param->data; + ret_if(NULL == sensor_info); UA_INFO("sensor: [%u], timestamp [%ld], accuracy [%d], value [%f]", - event_data->sensor_bitmask, event_data->timestamp, - event_data->accuracy, event_data->values[0]); - _ua_monitor_handle_user_presence_detected(event_data->sensor_bitmask, NULL, + sensor_info->sensor_bitmask, sensor_info->timestamp, + sensor_info->accuracy, sensor_info->values[0]); + _ua_monitor_handle_user_presence_detected(sensor_info, NULL, NULL, 0, NULL); break; diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 2ca3a09..b9bb722 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -676,12 +676,18 @@ void _ua_monitor_handle_scan_complete(int result) FUNC_EXIT; } -void _ua_monitor_handle_user_presence_detected(unsigned int uam_bitmask, +void _ua_monitor_handle_user_presence_detected(uam_sensor_info_s *info, char *service, char *account, long timestamp, char *device_id) { FUNC_ENTRY; GSList *l; - ua_sensor_e bitmask = _uam_to_ua_sensor(uam_bitmask); + ua_sensor_info_s *sensor_info; + ua_sensor_e bitmask; + ret_if(NULL == info); + + sensor_info = _uam_to_ua_sensor_info(info); + ret_if(NULL == sensor_info); + bitmask = sensor_info->bitmask; for (l = ua_monitor_list; l; l = g_slist_next(l)) { ua_monitor_s *monitor = l->data; @@ -695,6 +701,7 @@ void _ua_monitor_handle_user_presence_detected(unsigned int uam_bitmask, if (!service || !g_strcmp0(service, monitor->service)) { /* Presence detection ongoing */ + monitor->user_data = sensor_info; __ua_sensor_presence_detected(monitor, bitmask, account, timestamp, device_id); } diff --git a/src/user-awareness-util.c b/src/user-awareness-util.c index f16dbf3..6b479a6 100644 --- a/src/user-awareness-util.c +++ b/src/user-awareness-util.c @@ -213,3 +213,32 @@ ua_sensor_e _uam_to_ua_sensor(uam_sensor_bitmask_e bitmask) } FUNC_EXIT; } + +ua_sensor_info_s* _uam_to_ua_sensor_info(uam_sensor_info_s *info) +{ + FUNC_ENTRY; + ua_sensor_info_s *sensor_info = NULL; + unsigned int i = 0; + + sensor_info = g_malloc0(sizeof(ua_sensor_info_s)); + if (!sensor_info) { + UA_ERR("g_malloc0 failed"); + return NULL; + } + sensor_info->values = NULL; + sensor_info->values = g_malloc0(UA_SENSOR_MAX_VALUES*sizeof(double)); + if (!sensor_info->values) { + UA_ERR("g_malloc0 failed"); + g_free(sensor_info); + return NULL; + } + sensor_info->timestamp = info->timestamp; + sensor_info->count = info->count; + sensor_info->bitmask = _uam_to_ua_sensor(info->sensor_bitmask); + for(i = 0; i < UA_SENSOR_MAX_VALUES; i++) { + sensor_info->values[i] = info->values[i]; + } + + return sensor_info; + FUNC_EXIT; +} diff --git a/test/uat-detections.c b/test/uat-detections.c index cb76c17..088eb01 100644 --- a/test/uat-detections.c +++ b/test/uat-detections.c @@ -55,6 +55,8 @@ static void __device_presence_detected_cb(int result, ua_monitor_h monitor, msg("\n[%s] Device PRESENCE [%d]", pbuf, sensor); free(pbuf); + ua_sensor_info_s *info; + info = user_data; if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) { msgb("[%s] PRESENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_BLE), uat_get_error_str(result)); @@ -64,12 +66,13 @@ static void __device_presence_detected_cb(int result, ua_monitor_h monitor, uat_get_sensor_bitmask_str(UA_SENSOR_WIFI), uat_get_error_str(result)); } if (UA_SENSOR_LIGHT == (UA_SENSOR_LIGHT & sensor)) { - msgb("[%s] PRESENCE detected [%s]", - uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT),uat_get_error_str(result)); + msgb("[%s] PRESENCE detected at timestamp [%ld] lux [%f] [%s]", + uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT), info->timestamp, + info->values[0], uat_get_error_str(result)); } if (UA_SENSOR_MOTION == (UA_SENSOR_MOTION & sensor)) { - msgb("[%s] PRESENCE detected [%s]", - uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), uat_get_error_str(result)); + msgb("[%s] PRESENCE detected at timestamp [%ld] [%s]", + uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), info->timestamp, uat_get_error_str(result)); } } |