GList *found_group_list;
GList *found_device_list;
GList *invited_device_list;
+GList *found_channel_list;
static char groupid[MENU_DATA_SIZE + 1] = "mygroup";
static char request_groupid[MENU_DATA_SIZE + 1] = "subgroup";
static char timeout[MENU_DATA_SIZE + 1] = "2";
static char group_idx[MENU_DATA_SIZE + 1] = "1";
static char device_idx[MENU_DATA_SIZE + 1] = "1";
+static char channel_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 channel_id[MENU_DATA_SIZE + 1] = "Channel1";
return RET_SUCCESS;
}
+typedef struct _channel_t {
+ char *device_id; /**< User callback to be called */
+ char *channel_id; /**< User data pointer */
+} channel_t;
+
+static int run_channels_show(MManager *mm, struct menu_data *menu)
+{
+ channel_t *channel;
+
+ int i;
+ GList *iter = NULL;
+
+ /* Get a first item */
+ i = 0;
+ iter = g_list_first(found_channel_list);
+ while (NULL != iter) {
+ channel = iter->data;
+ if (!channel) {
+ msgr("channel is null");
+ break;
+ }
+
+ msgp("[%d] device id : %s, channel id : %s,", i+1, channel->device_id, channel->channel_id);
+
+ /* Next item */
+ iter = g_list_next(iter);
+ i++;
+ }
+
+ return RET_SUCCESS;
+}
+
#if 0
static int run_group_get_members(MManager *mm, struct menu_data *menu)
{
msgb("\rFind Send Data Finished = %d", result);
}
-static int __send_data(int idx)
+static int __send_data(int devidx, int chaidx)
{
int ret = 0;
char *deviceid = NULL;
char *address = NULL;
mdg_device_h device = NULL;
-
+ channel_t *channel = NULL;
if (found_device_list) {
- device = g_list_nth_data(found_device_list, idx - 1);
+ device = g_list_nth_data(found_device_list, devidx - 1);
if (NULL == device) {
msgr("Find local device first");
return RET_FAILURE;
}
}
+ if (found_channel_list) {
+ channel = g_list_nth_data(found_channel_list, chaidx - 1);
+ if (NULL == channel) {
+ msgr("Find local device first");
+ return RET_FAILURE;
+ }
+ }
+
mdg_device_info_get_device_id(device, &deviceid);
mdg_device_info_get_addr(device, &address);
- msgp("Sent to [ID] %s [ADDR] %s", deviceid, address);
+ msgp("Sent to [ID] %s [ADDR] %s [CHANNEL ID] %s", deviceid, address, channel->channel_id);
if (deviceid) {
free(deviceid);
deviceid = NULL;
address = NULL;
}
- ret = mdg_device_send_data(handle, device, channel_id, (unsigned char *)message,
+ ret = mdg_device_send_data(handle, device, channel->channel_id, (unsigned char *)message,
strlen(message), _send_data_finish_cb, NULL);
if (MDG_ERROR_NONE != ret)
msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address);
static int run_send_data(MManager *mm, struct menu_data *menu)
{
- int idx = 0;
+ int devidx = 0;
+ int chaidx = 0;
int count = g_list_length(found_device_list);
if (0 >= count) {
}
if (strlen(device_idx)) {
- idx = (unsigned short)strtol(device_idx, NULL, 10);
- if (0 >= idx) {
+ devidx = (unsigned short)strtol(device_idx, NULL, 10);
+ if (0 >= devidx) {
msgp("Invalid index. set to 1");
- idx = 1;
+ devidx = 1;
}
}
- return __send_data(idx);
+ if (strlen(channel_idx)) {
+ chaidx = (unsigned short)strtol(channel_idx, NULL, 10);
+ if (0 >= chaidx) {
+ msgp("Invalid index. set to 1");
+ chaidx = 1;
+ }
+ }
+ return __send_data(devidx, chaidx);
}
void _invited_device_finish_cb(int result, void *user_data)
return RET_SUCCESS;
}
+void __req_channel_list_finish_cb(char *device_id, char *channel_id, void *user_data)
+{
+ msgp("\rDevice ID : [%s], Channel ID : [%s]", device_id, channel_id);
+
+ channel_t *channel = g_new0(channel_t, 1);
+ channel->device_id = g_strdup(device_id);
+ channel->channel_id = g_strdup(channel_id);
+
+ found_channel_list = g_list_append(found_channel_list, channel);
+
+ return;
+}
+
static int run_request_channel_list(MManager *mm, struct menu_data *menu)
{
int ret = 0;
}
}
- ret = mdg_request_channel_list(handle, device, receive_request_result, NULL);
+ ret = mdg_request_channel_list(handle, device, __req_channel_list_finish_cb, NULL);
if (MDG_ERROR_NONE != ret) {
msgr("Failed to Request Eject: [%s(0x%X)]", mdg_error_to_string(ret), ret);
return RET_FAILURE;
static struct menu_data menu_send_data[] = {
{ "0", "Show My Owned Device(s)", NULL, run_invited_devices_show, NULL },
- { "1", "Message", NULL, NULL, message },
- { "2", "Channel Name", NULL, NULL, channel_id },
+ { "1", "Show Channel List", NULL, run_channels_show, NULL },
+ { "2", "Message", NULL, NULL, message },
{ "3", "Device Index", NULL, NULL, device_idx },
- { "4", "Send", NULL, run_send_data, NULL },
+ { "4", "Channel Index", NULL, NULL, channel_idx },
+ { "5", "Send", NULL, run_send_data, NULL },
{ NULL, NULL, },
};