--- /dev/null
+{\r
+ "cred":{\r
+ "creds": [\r
+ {\r
+ "credid": 1,\r
+ "subjectuuid": "*",\r
+ "credtype": 16,\r
+ "privatedata": {\r
+ "encoding": "oic.sec.encoding.raw",\r
+ "data": "12341234"\r
+ }\r
+ }\r
+ ],\r
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+ },\r
+ "acl": {\r
+ "aclist": {\r
+ "aces": [\r
+ {\r
+ "subjectuuid": "*",\r
+ "resources": [\r
+ {\r
+ "href": "/oic/res",\r
+ "rel": "",\r
+ "rt": ["oic.wk.res"],\r
+ "if": ["oic.if.ll"]\r
+ },{\r
+ "href": "/oic/d",\r
+ "rel": "",\r
+ "rt": ["oic.wk.d"],\r
+ "if": ["oic.if.baseline", "oic.if.r"]\r
+ },{\r
+ "href": "/oic/p",\r
+ "rel": "",\r
+ "rt": ["oic.wk.p"],\r
+ "if": ["oic.if.baseline", "oic.if.r"]\r
+ }\r
+ ],\r
+ "permission": 2\r
+ },\r
+ {\r
+ "subjectuuid": "*",\r
+ "resources": [\r
+ {\r
+ "href": "/oic/sec/doxm",\r
+ "rel": "",\r
+ "rt": ["oic.r.doxm"],\r
+ "if": ["oic.if.baseline"]\r
+ },\r
+ {\r
+ "href": "/oic/sec/pstat",\r
+ "rel": "",\r
+ "rt": ["oic.r.pstat"],\r
+ "if": ["oic.if.baseline"]\r
+ },\r
+ {\r
+ "href": "/oic/sec/cred",\r
+ "rel": "",\r
+ "rt": ["oic.r.cred"],\r
+ "if": ["oic.if.baseline"]\r
+ }\r
+ ],\r
+ "permission": 6\r
+ }, \r
+ {\r
+ "subjectuuid": "*",\r
+ "resources": [\r
+ {\r
+ "href": "/fn/group",\r
+ "rel": "",\r
+ "rt": ["core.fn.group"],\r
+ "if": ["oic.if.ll"]\r
+ },{\r
+ "href": "/fn/operation",\r
+ "rel": "",\r
+ "rt": ["core.fn.operation"],\r
+ "if": ["oic.if.baseline", "oic.if.r"]\r
+ }\r
+ ],\r
+ "permission": 31\r
+ },\r
+ {\r
+ "subjectuuid": "*",\r
+ "resources": [\r
+ {\r
+ "href": "/oic/sec/pconf",\r
+ "rel": "",\r
+ "rt": ["oic.r.pconf"],\r
+ "if": ["oic.if.baseline"]\r
+ },\r
+ {\r
+ "href": "/oic/sec/dpairing",\r
+ "rel": "",\r
+ "rt": ["oic.r.dpairing"],\r
+ "if": ["oic.if.baseline"]\r
+ }\r
+ ],\r
+ "permission": 2\r
+ }\r
+ ]\r
+ },\r
+ "rowneruuid" : "00000000-0000-0000-0000-000000000000"\r
+ },\r
+ "pstat": {\r
+ "isop": false,\r
+ "cm": 2,\r
+ "tm": 0,\r
+ "om": 4,\r
+ "sm": 4,\r
+ "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+ },\r
+ "doxm": {\r
+ "oxms": [0, 65280],\r
+ "oxmsel": 65280,\r
+ "sct": 17,\r
+ "owned": false,\r
+ "x.org.iotivity.mom": 1,\r
+ "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
+ "devowneruuid": "00000000-0000-0000-0000-000000000000",\r
+ "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+ }\r
+}\r
+++ /dev/null
-#include <fn_iot.h>
-#include <fn_group.h>
-
-static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
- void *user_data)
-{
- 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
- The Group device resource is only one per device.
- resource type is core.fn.group.device
- This resource has device information as an attribute.
- The resource uri is /fn/group/device + certain uuid.
- ex) /fn/group/device123123
- */
- //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);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_initialize: Failed %s", get_error_message(ret));
- return false;
- }
-
- 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);
-
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_find_device_info: Failed %s", get_error_message(ret));
- return false;
- }
-
- /*
- "operation" resource
- The operation resource is a control command channel between daemon and daemon.
- resource type is core.fn.operation
- Within this function we create a default operation resource. (uri is /fn/operation/1)
- If we need more control channels, increase the number.
- ex) /fn/operation/2, /fn/operation/3
- */
- fn_iot_add_resource(FN_RESOURCE_TYPE_OPERATION, "1");
-
- return FN_ERROR_NONE;
-}
-
-static void _request_handler(iotcon_resource_h resource, iotcon_request_h request,
- void *user_data)
-{
- LOG_DEBUG("thread id is ");
- //get resource element from fn resource list or, parsing resource uri
-
- //if request type is "get" and resource type is "group",
- //then OWNER send device information to CLIENT(Device info Exchange)
- //if request type is "put" and resource type is "operation",
- //then It is join request. CLIENT send device information to OWNER(Device info Exchange)
- //resource type "operation" don't have "get" request type.
-}
-
-int fn_iot_add_resource(fn_resource_type_e resource_type, char *uri)
-{
- iotcon_resource_h resource = NULL;
- iotcon_resource_types_h resource_types = NULL;
- iotcon_resource_interfaces_h resource_ifaces = NULL;
- char uri_path[PATH_MAX] = {0,};
-
- int ret = iotcon_resource_types_create(&resource_types);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_resource_types_create failed! : %s", get_error_message(ret));
- goto EXIT;
- }
-
- ret = iotcon_resource_types_add(resource_types, fn_resource_get_type(resource_type));
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_resource_types_add failed! : %s", get_error_message(ret));
- goto EXIT;
- }
-
- ret = iotcon_resource_interfaces_create(&resource_ifaces);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_resource_interfaces_create failed! : %s", get_error_message(ret));
- goto EXIT;
- }
-
- ret = iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_resource_interfaces_add failed! : %s", get_error_message(ret));
- goto EXIT;
- }
-
- strncpy(uri_path, fn_resource_get_uri_prefix(resource_type), PATH_MAX);
- strncat(uri_path, uri, PATH_MAX);
-
- LOG_DEBUG("[ADD] resource uri is %s", uri_path);
- //name duplication check
-
- ret = iotcon_resource_create(uri_path, resource_types, resource_ifaces,
- fn_resource_get_policies(resource_type), _request_handler, NULL, &resource);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("iotcon_resource_create failed! : %s", get_error_message(ret));
- goto EXIT;
- }
-
- //get resource list of resource type
- ret = fn_resource_append(resource_type, uri, resource);
- if (FN_ERROR_NONE != ret) {
- LOG_ERR("fn_resource_append failed! : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
-
-EXIT:
- if (resource_types != NULL)
- iotcon_resource_types_destroy(resource_types);
-
- if (resource_ifaces != NULL)
- iotcon_resource_interfaces_destroy(resource_ifaces);
-
- return FN_ERROR_NONE;
-}
-
-static bool _get_res_type_cb(const char *string, void *user_data)
-{
- char **resource_type = user_data;
-
- *resource_type = g_strdup(string);
-
- LOG_DEBUG("resource type : %s", *resource_type);
-
- return IOTCON_FUNC_CONTINUE;
-}
-
-int found_device_count = 0;
-
-static bool _found_resource(iotcon_remote_resource_h resource,
- iotcon_error_e result, void *user_data)
-{
- int ret;
- char *resource_uri_path = NULL;
- iotcon_resource_types_h resource_types;
- char *resource_device_id;
- char *resource_device_name;
- char *resource_host;
- char *resource_type;
- fn_group_type_e group_type;
-
- LOG_DEBUG("Resource Found");
-
- /* get the resource URI */
- ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get resource uri path");
- return IOTCON_FUNC_CONTINUE;
- }
- LOG_DEBUG("resource uri : %s", resource_uri_path);
-
- /* get the resource device id */
- ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get resource device id");
- return IOTCON_FUNC_CONTINUE;
- }
- LOG_DEBUG("resource device id : %s", resource_device_id);
-
- /* get the resource device name */
- ret = iotcon_remote_resource_get_device_name(resource,
- &resource_device_name);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get resource device name");
- return IOTCON_FUNC_CONTINUE;
- }
- LOG_DEBUG("resource device name : %s", resource_device_name);
-
- /* get the resource host address */
- ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get resource host address");
- return IOTCON_FUNC_CONTINUE;
- }
- LOG_DEBUG("resource host : %s", resource_host);
-
- ret = iotcon_remote_resource_get_types(resource, &resource_types);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get resource types");
- return IOTCON_FUNC_CONTINUE;
- }
-
- ret = iotcon_resource_types_foreach(resource_types, _get_res_type_cb,
- &resource_type);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to get foreach resource types");
- 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, group_type);
- found_device_count++;
-
- g_free(resource_type);
-
- return IOTCON_FUNC_CONTINUE;
-}
-
-static gboolean _timeout_cb(gpointer data)
-{
- int ret = -1;
- if (found_device_count > 0)
- ret = 0;
-
- notify_group_finish(ret);
-
- return false;
-}
-
-int fn_iot_discovery_resource(fn_resource_type_e resource_type, int timeout)
-{
- int ret;
- iotcon_query_h query;
-
- found_device_count = 0;
-
- ret = iotcon_set_timeout(timeout);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to set timeout value");
- return FN_ERROR_OPERATION_FAILED;
- }
-
- ret = iotcon_query_create(&query);
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to create iotcon query");
- return FN_ERROR_OPERATION_FAILED;
- }
-
- ret = iotcon_query_set_resource_type(query,
- fn_resource_get_type(resource_type));
- if (IOTCON_ERROR_NONE != ret) {
- LOG_ERR("Failed to set iotcon query resource type");
- return FN_ERROR_OPERATION_FAILED;
- }
-
- LOG_DEBUG("find resource : %s", get_error_message(ret));
-
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
- IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
- query, _found_resource, NULL);
-
- g_timeout_add_seconds(timeout + 1, _timeout_cb, NULL);
-
- LOG_DEBUG("find resource : %s", get_error_message(ret));
-
- return ret;
-}
-
-int fn_iot_delete_resource(fn_resource_type_e resource_type)
-{
- //delete resource from resource list using resource_type and index
- //delete DB
- return FN_ERROR_NONE;
-}
-
-int fn_iot_deinitialize()
-{
- return FN_ERROR_NONE;
-}