From: saerome.kim Date: Wed, 17 Jan 2018 13:00:36 +0000 (+0900) Subject: demo: add send data feature X-Git-Tag: submit/tizen/20190131.065036~198 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=759cf5d069d40e3639161596ea4222798fd4837e;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git demo: add send data feature Signed-off-by: saerome.kim --- diff --git a/capi/demo/comp-manager.c b/capi/demo/comp-manager.c index 3a2f339..597b17a 100644 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -37,6 +37,7 @@ static char group_idx_a[MENU_DATA_SIZE + 1] = "1"; 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] = "11223344"; +static char message[MENU_DATA_SIZE + 1] = "Hello World!!"; void _device_invite_result_cb(int result, void *user_data) { @@ -584,15 +585,50 @@ static int run_group_create(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } +static int run_send_data(MManager *mm, struct menu_data *menu) +{ + int ret = 0; + int count = 0; + companion_device_h device = NULL; + + count = g_list_length(found_device_list); + + if (0 >= count ) { + msgr("No Device"); + return RET_SUCCESS; + } + + for (int i = 0; i < count; i++) { + device = (companion_device_h)(found_device_list[i].data); + ret = companion_send_data(device, message); + if (COMP_ERROR_NONE != ret) { + char *deviceid = NULL; + char *address = NULL; + companion_device_information_get_device_id(device, &deviceid); + companion_device_information_get_device_id(device, &address); + msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address); + if (deviceid) { + free(deviceid); + deviceid= NULL; + } + if (address) { + free(address); + address= NULL; + } + } + } + return RET_SUCCESS; +} + static struct menu_data menu_group_create[] = { { "0", "Group Name", NULL, NULL, groupid }, - { "2", "Run", NULL, run_group_create, NULL }, + { "1", "Run", NULL, run_group_create, NULL }, { NULL, NULL, }, }; static struct menu_data menu_group_find[] = { { "0", "Timeout", NULL, NULL, timeout }, - { "2", "Run", NULL, run_group_find, NULL }, + { "1", "Run", NULL, run_group_find, NULL }, { NULL, NULL, }, }; @@ -654,6 +690,12 @@ static struct menu_data menu_group_eject_device[] = { { NULL, NULL, }, }; +static struct menu_data menu_send_data[] = { + { "0", "Message", NULL, NULL, message }, + { "1", "Send (Broadcast)", NULL, run_send_data, NULL }, + { NULL, NULL, }, +}; + struct menu_data menu_comp_manager[] = { { "1", "Group Create", menu_group_create, NULL, NULL }, { "2", "Find Groups", menu_group_find, NULL, NULL }, @@ -667,5 +709,6 @@ struct menu_data menu_comp_manager[] = { { "10", "Get Found Devices", NULL, run_device_get_found, NULL }, { "11", "Invite Device", menu_group_invite_device, NULL, NULL }, { "12", "Eject Device", menu_group_eject_device, NULL, NULL }, + { "13", "Send Message", menu_send_data, NULL, NULL }, { NULL, NULL, }, };