diff options
author | Abhay Agarwal <ay.agarwal@samsung.com> | 2019-10-04 19:39:01 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-10-04 20:22:56 +0900 |
commit | bc903f646ce332f2a2b527de03ce94ecc2369c95 (patch) | |
tree | ea707cfb1a2bce1c2f67b754215f574ba3feb3e6 /src | |
parent | da808f97cec0a17f7a1ac31d41f6ceecdb643688 (diff) | |
download | user-awareness-bc903f646ce332f2a2b527de03ce94ecc2369c95.tar.gz user-awareness-bc903f646ce332f2a2b527de03ce94ecc2369c95.tar.bz2 user-awareness-bc903f646ce332f2a2b527de03ce94ecc2369c95.zip |
Provide sensor information in user detection callback
Change-Id: I79c1256f8bd1ea21f8421d3964b573d6eba45cef
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/user-awareness-monitors.c | 7 | ||||
-rw-r--r-- | src/user-awareness-util.c | 38 |
2 files changed, 44 insertions, 1 deletions
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) |