static int run_devices_show(MManager *mm, struct menu_data *menu)
{
char *deviceid = NULL;
- char *name = NULL;
+ char *ip = NULL;
char *devicetype = NULL;
companion_device_h device;
break;
}
companion_device_information_get_device_id(device, &deviceid);
- companion_device_information_get_friendly_name(device, &name);
+ companion_device_information_get_ip(device, &ip);
companion_device_information_get_device_type(device, &devicetype);
- msgb("[%d] deviceid: %s, name: %s type: %s", i+1, deviceid, name, devicetype);
+ msgb("[%d] deviceid: %s, IP: %s type: %s", i+1, deviceid, ip, devicetype);
if (deviceid) {
free(deviceid);
deviceid = NULL;
}
- if (name) {
- free(name);
- name = NULL;
+ if (ip) {
+ free(ip );
+ ip = NULL;
}
if (devicetype) {
free(devicetype);
for (int i = 0; i < count; i++) {
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(devices[i], &ip);
companion_device_information_get_device_type(devices[i], &device_type);
- msgb("device_id : %s, name : %s, type : %s", device_id, friendly_name, device_type);
+ msgb("device_id : %s, name : %s, type : %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
}
for (int i = 0; i < count; i++) {
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(devices[i], &ip);
companion_device_information_get_device_type(devices[i], &device_type);
- msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
}
bool _device_found_cb(companion_device_h device, void *user_data)
{
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(device, &ip);
companion_device_information_get_device_type(device, &device_type);
- msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
if (ret == 0) {
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(device, &ip);
companion_device_information_get_device_type(device, &device_type);
- msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
}
bool _device_found_mine_cb(companion_device_h device, void *user_data)
{
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(device, &ip);
companion_device_information_get_device_type(device, &device_type);
- msgp("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgp("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
{
int ret = 0;
int count = 0;
+ char *deviceid = NULL;
+ char *address = NULL;
companion_device_h device = NULL;
- count = g_list_length(found_device_list);
+ count = g_list_length(my_devices_list);
if (0 >= count ) {
msgr("No Device");
}
for (int i = 0; i < count; i++) {
- device = (companion_device_h)(found_device_list[i].data);
+ device = (companion_device_h)(my_devices_list[i].data);
if (!device)
continue;
- ret = companion_send_data(device, message, _send_data_finish_cb, 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) {
- 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;
bool _mowned_device_found_cb(companion_device_h device, void *user_data)
{
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(device, &ip);
companion_device_information_get_device_type(device, &device_type);
- msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
for (int i = 0; i < count; i++) {
char *device_id = NULL;
- char *friendly_name = NULL;
+ char *ip = 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_ip(devices[i], &ip);
companion_device_information_get_device_type(devices[i], &device_type);
- msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, friendly_name, device_type);
+ msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
if (device_id)
free(device_id);
- if (friendly_name)
- free(friendly_name);
+ if (ip)
+ free(ip);
if (device_type)
free(device_type);
}
bool _device_found_cb(companion_device_h device, void *user_data)
{
char *device_id;
- char *friendly_name;
+ char *ip;
char *device_type;
companion_device_information_get_device_id(device, &device_id);
- companion_device_information_get_friendly_name(device, &friendly_name);
+ companion_device_information_get_ip(device, &ip);
companion_device_information_get_device_type(device, &device_type);
- TC_PRT("found device device_id : %s, friendly_name : %s, device_type : %s", device_id, friendly_name, device_type);
+ TC_PRT("found device device_id : %s, ip : %s, device_type : %s", device_id, ip, device_type);
found_device_list = g_list_prepend(found_device_list, device);
}
for (int i = 0; i < count; i++) {
char *uuid;
- char *friendly_name;
+ char *ip;
char *device_type;
companion_device_information_get_device_id(devices[i], &uuid);
- companion_device_information_get_friendly_name(devices[i], &friendly_name);
+ companion_device_information_get_ip(devices[i], &ip);
companion_device_information_get_device_type(devices[i], &device_type);
- TC_PRT("%d. uuid : %s, friendly_name : %s, device_type : %s", i+1, uuid, friendly_name, device_type);
+ TC_PRT("%d. uuid : %s, ip : %s, device_type : %s", i+1, uuid, ip, device_type);
found_device_list = g_list_prepend(found_device_list, devices[i]);
}
companion_device_h source);
int companion_device_information_destroy(companion_device_h data);
int companion_device_information_get_device_id(companion_device_h device, char **device_id);
-int companion_device_information_get_friendly_name(companion_device_h device, char **friendly_name);
+int companion_device_information_get_ip(companion_device_h device, char **ip);
int companion_device_information_get_device_type(companion_device_h device, char **device_type);
-int companion_send_data(companion_device_h device, char *data, companion_send_data_finish_cb finish_cb, void *user_data);
-
+int companion_send_data(companion_device_h device, char *data, int len,
+ companion_send_data_finish_cb finish_cb, void *user_data);
int companion_create_subgroup(companion_group_h group, companion_device_h device, char *subgroup_name);
int companion_get_subgroups(companion_group_h group, companion_group_h **subgroups, int *count);
int companion_add_device_to_subgroup(companion_group_h subgroup, companion_device_h device);
typedef struct _companion_device_t
{
char *device_id;
- char *friendly_name;
+ char *ip;
char *device_type;
int port;
} companion_device_t;
return group;
}
-static companion_device_t *_create_device_handle(char *device_id, char *friendly_name, char *device_type, int port)
+static companion_device_t *_create_device_handle(char *device_id, char *ip, char *device_type, int port)
{
companion_device_t *device = g_new0(companion_device_t, 1);
device->device_id = g_strdup(device_id);
- device->friendly_name = g_strdup(friendly_name);
+ device->ip = g_strdup(ip);
device->device_type = g_strdup(device_type);
device->port = port;
g_variant_get(va, "aa{sv}", &iter);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
char *device_id;
- char *friendly_name;
+ char *ip;
char *device_type;
int port;
if (g_strcmp0(key, "DeviceID") == 0) {
device_id = (char *)g_variant_get_string(key_value, NULL);
} else if (g_strcmp0(key, "Address") == 0) {
- friendly_name = (char *)g_variant_get_string(key_value, NULL);
+ ip = (char *)g_variant_get_string(key_value, NULL);
} else if (g_strcmp0(key, "SecVer") == 0) {
device_type = (char *)g_variant_get_string(key_value, NULL);
} else if (g_strcmp0(key, "Port") == 0) {
}
g_variant_iter_free(iter_row);
- device = _create_device_handle(device_id, friendly_name, device_type, port);
+ device = _create_device_handle(device_id, ip, device_type, port);
if (device_found_cb.found_cb)
device_found_cb.found_cb(device, device_found_cb.user_data);
}
return ret;
}
-int companion_send_data(companion_device_h device, char *data, companion_send_data_finish_cb finish_cb, void *user_data)
+int companion_send_data(companion_device_h device, char *data, int len,
+ companion_send_data_finish_cb finish_cb, void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+
+ char *buf = NULL;
GError *error = NULL;
companion_device_t *dev = (companion_device_t *)device;
+ buf = g_malloc0(len + 1);
+ if (NULL == buf)
+ return COMP_ERROR_OUT_OF_MEMORY;
+ memcpy(buf, data, len);
+
send_data_finish_cb.finish_cb = finish_cb;
send_data_finish_cb.user_data = user_data;
- group_call_send_data_sync(group_proxy, dev->device_id, dev->friendly_name, dev->port, &ret, NULL, &error);
+ group_call_send_data_sync(group_proxy, dev->device_id, dev->ip, dev->port,
+ buf, len, &ret, NULL, &error);
+
+ free(buf);
+ buf = NULL;
return ret;
}
if (src->device_id) {
dst->device_id = g_strdup(src->device_id);
}
- if (src->friendly_name) {
- dst->friendly_name = g_strdup(src->friendly_name);
+ if (src->ip) {
+ dst->ip = g_strdup(src->ip);
}
if (src->device_type) {
dst->device_type = g_strdup(src->device_type);
g_free(device->device_id);
device->device_id = NULL;
}
- if (device->friendly_name) {
- g_free(device->friendly_name);
- device->friendly_name = NULL;
+ if (device->ip) {
+ g_free(device->ip);
+ device->ip = NULL;
}
if (device->device_type) {
g_free(device->device_type);
return 0;
}
-int companion_device_information_get_friendly_name(companion_device_h device, char **friendly_name)
+int companion_device_information_get_ip(companion_device_h device, char **ip)
{
- *friendly_name = g_strdup(((companion_device_t *)device)->friendly_name);
+ *ip = g_strdup(((companion_device_t *)device)->ip);
return 0;
</method>
<method name="SendData">
<arg type="s" name="uuid" direction="in" />
- <arg type="s" name="data" direction="in"/>
+ <arg type="s" name="addr" direction="in"/>
<arg type="i" name="port" direction="in"/>
+ <arg type="s" name="data" direction="in"/>
+ <arg type="i" name="len" direction="in"/>
<arg type="i" name="result" direction="out" />
</method>
<method name="FindMownedDevices">
MESSAGE("===================================================================")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include/cjson)
FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data);
gboolean group_send_data(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid_dev, gchar *data, int port, gpointer user_data);
+ gchar *uuid_dev, gchar *addr, int port, gchar *data, int len, gpointer user_data);
gboolean group_find_mowned_devices(Group *group,
GDBusMethodInvocation *invocation, gpointer user_data);
char *uri2, char *rt2, char *interface2, int permission2);
int comp_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2);
-int comp_group_send_data(gchar *uuid_dev, gchar *data, int port);
+int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data, int len);
GVariant *comp_group_get_remote_mot_enabled_devices();
int comp_group_get_mot_device_count();
}
gboolean group_send_data(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid_dev, gchar *data, int port, gpointer user_data)
+ gchar *uuid_dev, gchar *addr, int port, gchar *data, int len, gpointer user_data)
{
int ret = 0;
LOG_DEBUG("send data called using dbus successful");
- ret = comp_group_send_data(uuid_dev, data, port);
+ ret = comp_group_send_data(uuid_dev, addr, port, data, len);
group_complete_send_data(group, invocation, 0);
return ret;
}
-int comp_group_send_data(gchar *uuid_dev, gchar *data, int port)
+int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data, int len)
{
int ret;
- data[strlen(data) - 6] = '\0';
-
LOG_BEGIN();
iot_discovery_t *iot = g_new0(iot_discovery_t, 1);
iot->uuid = g_strdup(uuid_dev);
- iot->host = g_strdup_printf("coap://[%s]:%d", data, port);
- iot->data = g_strdup("Hello");
+ iot->host = g_strdup_printf("coap://[%s]:%d", addr, port);
+ iot->data = g_malloc0(len);
+ if (NULL == iot->data) {
+ ret = COMP_ERROR_OUT_OF_MEMORY;
+ LOG_ERR("Send Data Fail to uuid = %s host %s error=%s",
+ iot->uuid, iot->host, comp_log_get_error_string(ret));
+ return ret;
+ }
+ memcpy(iot->data, data, len);
LOG_DEBUG("UUID %s host %s", iot->uuid, iot->host);
- ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 20, iot);
+ ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 1, iot);
if (ret != COMP_ERROR_NONE) {
- LOG_ERR("Failed to discover resource : %s",
- comp_log_get_error_string(ret));
+ LOG_ERR("Failed to discover resource : %s", comp_log_get_error_string(ret));
}
LOG_END();
- return COMP_ERROR_NONE;
-
- LOG_END();
-
return ret;
}
LOG_ERR("Failed to discover resource : %s",
comp_log_get_error_string(ret));
}
+
+ return ret;
}
int comp_group_delete_subgroup(char *subgroup_name)
{
-
+ return COMP_ERROR_NONE;
}
#include <tzplatform_config.h>
+#include <iotivity_config.h>
+#include <platform_features.h>
+#include <utlist.h>
+#include <srmutility.h>
#include <ocprovisioningmanager.h>
#include <comp_iot.h>
/*
"operation" resource
The operation resource is a control command channel between daemon and daemon.
- resource type is core.comp.operation
- Within this function we create a default operation resource. (uri is /comp/operation/1)
- If we need more control channels, increase the number.
+ resource type is core.comp.operation
+ Within this function we create a default operation resource. (uri is /comp/operation/1)
+ If we need more control channels, increase the number.
ex) /comp/operation/2, /comp/operation/3
*/
comp_iot_add_resource(COMP_RESOURCE_TYPE_OPERATION, "1");
if (strncmp(key, "UUID", 4) == 0) {
LOG_DEBUG("Insert in %s, UUID : %s", group_name, value);
- comp_group_add_device_in_group(group_name, value);
+ comp_group_add_device_in_group(group_name, (char *)value);
}
return IOTCON_FUNC_CONTINUE;
}
}
+
+ return IOTCON_FUNC_CONTINUE;
}
static gboolean _timeout_cb(gpointer data)
LOG_DEBUG("Set Resource Type : %s", get_error_message(ret));
- if (timeout == 20)
+ if (timeout == 1)
ret = iotcon_find_resource(iot->host,
IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
query, _found_resource, user_data);
</method>
<method name="SendData">
<arg type="s" name="uuid" direction="in" />
- <arg type="s" name="data" direction="in"/>
+ <arg type="s" name="addr" direction="in"/>
<arg type="i" name="port" direction="in"/>
+ <arg type="s" name="data" direction="in"/>
+ <arg type="i" name="len" direction="in"/>
<arg type="i" name="result" direction="out" />
</method>
<method name="FindMownedDevices">