if (ret == 0 && arg != NULL)
msgb("Deleted Group name is %s", arg);
} else {
- msgb("[DATA] %s", arg);
+ msgb("[Recv] %s", arg);
}
}
}
}
}
-static int run_send_data(MManager *mm, struct menu_data *menu)
+static int __send_data(int idx)
{
int ret = 0;
int count = 0;
return RET_SUCCESS;
}
- for (int i = 0; i < count; i++) {
- device = (companion_device_h)(my_devices_list[i].data);
- if (!device)
- continue;
+ device = (companion_device_h)(my_devices_list[idx-1].data);
+ if (!device) {
+ msgr("Find my device first");
+ }
+ companion_device_information_get_device_id(device, &deviceid);
+ companion_device_information_get_ip(device, &address);
+ msgb("Send Data: [ID] %s [IP] %s", deviceid, address);
+ if (deviceid) {
+ free(deviceid);
+ deviceid= NULL;
+ }
+ if (address) {
+ free(address);
+ address= NULL;
+ }
- companion_device_information_get_device_id(device, &deviceid);
- companion_device_information_get_ip(device, &address);
- msgb("Send Data: [ID] %s [IP] %s", deviceid, address);
- if (deviceid) {
- free(deviceid);
- deviceid= NULL;
- }
- if (address) {
- free(address);
- address= NULL;
- }
+ ret = companion_send_data(device, message, strlen(message), _send_data_finish_cb, NULL);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address);
+ }
- ret = companion_send_data(device, message, strlen(message), _send_data_finish_cb, NULL);
- if (COMP_ERROR_NONE != ret) {
- msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address);
+ return ret;
+}
+
+static int run_send_data(MManager *mm, struct menu_data *menu)
+{
+ int idx = 0;
+
+ if (strlen(device_idx)) {
+ idx = (unsigned short)strtol(device_idx, NULL, 10);
+ if (0 >= idx) {
+ msgp("Invalid index. set to 1");
+ idx = 1;
}
}
+ return __send_data(idx);
+}
+
+static int run_send_data_all(MManager *mm, struct menu_data *menu)
+{
+ int ret = 0;
+ int count = 0;
+
+ count = g_list_length(my_devices_list);
+
+ if (0 >= count ) {
+ msgr("No Device");
+ return RET_SUCCESS;
+ }
+
+ for (int i = 1; i <= count; i++)
+ __send_data(i);
+
return RET_SUCCESS;
}
};
static struct menu_data menu_send_data[] = {
- { "0", "Message", NULL, NULL, message },
- { "1", "Send (Broadcast)", NULL, run_send_data, NULL },
+ { "0", "Show My Owned Device(s)", NULL, run_device_show_mowned_device, NULL },
+ { "1", "Message", NULL, NULL, message },
+ { "2", "Device Index", NULL, NULL, device_idx },
+ { "3", "Send (Unicast)", NULL, run_send_data, NULL },
+ { "4", "Send (Broadcast)", NULL, run_send_data_all, NULL },
{ NULL, NULL, },
};
{ "2", "Run", NULL, run_request_delete_group, NULL },
{ NULL, NULL, },
};
+
struct menu_data menu_comp_manager[] = {
{ "0", "Show My Device ID", NULL, run_get_my_id, NULL },
{ "1", "Create Group", menu_group_create, NULL, NULL },
int companion_request_invite(companion_group_h group, companion_device_h device, char *PIN)
{
int ret = 0;
- GError *error = NULL;
+
companion_group_t *grp = (companion_group_t *)group;
companion_device_t *dev = (companion_device_t *)device;
_ERR("%s", grp->group_name);
_ERR("%s", dev->device_id);
- group_call_request_invite(group_proxy, grp->device_id, grp->group_name, dev->device_id, PIN, &ret, NULL, &error);
+ group_call_request_invite(group_proxy, grp->device_id, grp->group_name, dev->device_id, PIN,
+ NULL, NULL, NULL);
return ret;
}
_ERR("%s", grp->group_name);
_ERR("%s", dev->device_id);
- group_call_request_eject(group_proxy, grp->device_id, grp->group_name, dev->device_id, &ret, NULL, &error);
+ group_call_request_eject(group_proxy, grp->device_id, grp->group_name, dev->device_id,
+ NULL, NULL, NULL);
return ret;
}
int companion_request_delete_group(companion_group_h group)
{
-
+ int ret = 0;
+ return ret;
}
int companion_request_result_callback(companion_request_result_cb result_cb, void *user_data)
{
+ int ret = 0;
+
request_result_cb.result_cb = result_cb;
request_result_cb.user_data = user_data;
+
+ return ret;
}
#include <iotivity_config.h>
#include <platform_features.h>
#include <ocprovisioningmanager.h>
+#include <doxmresource.h>
#include <comp_iot.h>
#include <comp_group.h>
LOG_ERR("iotcon_set_timeout: Failed %s", get_error_message(ret));
}
- if (cmd && (cmd->command == COMP_REQ_CREATE_GROUP ||
- cmd->command == COMP_REQ_SEND_DATA))
- ret = iotcon_find_resource(cmd->host,
+ if (cmd && (cmd->command == COMP_REQ_SEND_DATA_ALL))
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
query, _found_resource, user_data);
else
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
+ ret = iotcon_find_resource(cmd->host,
IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
query, _found_resource, user_data);