diff options
author | Abhay Agarwal <ay.agarwal@samsung.com> | 2019-09-19 14:14:29 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-09-23 14:24:43 +0900 |
commit | e804ce2430df0713e8b65d26f632f064ea027325 (patch) | |
tree | 9389bde16dd8315cddf3a4db3189b8bc09e3885e /src | |
parent | 3c874ebcf9d2c36e5c8dff5a3957f217c0ba4697 (diff) | |
download | user-awareness-e804ce2430df0713e8b65d26f632f064ea027325.tar.gz user-awareness-e804ce2430df0713e8b65d26f632f064ea027325.tar.bz2 user-awareness-e804ce2430df0713e8b65d26f632f064ea027325.zip |
Support Add/Remove sensor during detection
Change-Id: I7337191785ac65c251a549f058c294d7d19da7d1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/user-awareness-monitors.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 727b820..2ca3a09 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -1218,9 +1218,6 @@ int ua_monitor_add_sensor( UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); - retv_if(TRUE == monitor->presence_detection_started, UA_ERROR_NOT_PERMITTED); - retv_if(TRUE == monitor->absence_detection_started, UA_ERROR_NOT_PERMITTED); - bitmask = __ua_sensor_type_to_bitmask(sensor_type); retv_if(0 != (monitor->sensor_bitmask & bitmask), UA_ERROR_ALREADY_DONE); @@ -1247,9 +1244,6 @@ int ua_monitor_remove_sensor( UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); - retv_if(TRUE == monitor->presence_detection_started, UA_ERROR_NOT_PERMITTED); - retv_if(TRUE == monitor->absence_detection_started, UA_ERROR_NOT_PERMITTED); - bitmask = __ua_sensor_type_to_bitmask(sensor_type); retv_if(0 == (monitor->sensor_bitmask & bitmask), UA_ERROR_ALREADY_DONE); @@ -1366,6 +1360,7 @@ int ua_monitor_start_presence_detection( ua_detection_type_e detect = UA_PRESENCE_DETECTION; char *service; GSList *ua_services_list = _ua_service_get_services(); + unsigned int available_sensors = 0; UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); @@ -1399,12 +1394,12 @@ int ua_monitor_start_presence_detection( else monitor->service = g_strndup(service, UA_MAX_SERVICE_LEN); } - /** - * TODO: Check if we have to check is_sensor_ready at this point and remove sensor - * from monitor if sensor is not ready - */ + if (UA_ERROR_NONE != _ua_get_error_code( + _uam_get_available_sensors(&available_sensors))) + UA_WARN("_uam_get_available_sensors failed"); + if (!monitor->internal_presence_started || !monitor->absence_detection_started) { - ret = __ua_start_monitoring(monitor->sensor_bitmask, monitor->service, detect); + ret = __ua_start_monitoring(available_sensors, monitor->service, detect); if (UA_ERROR_NONE != ret) { /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", @@ -1440,6 +1435,7 @@ int ua_monitor_start_absence_detection( ua_detection_type_e detect = UA_ABSENCE_DETECTION; char *service; GSList *ua_services_list = _ua_service_get_services(); + unsigned int available_sensors = 0; UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); @@ -1482,10 +1478,10 @@ int ua_monitor_start_absence_detection( monitor->service = g_strndup(service, UA_MAX_SERVICE_LEN); } - /* TODO: Check if we have to check is_sensor_ready at this point and remove sensor - * from monitor if sensor is not ready. - */ - ret = __ua_start_monitoring(monitor->sensor_bitmask, monitor->service, detect); + if (UA_ERROR_NONE != _ua_get_error_code( + _uam_get_available_sensors(&available_sensors))) + UA_WARN("_uam_get_available_sensors failed"); + ret = __ua_start_monitoring(available_sensors, monitor->service, detect); if (mode == UA_DETECT_MODE_ALL_SENSOR) __ua_monitor_internal_presence_ref(monitor); @@ -1520,13 +1516,17 @@ int ua_monitor_stop_presence_detection(ua_monitor_h handle) int ret; ua_monitor_s *monitor = (ua_monitor_s *)handle; ua_detection_type_e detect = UA_PRESENCE_DETECTION; + unsigned int available_sensors = 0; UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); retv_if(FALSE == monitor->presence_detection_started, UA_ERROR_NOT_IN_PROGRESS); + if (UA_ERROR_NONE != _ua_get_error_code( + _uam_get_available_sensors(&available_sensors))) + UA_WARN("_uam_get_available_sensors failed"); if (!monitor->internal_presence_started || !monitor->absence_detection_started) { - ret = __ua_stop_monitoring(monitor->sensor_bitmask, monitor->service, detect); + ret = __ua_stop_monitoring(available_sensors, monitor->service, detect); if (UA_ERROR_NONE != ret) { /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", @@ -1558,13 +1558,17 @@ int ua_monitor_stop_absence_detection(ua_monitor_h handle) int ret; ua_monitor_s *monitor = (ua_monitor_s *)handle; ua_detection_type_e detect = UA_ABSENCE_DETECTION; + unsigned int available_sensors = 0; UA_VALIDATE_INPUT_PARAMETER(handle); UA_VALIDATE_HANDLE(handle, ua_monitor_list); retv_if(FALSE == monitor->absence_detection_started, UA_ERROR_NOT_IN_PROGRESS); retv_if(NULL == monitor->absence_cb, UA_ERROR_NOT_IN_PROGRESS); + if (UA_ERROR_NONE != _ua_get_error_code( + _uam_get_available_sensors(&available_sensors))) + UA_WARN("_uam_get_available_sensors failed"); - ret = __ua_stop_monitoring(monitor->sensor_bitmask, monitor->service, detect); + ret = __ua_stop_monitoring(available_sensors, monitor->service, detect); if (UA_ERROR_NONE != ret) { /* LCOV_EXCL_START */ UA_ERR("Failed with error: %s(0x%X)", |