Combined bitmask conditions menu and detection menu into one.
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 4 Sep 2019 01:33:13 +0000 (10:33 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 16 Sep 2019 12:04:31 +0000 (21:04 +0900)
Change-Id: Ibf8b870dfdaff8d4952966e0ecd8523313f7c3f5
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/capi-network-ua.spec
test/uat-detections.c

index 8317716295aa32358cb5a1b9a67cd4666ec9f51f..077649fc85cd642660c7a5f01d9b0f18bcf1b7bf 100644 (file)
@@ -1,6 +1,6 @@
 Name: capi-network-ua
 Summary: User Awareness Framework CAPI
-Version: 0.8.3
+Version: 0.8.4
 Release: 1
 License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
index 6e3898d10c3ac9940a391fc6e2f1393e3db6e622..264b5c2103d53603af60df5d2728b95f8c58347b 100644 (file)
@@ -37,14 +37,15 @@ extern char g_service_str[MENU_DATA_SIZE + 1]; /**< Service string */
 static char cycle_time[MENU_DATA_SIZE + 1] = {"900", }; /**< cycle time */
 static char window[MENU_DATA_SIZE + 1] = {"60", }; /**< Detection window */
 
-static char g_presence_and_cond[MENU_DATA_SIZE + 1] = {0,}; /**< PRESENCE AND condition */
-static char g_presence_or_cond[MENU_DATA_SIZE + 1] = {0,}; /**< PRESENCE OR condition */
-static char g_absence_and_cond[MENU_DATA_SIZE + 1] = {0,}; /**< ABSENCE AND condition */
-static char g_absence_or_cond[MENU_DATA_SIZE + 1] = {0,}; /**< ABSENCE OR condition */
-static char g_conjunction_op[MENU_DATA_SIZE + 1] = {"1",}; /**< logical conjunction operation */
-
-static char g_presence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected PRESENCE type */
-static char g_absence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected ABSENCE type */
+static char g_presence_and_cond[MENU_DATA_SIZE + 1] = {"16",}; /**< PRESENCE AND condition */
+static char g_presence_or_cond[MENU_DATA_SIZE + 1] = {"6",}; /**< PRESENCE OR condition */
+static char g_presence_conjunction_op[MENU_DATA_SIZE + 1] = {"1",}; /**< logical conjunction operation */
+static char g_absence_and_cond[MENU_DATA_SIZE + 1] = {"6",}; /**< ABSENCE AND condition */
+static char g_absence_or_cond[MENU_DATA_SIZE + 1] = {"16",}; /**< ABSENCE OR condition */
+static char g_absence_conjunction_op[MENU_DATA_SIZE + 1] = {"0",}; /**< logical conjunction operation */
+
+static char g_presence_type[MENU_DATA_SIZE + 1] = "1"; /**< Selected PRESENCE type */
+static char g_absence_type[MENU_DATA_SIZE + 1] = "1"; /**< Selected ABSENCE type */
 static char g_scan_time_multiplier[MENU_DATA_SIZE + 1] = {0,}; /**< 10ms * what number */
 
 static void __device_presence_detected_cb(int result, ua_monitor_h monitor,
@@ -227,15 +228,16 @@ static int run_ua_monitor_set_user_presence_condition(
                bitmask_and = (unsigned int)strtol(g_presence_and_cond, NULL, 10);
        if (strlen(g_presence_or_cond))
                bitmask_or = (unsigned int)strtol(g_presence_or_cond, NULL, 10);
-       if (strlen(g_conjunction_op))
-               op_value = (unsigned int)strtol(g_conjunction_op, NULL, 10);
+       if (strlen(g_presence_conjunction_op))
+               op_value = (unsigned int)strtol(g_presence_conjunction_op, NULL, 10);
 
        conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION;
 
        msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or",
                        bitmask_or);
 
-       ret = ua_monitor_set_user_presence_condition(g_ua_mon_h, bitmask_and, bitmask_or, conjunction_op);
+       ret = ua_monitor_set_user_presence_condition(g_ua_mon_h,
+               bitmask_and, bitmask_or, conjunction_op);
 
        msg(" - ua_monitor_set_user_presence_condition() ret: [0x%X] [%s]",
                        ret, uat_get_error_str(ret));
@@ -258,8 +260,8 @@ static int run_ua_monitor_set_user_absence_condition(
                bitmask_and = (unsigned int)strtol(g_absence_and_cond, NULL, 10);
        if (strlen(g_absence_or_cond))
                bitmask_or = (unsigned int)strtol(g_absence_or_cond, NULL, 10);
-       if (strlen(g_conjunction_op))
-               op_value = (unsigned int)strtol(g_conjunction_op, NULL, 10);
+       if (strlen(g_absence_conjunction_op))
+               op_value = (unsigned int)strtol(g_absence_conjunction_op, NULL, 10);
 
        conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION;
 
@@ -278,6 +280,10 @@ static int run_ua_monitor_start_presence_detection(
        MManager *mm, struct menu_data *menu)
 {
        int ret = UA_ERROR_NONE;
+       unsigned int bitmask_and = 0;
+       unsigned int bitmask_or = 0;
+       unsigned int op_value = 1;
+       ua_condition_conjunction_e conjunction_op = UA_AND_OPERATION;
 
        msg("ua_monitor_start_presence_detection");
 
@@ -285,6 +291,21 @@ static int run_ua_monitor_start_presence_detection(
 
        check_if(NULL == g_ua_mon_h);
 
+       if (strlen(g_presence_and_cond))
+               bitmask_and = (unsigned int)strtol(g_presence_and_cond, NULL, 10);
+       if (strlen(g_presence_or_cond))
+               bitmask_or = (unsigned int)strtol(g_presence_or_cond, NULL, 10);
+       if (strlen(g_presence_conjunction_op))
+               op_value = (unsigned int)strtol(g_presence_conjunction_op, NULL, 10);
+
+       conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION;
+
+       msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or",
+                       bitmask_or);
+
+       ret = ua_monitor_set_user_presence_condition(g_ua_mon_h,
+               bitmask_and, bitmask_or, conjunction_op);
+
        if (strlen(g_presence_type))
                detection_mode = (unsigned char)strtol(g_presence_type, NULL, 10);
 
@@ -320,12 +341,32 @@ static int run_ua_monitor_start_absence_detection(
 {
        int ret = UA_ERROR_NONE;
 
-       msg("ua_monitor_start_absence_detection");
+       unsigned int bitmask_and = 0;
+       unsigned int bitmask_or = 0;
+       unsigned int op_value = 1;
+       ua_condition_conjunction_e conjunction_op = UA_AND_OPERATION;
 
-       ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID;
+       msg("ua_monitor_start_absence_detection");
 
        check_if(NULL == g_ua_mon_h);
 
+       if (strlen(g_absence_and_cond))
+               bitmask_and = (unsigned int)strtol(g_absence_and_cond, NULL, 10);
+       if (strlen(g_absence_or_cond))
+               bitmask_or = (unsigned int)strtol(g_absence_or_cond, NULL, 10);
+       if (strlen(g_absence_conjunction_op))
+               op_value = (unsigned int)strtol(g_absence_conjunction_op, NULL, 10);
+
+       conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION;
+
+       msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or",
+                       bitmask_or);
+
+       ret = ua_monitor_set_user_absence_condition(g_ua_mon_h,
+               bitmask_and, bitmask_or, conjunction_op);
+
+       ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID;
+
        if (strlen(g_absence_type))
                detection_mode = (unsigned char)strtol((g_absence_type), NULL, 10);
 
@@ -494,7 +535,7 @@ static int run_device_power_request_poweroff(
         msgr("Fail to request power off");
         return false;
     }
-#if 0
+
        ret = device_power_set_wakeup_reason(POWER_WAKEUP_REASON_REMOTE_CONTROLLER);
        if(POWER_ERROR_NONE != device_power_set_wakeup_reason(POWER_WAKEUP_REASON_REMOTE_CONTROLLER))
        {
@@ -506,7 +547,7 @@ static int run_device_power_request_poweroff(
                msgr("Failed to request TV to STANDBY!");
                return RET_SUCCESS;
        }
-#endif
+
        msg(" - run_device_power_request_poweroff() ret: [0x%X] [%s]",
                        ret, uat_get_error_str(ret));
 
@@ -546,7 +587,7 @@ static struct menu_data menu_ua_set_presence_condition[] = {
        { "2", "OR Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
                NULL, NULL, g_presence_or_cond },
        { "3", "logical conjunction operation(0:OR, 1:AND)",
-               NULL, NULL, g_conjunction_op },
+               NULL, NULL, g_presence_conjunction_op },
        { "4", "run", NULL,
                run_ua_monitor_set_user_presence_condition, NULL },
        { NULL, NULL, },
@@ -558,7 +599,7 @@ static struct menu_data menu_ua_set_absence_condition[] = {
        { "2", "OR Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
                NULL, NULL, g_absence_or_cond },
        { "3", "logical conjunction operation(0:OR, 1:AND)",
-               NULL, NULL, g_conjunction_op },
+               NULL, NULL, g_absence_conjunction_op },
        { "4", "run", NULL,
                run_ua_monitor_set_user_absence_condition, NULL },
        { NULL, NULL, },
@@ -571,24 +612,46 @@ static struct menu_data menu_start_device_scan[] = {
 };
 
 static struct menu_data menu_ua_start_presence[] = {
-       { "1", "type (1:ALL 2:ANY)", NULL, NULL, g_presence_type },
-       { "2", "service(empty for default, else selected service)", NULL, NULL, g_service_str},
-       { "3", "run", NULL, run_ua_monitor_start_presence_detection, NULL },
+       { "1", "AND (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
+               NULL, NULL, g_presence_and_cond },
+       { "2", "OR (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
+               NULL, NULL, g_presence_or_cond },
+       { "3", "[1] cond. [2] (0:OR, 1:AND)",
+               NULL, NULL, g_presence_conjunction_op },
+       { "4", "type (1:ALL 2:ANY)",
+               NULL, NULL, g_presence_type },
+       { "5", "service(empty for default, else selected service)",
+               NULL, NULL, g_service_str},
+       { "6", "run",
+               NULL, run_ua_monitor_start_presence_detection, NULL },
        { NULL, NULL, },
 };
 
 static struct menu_data menu_ua_start_absence[] = {
-       { "1", "type (1:ALL 2:ANY)", NULL, NULL, g_absence_type },
-       { "2", "service(empty for default, else selected service)", NULL, NULL, g_service_str},
-       { "3", "run", NULL, run_ua_monitor_start_absence_detection, NULL },
+       { "1", "AND (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
+               NULL, NULL, g_absence_and_cond },
+       { "2", "OR (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
+               NULL, NULL, g_absence_or_cond },
+       { "3", "[1] cond. [2] ( 0:OR, 1:AND)",
+               NULL, NULL, g_absence_conjunction_op },
+       { "4", "type (1:ALL 2:ANY)",
+               NULL, NULL, g_absence_type },
+       { "5", "service(empty for default, else selected service)",
+               NULL, NULL, g_service_str},
+       { "6", "run",
+               NULL, run_ua_monitor_start_absence_detection, NULL },
        { NULL, NULL, },
 };
 
 static struct menu_data menu_start_absence_presence[] = {
-       { "1", "ABSENCE detection type (1:ALL 2:ANY)", NULL, NULL, g_absence_type },
-       { "2", "PRESENCE detection type (1:ALL 2:ANY)", NULL, NULL, g_presence_type },
-       { "3", "start", NULL, run_ua_monitor_start_absence_presence, NULL },
-       { "4", "stop", NULL, run_ua_monitor_stop_absence_presence, NULL },
+       { "1", "ABSENCE detection type (1:ALL 2:ANY)",
+               NULL, NULL, g_absence_type },
+       { "2", "PRESENCE detection type (1:ALL 2:ANY)",
+               NULL, NULL, g_presence_type },
+       { "3", "start",
+               NULL, run_ua_monitor_start_absence_presence, NULL },
+       { "4", "stop",
+               NULL, run_ua_monitor_stop_absence_presence, NULL },
        { NULL, NULL, },
 };