#include <fn_iot.h>
#include <fn_group.h>
-int fn_iot_initialize()
+static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
+ void *user_data)
{
- int ret = iotcon_initialize(SVR_PATH);
- LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret));
+ int ret;
+ char *device_id = NULL;
+
+ LOG_DEBUG("device info found");
+
+ ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_ID, &device_id);
+ if (IOTCON_ERROR_NONE != ret) {
+ return false;
+ }
+
+ LOG_DEBUG("device_id : %s", device_id);
fn_context_t *fn_ctx = fn_context_get_context();
+ fn_ctx->device_uuid = g_strdup(device_id);
/*
"Group device" resource
*/
fn_iot_add_resource(FN_RESOURCE_TYPE_GROUP_DEVICE, fn_ctx->device_uuid);
+ return false;
+}
+
+int fn_iot_initialize()
+{
+ int ret = iotcon_initialize(SVR_PATH);
+ LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret));
+
+ ret = iotcon_find_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
+ NULL, _request_device_info, NULL);
+
/*
"operation" resource
The operation resource is a control command channel between daemon and daemon.
char *resource_device_name;
char *resource_host;
char *resource_type;
+ fn_group_type_e group_type;
LOG_DEBUG("Resource Found");
return IOTCON_FUNC_CONTINUE;
}
+ fn_context_t *fn_ctx = fn_context_get_context();
+ if (strcmp(resource_device_id, fn_ctx->device_uuid) == 0)
+ group_type = FN_GROUP_DEVICE;
+ else
+ group_type = FN_GROUP_REMOTE_DEVICE;
+
fn_group_add_new(resource_uri_path, resource_device_id,
- resource_device_name, resource_host, resource_type, FN_GROUP_REMOTE_DEVICE);
+ resource_device_name, resource_host, resource_type, group_type);
found_device_count++;
g_free(resource_type);