GList *found_group_list;
GList *found_device_list;
+GList *my_devices_list;
static char groupid[MENU_DATA_SIZE + 1] = "mygroup";
static char timeout[MENU_DATA_SIZE + 1] = "5";
static char pin[MENU_DATA_SIZE + 1] = "11223344";
static char message[MENU_DATA_SIZE + 1] = "Hello World!!";
+int run_get_my_id(MManager *mm, struct menu_data *menu)
+{
+ msg("");
+#if 0
+ ret = companion_device_my_deviceid(&devices, &count);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Get My Device ID: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_my_deviceid() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+#endif
+ return RET_SUCCESS;
+}
+
void _device_eject_result_cb(int result, void *user_data)
{
msg("Eject Device Complete [%s]", comp_error_to_string(result) );
return RET_SUCCESS;
}
+int run_device_get_found_mine(MManager *mm, struct menu_data *menu)
+{
+ int ret = 0;
+ int count = 0;
+ companion_device_h *devices = NULL;
+
+ msg("");
+#if 0
+ ret = companion_device_get_found_my_devices(&devices, &count);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Get Found My Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_get_found_my_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+#endif
+ for (int i = 0; i < count; i++) {
+ char *device_id = NULL;
+ char *friendly_name = NULL;
+ char *device_type = NULL;
+
+ companion_device_information_get_device_id(devices[i], &device_id);
+ companion_device_information_get_friendly_name(devices[i], &friendly_name);
+ companion_device_information_get_device_type(devices[i], &device_type);
+
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+
+ if (device_id)
+ free(device_id);
+ if (friendly_name)
+ free(friendly_name);
+ if (device_type)
+ free(device_type);
+ }
+
+ return RET_SUCCESS;
+}
+
+
+bool _device_found_mine_cb(companion_device_h device, void *user_data)
+{
+ char *device_id = NULL;
+ char *friendly_name = NULL;
+ char *device_type = NULL;
+
+ companion_device_information_get_device_id(device, &device_id);
+ companion_device_information_get_friendly_name(device, &friendly_name);
+ companion_device_information_get_device_type(device, &device_type);
+
+ msgp("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+
+ if (device_id)
+ free(device_id);
+ if (friendly_name)
+ free(friendly_name);
+ if (device_type)
+ free(device_type);
+
+ my_devices_list = g_list_prepend(my_devices_list, device);
+
+ return TRUE;
+}
+
+static int run_devices_find_mine(MManager *mm, struct menu_data *menu)
+{
+ int ret;
+ int duration;
+ msg("Find Devices");
+
+ if (strlen(timeout))
+ duration = (unsigned short)strtol(timeout, NULL, 10);
+#if 0
+ ret = companion_device_find_mine(duration, _device_found_mine_cb, _device_finish_cb, NULL);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Find My Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_find_mine() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+#endif
+ if (my_devices_list) {
+ g_list_free_full(my_devices_list, _destroy_comp_device_info);
+ my_devices_list = NULL;
+ }
+
+ return RET_SUCCESS;
+}
+
+
static void _group_leave_finish_cb(int result, void *user_data)
{
msgb("leave operation finished");
{ NULL, NULL, },
};
+static struct menu_data menu_my_devices_find[] = {
+ { "0", "Timeout", NULL, NULL, timeout },
+ { "1", "Run", NULL, run_devices_find_mine, NULL },
+ { NULL, NULL, },
+};
+
static struct menu_data menu_send_data[] = {
{ "0", "Message", NULL, NULL, message },
{ "1", "Send (Broadcast)", NULL, run_send_data, NULL },
};
struct menu_data menu_comp_manager[] = {
+ { "0", "Get My Device ID", NULL, run_get_my_id, NULL },
{ "1", "Group Create", menu_group_create, NULL, NULL },
{ "2", "Find Groups", menu_group_find, NULL, NULL },
{ "3", "Get Found Groups", NULL, run_group_get_found , NULL },
{ "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", "Find My Devices", menu_my_devices_find, NULL, NULL },
+ { "14", "Get Found My Devices", NULL, run_device_get_found_mine, NULL },
{ "13", "Send Message", menu_send_data, NULL, NULL },
{ NULL, NULL, },
};