From: Saurav Babu Date: Fri, 20 Apr 2018 04:52:02 +0000 (+0530) Subject: demo: Added test code for device monitoring X-Git-Tag: submit/tizen/20190131.065036~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f309fa1f5eb473e55e277d68181525c2aba25f7;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git demo: Added test code for device monitoring Signed-off-by: Saurav Babu --- diff --git a/capi/demo/comp-manager.c b/capi/demo/comp-manager.c index 9e103e5..64798a2 100755 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -41,6 +41,7 @@ static char group_idx_b[MENU_DATA_SIZE + 1] = "2"; 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); @@ -1189,6 +1190,38 @@ static int run_request_delete_group(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 }, @@ -1305,6 +1338,12 @@ static struct menu_data menu_request_delete_group[] = { { 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 }, @@ -1326,5 +1365,6 @@ struct menu_data menu_comp_manager[] = { { "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, }, };