static char device_idx[MENU_DATA_SIZE + 1] = "1";
static char pin[MENU_DATA_SIZE + 1] = "12341234";
static char message[MENU_DATA_SIZE + 1] = "Hello World!!";
+static char monitor[MENU_DATA_SIZE + 1] = "1";
static int run_group_find(MManager *mm, struct menu_data *menu);
static int run_devices_find(MManager *mm, struct menu_data *menu);
return RET_SUCCESS;
}
+static void device_monitor_result(char *uuid, char *group_name,
+ companion_device_status_e status, void *user_data)
+{
+ msgp("device monitor result uuid %s group_name %s status %s", uuid,
+ group_name, status == COMPANION_DEVICE_ADDED ? "ADDED" : "REMOVED");
+}
+
+static int run_start_device_monitor(MManager *mm, struct menu_data *menu)
+{
+ int ret;
+
+ if (g_strcmp0(monitor, "1") == 0) {
+ msg(" - Start device monitor");
+ ret = companion_device_monitor_start(handle, device_monitor_result,
+ NULL);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Start Monitor: [%s(0x%X)]",
+ comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ } else {
+ msg(" - Stop device monitor");
+ ret = companion_device_monitor_stop(handle);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Stop Monitor: [%s(0x%X)]",
+ comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ }
+ return RET_SUCCESS;
+}
+
static struct menu_data menu_group_create[] = {
{ "0", "Group Name", NULL, NULL, groupid },
{ NULL, NULL, },
};
+static struct menu_data menu_monitor[] = {
+ { "1", "Input 1 to Start and 2 to Stop Monitor", NULL, NULL, monitor },
+ { "2", "Start/Stop Device Monitor", NULL, run_start_device_monitor, NULL },
+ { NULL, NULL, },
+};
+
struct menu_data menu_comp_manager[] = {
{ "0", "Show My Device ID", NULL, run_get_my_id, NULL },
{ "1", "Show My Device", NULL, run_device_show_my_device, NULL },
{ "17", "Request Eject", menu_request_eject, NULL, NULL },
{ "18", "Request Delete Group (Not yet developed)", menu_request_delete_group,
NULL, NULL },
+ { "19", "Start/Stop Device Monitor", menu_monitor, NULL, NULL },
{ NULL, NULL, },
};