#include <user-awareness.h>
#include <user-awareness-log.h>
#include <user-awareness-private.h>
+#include <user-awareness-internal.h>
#include <user-awareness-util.h>
#define UA_MONITORING_TIME 60 /* Default: 60 seconds for scanning for device */
case UA_SENSOR_AUDIO:
bitmask = UAM_SENSOR_BITMASK_AUDIO;
break;
+ case UA_SENSOR_ALL:
+ bitmask = UAM_SENSOR_ALL;
+ break;
default:
UA_WARN("Unsupported sensor [%d]", sensor_type);
bitmask = 0x00;
return UA_ERROR_NONE;
}
-int ua_enable_low_power_mode(unsigned int sensors)
+int ua_enable_low_power_mode(void)
{
FUNC_ENTRY;
int ret;
- ret = _ua_get_error_code(_uam_enable_low_power_mode(sensors));
+ ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, true));
if (UA_ERROR_NONE != ret) {
- UA_ERR("_uam_enable_low_power_mode failed");
+ /* LCOV_EXCL_START */
+ UA_ERR("_uam_set_low_power_mode failed");
return ret;
+ /* LCOV_EXCL_STOP */
}
FUNC_EXIT;
return UA_ERROR_NONE;
}
+int ua_disable_low_power_mode(void)
+{
+ FUNC_ENTRY;
+ int ret;
+
+ ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, false));
+ if (UA_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
+ UA_ERR("_uam_set_low_power_mode failed");
+ return ret;
+ /* LCOV_EXCL_STOP */
+ }
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
-int ua_disable_low_power_mode(unsigned int sensors)
+int ua_set_low_power_mode(unsigned int bitmask, bool on_off)
{
FUNC_ENTRY;
int ret;
- ret = _ua_get_error_code(_uam_disable_low_power_mode(sensors));
+ ret = _ua_get_error_code(_uam_set_low_power_mode(bitmask, on_off));
if (UA_ERROR_NONE != ret) {
- UA_ERR("_uam_disable_low_power_mode failed");
+ /* LCOV_EXCL_START */
+ UA_ERR("_uam_set_low_power_mode failed");
return ret;
+ /* LCOV_EXCL_STOP */
}
FUNC_EXIT;
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_lpm_enable_sensors[MENU_DATA_SIZE + 1] = {"30",}; /**< Low Power Mode enable sensors */
-static char g_lpm_disable_sensors[MENU_DATA_SIZE + 1] = {"30",}; /**< Low Power Mode disable sensors */
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 char g_lpm_sensor[MENU_DATA_SIZE + 1] = "2"; /**< Sensor to set LPM */
+static char g_lpm_onoff[MENU_DATA_SIZE + 1] = "1"; /**< LPM mode on/off */
+
static void __sensor_presence_detected_device(ua_device_h device_handle)
{
int ret;
MManager *mm, struct menu_data *menu)
{
int ret = UA_ERROR_NONE;
- unsigned int lpm_enable_sensors = 0;
- if (strlen(g_lpm_enable_sensors))
- lpm_enable_sensors = (unsigned int)strtol(g_lpm_enable_sensors, NULL, 10);
msg("ua_enable_low_power_mode");
- ret = ua_enable_low_power_mode(lpm_enable_sensors);
+ ret = ua_enable_low_power_mode();
msg(" - ua_enable_low_power_mode() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
MManager *mm, struct menu_data *menu)
{
int ret = UA_ERROR_NONE;
- unsigned int lpm_disable_sensors = 0;
-
- if (strlen(g_lpm_disable_sensors))
- lpm_disable_sensors = (unsigned int)strtol(g_lpm_disable_sensors, NULL, 10);
msg("ua_disable_low_power_mode");
- ret = ua_disable_low_power_mode(lpm_disable_sensors);
+ 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;
}
+
+static int run_ua_set_low_power_mode(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ ua_sensor_e sensor = UA_SENSOR_ALL;
+ int onoff = 0;
+
+ if (strlen(g_lpm_sensor))
+ sensor = (unsigned char)strtol((g_lpm_sensor), NULL, 10);
+
+ if (strlen(g_lpm_onoff))
+ onoff = (unsigned char)strtol((g_lpm_onoff), NULL, 10);
+
+ msg("run_ua_set_low_power_mode bitmask [%x]", sensor);
+
+ ret =ua_set_low_power_mode(sensor, onoff == 1 ? true : false);
+
+ msg(" - run_ua_set_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)
{ NULL, NULL, },
};
-static struct menu_data menu_ua_enable_low_power_mode[] = {
- { "1", "Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
- NULL, NULL, g_lpm_enable_sensors },
- { "2", "run", NULL,
- run_ua_enable_low_power_mode, NULL },
- { NULL, NULL, },
-};
-
-static struct menu_data menu_ua_disable_low_power_mode[] = {
- { "1", "Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
- NULL, NULL, g_lpm_disable_sensors },
- { "2", "run", NULL,
- run_ua_disable_low_power_mode, 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 },
{ NULL, NULL, },
};
+static struct menu_data menu_set_low_power_mode[] = {
+ { "1", "(1 BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)",
+ NULL, NULL, g_lpm_sensor },
+ { "2", "(0:OFF 1:ON)",
+ NULL, NULL, g_lpm_onoff },
+ { "3", "ua_set_low_power_mode",
+ NULL, run_ua_set_low_power_mode, NULL },
+ { NULL, NULL, },
+};
+
struct menu_data menu_ua_detections[] = {
{ "1", "ua_set_detection_cycle",
menu_ua_set_detection_cycle, NULL, NULL},
NULL, run_ua_monitor_cancel_scan_devices, NULL },
{ "12", "ua_enable_low_power_mode",
- menu_ua_enable_low_power_mode, NULL, NULL },
+ NULL, run_ua_enable_low_power_mode, NULL },
{ "13", "ua_disable_low_power_mode",
- menu_ua_disable_low_power_mode, NULL, NULL },
+ NULL, run_ua_disable_low_power_mode, NULL },
+ { "14", "ua_set_low_power_mode",
+ menu_set_low_power_mode, NULL, NULL },
#ifdef SUSPEND_RESUME_TEST
- { "14", "request_power_off",
+ { "15", "request_power_off",
NULL, run_device_power_request_poweroff, NULL },
#endif
{ NULL, NULL, },