/* * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #ifdef SUSPEND_RESUME_TEST #include #include #endif #include #include #include "uat-menu.h" #include "uat-common.h" extern ua_monitor_h g_ua_mon_h; /**< Monitor handle */ extern ua_service_h g_service_h; /**< Service handle */ 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] = {"55", }; /**< Detection window */ 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] = "2"; /**< Selected PRESENCE type */ static char g_absence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected ABSENCE type */ static char g_scan_time_multiplier[MENU_DATA_SIZE + 1] = {0,}; /**< 10ms * what number */ static void __sensor_presence_detected_device(ua_device_h device_handle) { int ret; ua_mac_type_e mac_type; char *mac = NULL; ret = ua_device_get_mac_address(device_handle, &mac); if (UA_ERROR_NONE != ret) { msg(" - ua_device_get_mac_address() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } ret = ua_device_get_mac_type(device_handle, &mac_type); if (UA_ERROR_NONE != ret) { msg(" - ua_device_get_mac_type() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } msgb("Presence detected on [%s][%s]", __convert_device_mac_type_to_txt(mac_type), mac); g_free(mac); } static void __sensor_presence_detected_sensor_info(ua_sensor_e sensor, ua_sensor_h sensor_handle) { int ret; char buf[MENU_DATA_SIZE] = {0, }; char final_buf[MENU_DATA_SIZE * 4] = {0, }; long int timestamp; int info_count = 0; GSList *values = NULL; double *value; GSList *l = 0; ret = ua_sensor_get_timestamp(sensor_handle, ×tamp); if (UA_ERROR_NONE != ret) { msg(" - ua_sensor_get_timestamp() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } ret = ua_sensor_get_info_count(sensor_handle, &info_count); if (UA_ERROR_NONE != ret) { msg(" - ua_sensor_get_info_count() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } values = ua_sensor_get_info_values(sensor_handle); if (NULL == values) { msg(" - ua_sensor_get_info_values() failed"); } for (l = values; l; l = g_slist_next(l)) { value = (double *)l->data; snprintf(buf, MENU_DATA_SIZE, "%lF ", *value); strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1); memset(buf, 0, MENU_DATA_SIZE); } msgb("[%s] information detected at timestamp [%ld] value [%s]", uat_get_sensor_bitmask_str(sensor), timestamp, final_buf); g_slist_free(values); } static void __sensor_presence_detected_cb(int result, ua_monitor_h monitor, ua_sensor_e sensor, ua_device_h device_handle, ua_sensor_h sensor_handle, void *user_data) { char *pbuf = uat_get_time(); msg("\n[%s] Sensor PRESENCE [%d]", pbuf, sensor); free(pbuf); if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) { msgb("[%s] PRESENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_BLE), uat_get_error_str(result)); } if (UA_SENSOR_WIFI == (UA_SENSOR_WIFI & sensor)) { msgb("[%s] PRESENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_WIFI), uat_get_error_str(result)); } if (UA_SENSOR_LIGHT == (UA_SENSOR_LIGHT & sensor)) { msgb("[%s] PRESENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT), uat_get_error_str(result)); } if (UA_SENSOR_MOTION == (UA_SENSOR_MOTION & sensor)) { msgb("[%s] PRESENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), uat_get_error_str(result)); } /* For device information */ if (device_handle) __sensor_presence_detected_device(device_handle); /* For sensor information */ if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION))) __sensor_presence_detected_sensor_info(sensor, sensor_handle); } static void __sensor_absence_detected_cb(int result, ua_monitor_h monitor, ua_sensor_e sensor, ua_sensor_h sensor_handle, void *user_data) { char *pbuf = uat_get_time(); msg("\n[%s] Sensor ABSENCE", pbuf); free(pbuf); if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) { msgp("[%s] ABSENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_BLE), uat_get_error_str(result)); } if (UA_SENSOR_WIFI == (UA_SENSOR_WIFI & sensor)) { msgp("[%s] ABSENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_WIFI), uat_get_error_str(result)); } if (UA_SENSOR_LIGHT == (UA_SENSOR_LIGHT & sensor)) { msgp("[%s] ABSENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT), uat_get_error_str(result)); } if (UA_SENSOR_MOTION == (UA_SENSOR_MOTION & sensor)) { msgp("[%s] ABSENCE detected [%s]", uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), uat_get_error_str(result)); } /* For sensor information */ if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION))) __sensor_presence_detected_sensor_info(sensor, sensor_handle); } void __ua_test_scan_completed_cb(ua_active_scan_type_e result, ua_monitor_h handle, ua_device_h device_handle, void *user_data) { int ret; if (result == UA_ACTIVE_SCAN_TYPE_DEVICE_FOUND && device_handle) { char *mac = NULL; ret = ua_device_get_mac_address(device_handle, &mac); if (UA_ERROR_NONE == ret) { msg(" Found Mac Address : [%s]", mac); g_free(mac); } msg(" - ua_test_scan_completed_cb ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } else msg("SCAN COMPLETED!!"); } static int run_ua_set_detection_cycle(MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int cycle_value = 0; msg("ua_set_detection_cycle"); if (strlen(cycle_time)) cycle_value = (unsigned int)strtol(cycle_time, NULL, 10); ret = ua_service_get_by_name(g_service_str, &g_service_h); if (UA_ERROR_NONE != ret) { msgr(" - ua_service_get_by_name() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } ret = ua_set_detection_cycle(g_service_h, cycle_value); msg(" - ua_set_detection_cycle() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_get_detection_cycle( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int cycle_value = 0; msg("ua_get_detection_cycle"); ret = ua_service_get_by_name(g_service_str, &g_service_h); if (UA_ERROR_NONE != ret) { msgr(" - ua_service_get_by_name() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } ret = ua_get_detection_cycle(g_service_h, &cycle_value); if (UA_ERROR_NONE == ret) { snprintf(cycle_time, sizeof(cycle_time), "%u", cycle_value); } msg(" - ua_get_detection_cycle() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); if (UA_ERROR_NONE == ret) msgb("Detection [cycle_time = %u]", cycle_value); return RET_SUCCESS; } static int run_ua_set_detection_window(MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int window_value = 0; msg("ua_set_detection_window"); if (strlen(window)) window_value = (unsigned int)strtol(window, NULL, 10); ret = ua_set_detection_window(window_value); msg(" - ua_set_detection_window() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_get_detection_window( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int window_value = 0; msg("ua_get_detection_window"); ret = ua_service_get_by_name(g_service_str, &g_service_h); if (UA_ERROR_NONE != ret) { msgr(" - ua_service_get_by_name() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); } ret = ua_get_detection_window(&window_value); msg(" - ua_get_detection_window() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); if (UA_ERROR_NONE == ret) msgb("Detection [window = %u]", window_value); return RET_SUCCESS; } static int run_ua_monitor_set_user_presence_condition( 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_set_user_presence_condition"); 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); msg(" - ua_monitor_set_user_presence_condition() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_set_user_absence_condition( 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_set_user_absence_condition"); 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); msg(" - ua_monitor_set_user_absence_condition() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } 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"); ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; 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 (UA_ERROR_NONE != ret) msgr(" - ua_monitor_set_user_presence_condition() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); if (strlen(g_presence_type)) detection_mode = (unsigned char)strtol(g_presence_type, NULL, 10); ret = ua_monitor_start_presence_detection(g_ua_mon_h, (g_service_str[0] == '\0' ? NULL : g_service_h), detection_mode, __sensor_presence_detected_cb, g_ua_mon_h); msg(" - ua_monitor_start_presence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_stop_presence_detection( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_monitor_stop_presence_detectio"); check_if(NULL == g_ua_mon_h); ret = ua_monitor_stop_presence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_presence_detectio() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_start_absence_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_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); if (UA_ERROR_NONE != ret) msgr(" - ua_monitor_set_user_absence_condition() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); 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); ret = ua_monitor_start_absence_detection(g_ua_mon_h, (g_service_str[0] == '\0' ? NULL : g_service_h), detection_mode, __sensor_absence_detected_cb, g_ua_mon_h); msg(" - ua_monitor_start_absence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_stop_absence_detection( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_monitor_stop_absence_detection"); check_if(NULL == g_ua_mon_h); ret = ua_monitor_stop_absence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_absence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_start_scan_devices( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int scantimemultiplier = 0; msg("ua_monitor_start_scan_devices"); check_if(NULL == g_ua_mon_h); if (strlen(g_scan_time_multiplier)) scantimemultiplier = (unsigned int)strtol(g_scan_time_multiplier, NULL, 10); ret = ua_monitor_start_scan_devices(g_ua_mon_h, scantimemultiplier, __ua_test_scan_completed_cb, NULL); msg(" - ua_monitor_stop_absence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_cancel_scan_devices( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_monitor_cancel_scan_devices,"); check_if(NULL == g_ua_mon_h); ret = ua_monitor_cancel_scan_devices(g_ua_mon_h); msg("ua_monitor_cancel_scan_devices,() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_start_absence_presence( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; msg("run_ua_monitor_start_absence_presence"); check_if(NULL == g_ua_mon_h); if (strlen(g_absence_type)) detection_mode = (unsigned char)strtol((g_absence_type), NULL, 10); ret = ua_monitor_start_absence_detection(g_ua_mon_h, (g_service_str[0] == '\0' ? NULL : g_service_h), detection_mode, __sensor_absence_detected_cb, g_ua_mon_h); msg(" - ua_monitor_start_absence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); if (strlen(g_presence_type)) detection_mode = (unsigned char)strtol(g_presence_type, NULL, 10); ret = ua_monitor_start_presence_detection(g_ua_mon_h, (g_service_str[0] == '\0' ? NULL : g_service_h), detection_mode, __sensor_presence_detected_cb, g_ua_mon_h); msg(" - ua_monitor_start_presence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_monitor_stop_absence_presence( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("run_ua_monitor_stop_absence_presence,"); check_if(NULL == g_ua_mon_h); ret = ua_monitor_stop_absence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_absence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); ret = ua_monitor_stop_presence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_presence_detection() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_enable_low_power_mode( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_enable_low_power_mode"); ret = ua_enable_low_power_mode(); #ifdef SUSPEND_RESUME_TEST if (POWER_ERROR_NONE != device_power_set_state(POWER_STATE_STANDBY, 1)) { msgr("Fail to request power off"); return RET_SUCCESS; } #endif msg(" - ua_enable_low_power_mode() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static int run_ua_disable_low_power_mode( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_disable_low_power_mode"); ret = ua_disable_low_power_mode(); msg(" - ua_disable_low_power_mode() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } #ifdef SUSPEND_RESUME_TEST static int run_device_power_request_poweroff( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; int off_reason = POWER_OFF_REASON_POWER_KEY | POWER_OFF_TO_SUSPEND; msg("run_device_power_request_poweroff"); if (0 != device_power_request_poweroff(off_reason)) { msgr("Fail to request power off"); return false; } ret = device_power_set_wakeup_reason(POWER_WAKEUP_REASON_REMOTE_CONTROLLER); if(POWER_ERROR_NONE != ret) { msgr("Fail to set wakeup reason"); return RET_SUCCESS; } if(POWER_ERROR_NONE != device_power_set_state(POWER_STATE_STANDBY, 1)) { msgr("Failed to request TV to STANDBY!"); return RET_SUCCESS; } msg(" - run_device_power_request_poweroff() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } #endif /* SUSPEND_RESUME_TEST */ static struct menu_data menu_ua_set_detection_cycle[] = { { "1", "service", NULL, NULL, g_service_str }, { "2", "cycle_time", NULL, NULL, cycle_time }, { "3", "run", NULL, run_ua_set_detection_cycle, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_get_detection_cycle[] = { { "1", "service", NULL, NULL, g_service_str }, { "2", "run", NULL, run_ua_get_detection_cycle, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_set_detection_window[] = { { "1", "window", NULL, NULL, window }, { "2", "run", NULL, run_ua_set_detection_window, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_set_presence_condition[] = { { "1", "AND Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", NULL, NULL, g_presence_and_cond }, { "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_presence_conjunction_op }, { "4", "run", NULL, run_ua_monitor_set_user_presence_condition, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_set_absence_condition[] = { { "1", "AND Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", NULL, NULL, g_absence_and_cond }, { "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_absence_conjunction_op }, { "4", "run", NULL, run_ua_monitor_set_user_absence_condition, NULL }, { NULL, NULL, }, }; static struct menu_data menu_start_device_scan[] = { { "1", "Device scan time multiplier", NULL, NULL, g_scan_time_multiplier}, { "2", "run", NULL, run_ua_monitor_start_scan_devices, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_start_presence[] = { { "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", "start", NULL, run_ua_monitor_start_presence_detection, NULL }, { "7", "stop", NULL, run_ua_monitor_stop_presence_detection, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_start_absence[] = { { "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", "start", NULL, run_ua_monitor_start_absence_detection, NULL }, { "7", "stop", NULL, run_ua_monitor_stop_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 }, { NULL, NULL, }, }; struct menu_data menu_ua_detections[] = { { "1", "ua_set_detection_cycle", menu_ua_set_detection_cycle, NULL, NULL}, { "2", "ua_get_detection_cycle", menu_ua_get_detection_cycle, NULL, NULL}, { "3", "ua_set_detection_window", menu_ua_set_detection_window, NULL, NULL}, { "4", "ua_get_detection_window", NULL, run_ua_get_detection_window, NULL}, { "5", "ua_monitor_set_user_presence_condition", menu_ua_set_presence_condition, NULL, NULL }, { "6", "ua_monitor_set_user_absence_condition", menu_ua_set_absence_condition, NULL, NULL }, { "7", "ua_monitor_start/stop_presence_detection", menu_ua_start_presence, NULL, NULL }, { "8", "ua_monitor_start/stop_absence_detection", menu_ua_start_absence, NULL, NULL }, { "9", "start/stop absence/presence simulataneously", menu_start_absence_presence, NULL, NULL }, { "10", "ua_monitor_start_device_scan", menu_start_device_scan, NULL, NULL }, { "11", "ua_monitor_cancel_scan_devices", NULL, run_ua_monitor_cancel_scan_devices, NULL }, { "12", "ua_enable_low_power_mode", NULL, run_ua_enable_low_power_mode, NULL }, { "13", "ua_disable_low_power_mode", NULL, run_ua_disable_low_power_mode, NULL }, { NULL, NULL, }, };