Tizen(Headless) Native API
6.0
|
IoTCon Resource Interfaces provides API to manage resource interfaces.
Required Header
#include <iotcon.h>
Overview
The IoTCon Resource Interfaces API provides methods for managing handle and add, remove resource interfaces. A resource interface indicates a class or category of resources. Example :
#include <iotcon.h> static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data) { // handle request ... } static void _create_light_resource() { int ret; iotcon_resource_h resource = NULL; iotcon_resource_interfaces_h resource_ifaces = NULL; iotcon_resource_types_h resource_types = NULL; ret = iotcon_resource_types_create(&resource_types); if (IOTCON_ERROR_NONE != ret) return; ret = iotcon_resource_types_add(resource_types, "org.tizen.light"); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(resource_types); return; } ret = iotcon_resource_interfaces_create(&resource_ifaces); if (IOTCON_ERROR_NONE != ret) iotcon_resource_types_destroy(resource_types); return; ret = iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); return; } ret = iotcon_resource_create("/light/1", resource_types, resource_ifaces, IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE, _request_handler, NULL, &resource); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); return; } iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); }
Related Features
This API is related with the following features:
- http://tizen.org/feature/iot.ocf
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | iotcon_resource_interfaces_create (iotcon_resource_interfaces_h *ifaces) |
Creates a new resource interfaces handle. | |
int | iotcon_resource_interfaces_destroy (iotcon_resource_interfaces_h ifaces) |
Destroys a resource ifaces handle. | |
int | iotcon_resource_interfaces_add (iotcon_resource_interfaces_h ifaces, const char *iface) |
Inserts a resource iface into the list. | |
int | iotcon_resource_interfaces_remove (iotcon_resource_interfaces_h ifaces, const char *iface) |
Deletes a resource iface from the list. | |
int | iotcon_resource_interfaces_foreach (iotcon_resource_interfaces_h ifaces, iotcon_resource_interfaces_foreach_cb cb, void *user_data) |
Gets all of the resource ifaces of the list by invoking the callback function. | |
int | iotcon_resource_interfaces_clone (iotcon_resource_interfaces_h src, iotcon_resource_interfaces_h *dest) |
Clones the resource ifaces handle. | |
Typedefs | |
typedef bool(* | iotcon_resource_interfaces_foreach_cb )(const char *iface, void *user_data) |
Specifies the iface of function passed to iotcon_resource_interfaces_foreach(). |
Typedef Documentation
typedef bool(* iotcon_resource_interfaces_foreach_cb)(const char *iface, void *user_data) |
Specifies the iface of function passed to iotcon_resource_interfaces_foreach().
- Since :
- 3.0
- Remarks:
- iface could be a value such as IOTCON_INTERFACE_DEFAULT.
- Parameters:
-
[in] iface The value of the resource ifaces [in] user_data The user data to pass to the function
- Returns:
true
to continue with the next iteration of the loop, otherwisefalse
to break out of the loop IOTCON_FUNC_CONTINUE and IOTCON_FUNC_STOP are more friendly values for the return
- Precondition:
- iotcon_resource_interfaces_foreach() will invoke this callback function.
- See also:
- iotcon_resource_interfaces_foreach()
Function Documentation
int iotcon_resource_interfaces_add | ( | iotcon_resource_interfaces_h | ifaces, |
const char * | iface | ||
) |
Inserts a resource iface into the list.
- Since :
- 3.0
- Remarks:
- iface could be a value such as IOTCON_INTERFACE_DEFAULT.
- Parameters:
-
[in] ifaces The handle of the resource ifaces [in] iface The string data to insert into the resource ifaces
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_INVALID_PARAMETER Invalid parameter IOTCON_ERROR_ALREADY Already done
int iotcon_resource_interfaces_clone | ( | iotcon_resource_interfaces_h | src, |
iotcon_resource_interfaces_h * | dest | ||
) |
Clones the resource ifaces handle.
Makes a deep copy of a source list of resource ifaces.
- Since :
- 3.0
- Remarks:
- You must destroy dest by calling iotcon_resource_interfaces_destroy() if dest is no longer needed.
- Parameters:
-
[in] src The origin handle of the resource ifaces [out] dest Clone of a source list of resource ifaces
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
int iotcon_resource_interfaces_create | ( | iotcon_resource_interfaces_h * | ifaces | ) |
Creates a new resource interfaces handle.
- Since :
- 3.0
- Remarks:
- You must destroy ifaces by calling iotcon_resource_interfaces_destroy() if ifaces is no longer needed.
- Parameters:
-
[out] ifaces A newly allocated list of resource ifaces handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_OUT_OF_MEMORY Out of memory IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
Destroys a resource ifaces handle.
- Since :
- 3.0
- Parameters:
-
[in] ifaces The handle of the resource ifaces
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
int iotcon_resource_interfaces_foreach | ( | iotcon_resource_interfaces_h | ifaces, |
iotcon_resource_interfaces_foreach_cb | cb, | ||
void * | user_data | ||
) |
Gets all of the resource ifaces of the list by invoking the callback function.
iotcon_resource_interfaces_foreach_cb() will be called for each iface.
If iotcon_resource_interfaces_foreach_cb() returns false, iteration will be stopped.
- Since :
- 3.0
- Parameters:
-
[in] ifaces The handle of resource ifaces [in] cb The callback function to get data [in] user_data The user data to pass to the function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- Postcondition:
- iotcon_resource_interfaces_foreach() will be called for each iface.
int iotcon_resource_interfaces_remove | ( | iotcon_resource_interfaces_h | ifaces, |
const char * | iface | ||
) |
Deletes a resource iface from the list.
- Since :
- 3.0
- Remarks:
- iface could be a value such as IOTCON_INTERFACE_DEFAULT.
- Parameters:
-
[in] ifaces The handle of the resource ifaces [in] iface The string data to delete from the resource ifaces
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
IOTCON_ERROR_NONE Successful IOTCON_ERROR_NOT_SUPPORTED Not supported IOTCON_ERROR_INVALID_PARAMETER Invalid parameter IOTCON_ERROR_NO_DATA No data available