return ret;
}
-int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data, int len)
+int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data,
+ int len)
{
int ret;
char ip[50];
if (percent)
percent[0] = '\0';
- iot_discovery_t *iot = g_new0(iot_discovery_t, 1);
- iot->uuid = g_strdup(uuid_dev);
+ comp_command_t *cmd = g_new0(comp_command_t, 1);
+ cmd->command = g_strdup("3");
+ cmd->uuid = g_strdup(uuid_dev);
- if (strchr(ip, ':'))
- iot->host = g_strdup_printf("coap://[%s]:%d", ip, port);
- else
- iot->host = g_strdup_printf("coap://%s:%d", ip, port);
+ if (strchr(ip, ':')) /* IPv6 Adress */
+ cmd->host = g_strdup_printf("coap://[%s]:%d", ip, port);
+ else /* IPv4 Address */
+ cmd->host = g_strdup_printf("coap://%s:%d", ip, port);
- iot->data = g_malloc0(len);
- if (NULL == iot->data) {
+ cmd->arg1 = g_malloc0(len);
+ if (NULL == cmd->arg1) {
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));
+ cmd->uuid, cmd->host, comp_log_get_error_string(ret));
return ret;
}
- memcpy(iot->data, data, len);
+ memcpy(cmd->arg1, data, len);
- LOG_DEBUG("UUID %s host %s", iot->uuid, iot->host);
+ LOG_DEBUG("UUID %s host %s", cmd->uuid, cmd->host);
- ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 1, iot);
+ ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 5, cmd);
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();
iotcon_query_add(query, "CMD", cmd->command);
iotcon_query_add(query, "name", cmd->arg1);
iotcon_query_add(query, "id", cmd->arg2);
+ } else if (strcmp(cmd->command, "3") == 0) {
+ LOG_DEBUG("CMD : %s, UUID : %s", cmd->command, cmd->uuid);
+ iotcon_query_add(query, "CMD", cmd->command);
+ iotcon_query_add(query, "data", cmd->arg1);
}
ret = iotcon_remote_resource_get(resource_clone, query, _on_get, NULL);
{
int ret;
iotcon_query_h query;
- iot_discovery_t *iot = user_data;
+ comp_command_t *cmd = user_data;
found_device_count = 0;
LOG_DEBUG("Set Resource Type : %s", get_error_message(ret));
- if (timeout == 1)
- ret = iotcon_find_resource(iot->host,
+ if (cmd && (g_strcmp0(cmd->command, "3") == 0))
+ ret = iotcon_find_resource(cmd->host,
IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
query, _found_resource, user_data);
else