From 5fd8ec9d225df5cbe6b7ba1b2099c32057e89c41 Mon Sep 17 00:00:00 2001 From: Abhay agarwal Date: Mon, 2 Sep 2019 14:59:33 +0530 Subject: [PATCH] Enable continuous monitoring for envionmental sensors Change-Id: Ib96df58d03eb615dad246beee28f12130fc999ec Signed-off-by: Abhay agarwal --- packaging/ua-manager.spec | 2 +- ua-daemon/include/ua-manager-core.h | 10 +++++----- ua-daemon/src/ua-manager-core.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index 9f2cdec..cb09dad 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -1,6 +1,6 @@ Name: ua-manager Summary: User awareness manager -Version: 0.7.4 +Version: 0.9.0 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/ua-daemon/include/ua-manager-core.h b/ua-daemon/include/ua-manager-core.h index 54d1350..d0287c5 100644 --- a/ua-daemon/include/ua-manager-core.h +++ b/ua-daemon/include/ua-manager-core.h @@ -37,12 +37,12 @@ typedef enum { UAM_ADDR_TYPE_MAX } uam_addr_type_e; -#define UAM_DETECTION_WINDOW_DEFAULT 60 /* 60 seconds */ -#define UAM_DETECTION_WINDOW_MAX 290 /* 290 seconds */ -#define UAM_DETECTION_WINDOW_STEP 10 /* 10 seconds */ +#define UAM_DETECTION_WINDOW_DEFAULT 55 /* 55 seconds */ +#define UAM_DETECTION_WINDOW_MAX 55 /* 55 seconds */ +#define UAM_DETECTION_WINDOW_STEP 5 /* 5 seconds */ -#define UAM_DETECTION_CYCLE_DEFAULT 900 /* 900 seconds */ -#define UAM_DETECTION_CYCLE_MIN 300 /* 300 seconds */ +#define UAM_DETECTION_CYCLE_DEFAULT 60 /* 60 seconds */ +#define UAM_DETECTION_CYCLE_MIN 60 /* 60 seconds */ typedef struct { char *name; diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 5b81d54..c4b12fa 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -594,6 +594,18 @@ unsigned int _uam_core_get_active_sensors(int detection_mode) return sensors; } +unsigned int _uam_core_get_env_sensors() +{ + FUNC_ENTRY; + unsigned int sensors = 0; + + sensors |= UAM_SENSOR_BITMASK_MOTION; + sensors |= UAM_SENSOR_BITMASK_LIGHT; + + FUNC_EXIT; + return sensors; +} + static GSList *__convert_db_svc_list_to_uam_svc_list(GSList *db_svc_list) { FUNC_ENTRY; @@ -1702,6 +1714,17 @@ static gboolean __start_detection(gpointer data) unsigned int sensors; gboolean start_detection = FALSE; GSList *l; + unsigned int env_sensors; + + env_sensors = _uam_core_get_env_sensors(); + UAM_DBG("Envionmental sensors: 0x%8.8X", env_sensors); + if (0 != env_sensors) { + /* Always Start PRESENCE detection on envionmental sensors*/ + ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, env_sensors); + if (UAM_ERROR_NONE != ret) + UAM_ERR("Failed with error: %s (0x%4.4X)", + _uam_manager_error_to_str(ret), ret); + } for (l = services; NULL != l; l = g_slist_next(l)) { service = l->data; @@ -1724,6 +1747,10 @@ static gboolean __start_detection(gpointer data) sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE); UAM_DBG("PRESENCE sensors: 0x%8.8X", sensors); + /* Remove env sensors from active sensors */ + sensors &= ~env_sensors; + UAM_DBG("PRESENCE sensors: 0x%8.8X", sensors); + if (0 != sensors) { /* Start PRESENCE detection */ ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, sensors); -- 2.7.4