summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsaerome.kim <saerome.kim@samsung.com>2019-12-03 17:34:06 +0900
committersaerome.kim <saerome.kim@samsung.com>2019-12-03 19:01:10 +0900
commitc452b256fbfbcc73db8c7cc1c0f7ef54392af7d8 (patch)
treec5a95f1857e8fbf4530ad81d887aac266dbdaf1e /src
parente22d39132241c85ff3d15fc85362feec379491af (diff)
downloaduser-awareness-c452b256fbfbcc73db8c7cc1c0f7ef54392af7d8.tar.gz
user-awareness-c452b256fbfbcc73db8c7cc1c0f7ef54392af7d8.tar.bz2
user-awareness-c452b256fbfbcc73db8c7cc1c0f7ef54392af7d8.zip
Reset detected bitmask when STOP command received
- Problem: PRESENCE is not detected after start -> stop -> start PRESENCE detection. - Cause: When receiving the stop PRESENCE detection command, the previously detected sensor bitmask is not initialized. - Solution: When the STOP PRESENCE command is received, initialize the detectedi bitmask. Change-Id: I91ef081509b308174b868f6935067da3d2ce5468 Signed-off-by: saerome.kim <saerome.kim@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/user-awareness-monitors.c92
1 files changed, 8 insertions, 84 deletions
diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c
index e70e44d..735642b 100644
--- a/src/user-awareness-monitors.c
+++ b/src/user-awareness-monitors.c
@@ -455,6 +455,9 @@ static void __ua_monitor_send_sensor_presence_cb(ua_monitor_s *monitor,
* send presence detection callback to application. This will make sure that each sensor is
* detected at least one device from registered devices list.
*/
+ UA_INFO("UA_DETECT_MODE_ALL_SENSOR [%d][%d]",
+ bitmask, monitor->presence_detected_bitmask);
+
if (((bitmask == UA_SENSOR_BLE) && (monitor->sensor_bitmask & UA_SENSOR_WIFI))
|| ((bitmask == UA_SENSOR_WIFI) && (monitor->sensor_bitmask & UA_SENSOR_BLE)))
monitor->presence_detected_bitmask |= (UA_SENSOR_BLE | UA_SENSOR_WIFI);
@@ -467,6 +470,9 @@ static void __ua_monitor_send_sensor_presence_cb(ua_monitor_s *monitor,
break;
case UA_DETECT_MODE_ANY_SENSOR:
+ UA_INFO("UA_DETECT_MODE_ANY_SENSOR [%d][%d]",
+ bitmask, monitor->presence_detected_bitmask);
+
if ((monitor->presence_detected_bitmask & bitmask) == 0)
if (monitor->presence_cb)
monitor->presence_cb(UA_ERROR_NONE, monitor,
@@ -906,89 +912,6 @@ void _ua_monitor_handle_detection_stopped(char *svc_name,
FUNC_EXIT;
}
-#if 0
-static void __ua_remove_sensor(ua_monitor_s *monitor, ua_sensor_e sensor_type)
-{
- FUNC_ENTRY;
- int ret;
- int is_presence = 0;
- int is_absence = 0;
- void *presence_callback = NULL;
- void *presence_user_data = NULL;
- void *absence_callback = NULL;
- void *absence_user_data = NULL;
- ua_detection_mode_e mode_presence;
- ua_detection_mode_e mode_absence;
-
- if (monitor->presence_detection_started) {
- /* Stop detection first */
- if (monitor->presence_cb) {
- /* Presence detection ongoing */
- presence_callback = monitor->presence_cb;
- presence_user_data = monitor->user_data;
- mode_presence = monitor->presence_mode;
-
- ret = ua_monitor_stop_presence_detection(monitor);
- UA_INFO("ua_monitor_stop_presence_detection returned %s",
- _ua_get_error_string(ret));
-
- is_presence = 1;
- } else {
- UA_WARN("Unexpected, detection started but cbs are NULL");
- }
- }
-
- if (monitor->absence_detection_started) {
- /* Stop detection first */
- if (monitor->absence_cb) {
- /* absence detection ongoing */
- absence_callback = monitor->absence_cb;
- absence_user_data = monitor->user_data;
- mode_absence = monitor->absence_mode;
-
- ret = ua_monitor_stop_presence_detection(monitor);
- UA_INFO("ua_monitor_stop_presence_detection returned %s",
- _ua_get_error_string(ret));
-
- is_absence = 1;
- } else {
- UA_WARN("Unexpected, detection started but cbs are NULL");
- }
- }
-
- if (is_presence || is_absence) {
- ret = ua_monitor_remove_sensor(monitor, sensor_type);
- UA_INFO("ua_monitor_remove_sensor returned %s",
- _ua_get_error_string(ret));
- }
-
- if (0 != monitor->sensor_bitmask) {
- if (is_presence) {
- ret = ua_monitor_start_presence_detection(
- monitor, monitor->service, mode_presence, presence_callback, presence_user_data);
- UA_INFO("ua_monitor_start_presence_detection returned %s",
- _ua_get_error_string(ret));
- }
-
- if (is_absence) {
- ret = ua_monitor_start_absence_detection(
- monitor, monitor->service, mode_absence, absence_callback, absence_user_data);
- UA_INFO("ua_monitor_start_absence_detection returned %s",
- _ua_get_error_string(ret));
- }
- }
-
- if (!is_presence && !is_absence) {
- /* Monitoring is already stopped, just remove sensor from monitor */
- ret = ua_monitor_remove_sensor(monitor, sensor_type);
- UA_INFO("ua_monitor_remove_sensor returned %s",
- _ua_get_error_string(ret));
- }
-
- FUNC_EXIT;
-}
-#endif
-
void _ua_monitor_handle_sensor_state(unsigned int bitmask, gboolean ready)
{
FUNC_ENTRY;
@@ -1790,6 +1713,7 @@ int ua_monitor_stop_presence_detection(ua_monitor_h handle)
monitor->presence_cb = NULL;
monitor->user_data = NULL;
monitor->presence_detection_started = FALSE;
+ monitor->presence_detected_bitmask = 0;
g_slist_free_full(monitor->user_state, __ua_free_user_state_info_t);
monitor->user_state = NULL;
monitor->env_user_cb_sent = FALSE;
@@ -1839,7 +1763,7 @@ int ua_monitor_stop_absence_detection(ua_monitor_h handle)
monitor->absence_cb = NULL;
monitor->user_data = NULL;
monitor->absence_detection_started = FALSE;
-
+ monitor->absence_detected_bitmask = 0;
if (!monitor->presence_detection_started) {
g_free(monitor->service);
monitor->service = NULL;