Tizen Native API
5.0
|
IoTCon Remote Resource provides API to manage remote resource.
#include <iotcon.h>
The IoTCon Remote Resource API provides methods for managing resource handle and send request. Example :
#include <iotcon.h> ... static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err, iotcon_request_type_e request_type, iotcon_response_h response, void *user_data) { if (IOTCON_ERROR_NONE != err) return; // handle get result ... } static bool _on_find(iotcon_remote_resource_h resource, iotcon_error_e result, void *user_data) { int ret; iotcon_remote_resource_h resource_clone = NULL; if (IOTCON_ERROR_NONE != result) return IOTCON_FUNC_STOP; if (NULL == resource) return IOTCON_FUNC_CONTINUE; // clone handle ret = iotcon_remote_resource_clone(resource, &resource_clone); if (IOTCON_ERROR_NONE != ret) return IOTCON_FUNC_CONTINUE; // request get ret = iotcon_remote_resource_get(resource_clone, NULL, _on_get, NULL); if (IOTCON_ERROR_NONE != ret) { iotcon_remote_resource_destroy(resource_clone); return IOTCON_FUNC_CONTINUE; } ... return IOTCON_FUNC_CONTINUE; } static void _find_light_resource() { int ret; ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, "org.tizen.light", false, _on_find, NULL); if (IOTCON_ERROR_NONE != ret) return; }
This API is related with the following features:
Functions | |
int | iotcon_remote_resource_create (const char *host_address, iotcon_connectivity_type_e connectivity_type, const char *uri_path, uint8_t policies, iotcon_resource_types_h resource_types, iotcon_resource_interfaces_h resource_ifaces, iotcon_remote_resource_h *remote_resource) |
Creates a new resource handle. | |
int | iotcon_remote_resource_destroy (iotcon_remote_resource_h resource) |
Destroys a resource handle. | |
int | iotcon_remote_resource_clone (iotcon_remote_resource_h src, iotcon_remote_resource_h *dest) |
Clones a clone of a remote resource. | |
int | iotcon_remote_resource_observe_register (iotcon_remote_resource_h resource, iotcon_observe_policy_e observe_policy, iotcon_query_h query, iotcon_remote_resource_observe_cb cb, void *user_data) |
Registers observe callback on the resource. | |
int | iotcon_remote_resource_observe_deregister (iotcon_remote_resource_h resource) |
Deregisters observe callback on the resource. | |
int | iotcon_remote_resource_get (iotcon_remote_resource_h resource, iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data) |
Gets the attributes of a resource asynchronously. | |
int | iotcon_remote_resource_put (iotcon_remote_resource_h resource, iotcon_representation_h repr, iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data) |
Puts the representation of a resource asynchronously. | |
int | iotcon_remote_resource_post (iotcon_remote_resource_h resource, iotcon_representation_h repr, iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data) |
Posts on a resource asynchronously. | |
int | iotcon_remote_resource_delete (iotcon_remote_resource_h resource, iotcon_remote_resource_response_cb cb, void *user_data) |
Deletes a resource asynchronously. | |
int | iotcon_remote_resource_start_caching (iotcon_remote_resource_h resource, iotcon_remote_resource_cached_representation_changed_cb cb, void *user_data) |
Starts caching of a remote resource. | |
int | iotcon_remote_resource_stop_caching (iotcon_remote_resource_h resource) |
Stops caching of a remote resource. | |
int | iotcon_remote_resource_start_monitoring (iotcon_remote_resource_h resource, iotcon_remote_resource_state_changed_cb cb, void *user_data) |
Starts monitoring of a remote resource. | |
int | iotcon_remote_resource_stop_monitoring (iotcon_remote_resource_h resource) |
Stops monitoring of a remote resource. | |
int | iotcon_remote_resource_get_uri_path (iotcon_remote_resource_h resource, char **uri_path) |
Gets an URI path of the remote resource. | |
int | iotcon_remote_resource_get_connectivity_type (iotcon_remote_resource_h resource, iotcon_connectivity_type_e *connectivity_type) |
Gets a connectivity type of the remote resource. | |
int | iotcon_remote_resource_get_host_address (iotcon_remote_resource_h resource, char **host_address) |
Gets a host address of the remote resource. | |
int | iotcon_remote_resource_get_device_id (iotcon_remote_resource_h resource, char **device_id) |
Gets a device ID of the remote resource. | |
int | iotcon_remote_resource_get_device_name (iotcon_remote_resource_h resource, char **device_name) |
Gets the device name of the remote resource. | |
int | iotcon_remote_resource_get_types (iotcon_remote_resource_h resource, iotcon_resource_types_h *types) |
Gets resource types of the remote resource. | |
int | iotcon_remote_resource_get_interfaces (iotcon_remote_resource_h resource, iotcon_resource_interfaces_h *ifaces) |
Gets resource interfaces of the remote resource. | |
int | iotcon_remote_resource_get_policies (iotcon_remote_resource_h resource, uint8_t *policies) |
Checks whether the remote resource is observable or not. | |
int | iotcon_remote_resource_get_options (iotcon_remote_resource_h resource, iotcon_options_h *options) |
Gets options of the remote resource. | |
int | iotcon_remote_resource_set_options (iotcon_remote_resource_h resource, iotcon_options_h options) |
Sets options into the remote resource. | |
int | iotcon_remote_resource_get_cached_representation (iotcon_remote_resource_h resource, iotcon_representation_h *representation) |
Gets cached representation from the remote resource. | |
int | iotcon_remote_resource_get_checking_interval (iotcon_remote_resource_h resource, int *interval) |
Gets the checking interval which is using on the monitoring & caching of remote resource. | |
int | iotcon_remote_resource_set_checking_interval (iotcon_remote_resource_h resource, int interval) |
Sets the checking interval which is using on the monitoring & caching of remote resource. | |
Typedefs | |
typedef void(* | iotcon_remote_resource_observe_cb )(iotcon_remote_resource_h resource, iotcon_error_e err, int sequence_number, iotcon_response_h response, void *user_data) |
Specifies the type of observe callback passed to iotcon_remote_resource_observe_register(). The err could be one of iotcon_error_e. The response is created by a server. Therefore, you can't get any values that the server didn't set. | |
typedef void(* | iotcon_remote_resource_response_cb )(iotcon_remote_resource_h resource, iotcon_error_e err, iotcon_request_type_e request_type, iotcon_response_h response, void *user_data) |
Specifies the type of response function. | |
typedef void(* | iotcon_remote_resource_cached_representation_changed_cb )(iotcon_remote_resource_h resource, iotcon_representation_h representation, void *user_data) |
Specifies the type of function passed to iotcon_remote_resource_start_caching(). | |
typedef void(* | iotcon_remote_resource_state_changed_cb )(iotcon_remote_resource_h resource, iotcon_remote_resource_state_e state, void *user_data) |
Specifies the type of function passed to iotcon_remote_resource_start_monitoring(). |
typedef void(* iotcon_remote_resource_cached_representation_changed_cb)(iotcon_remote_resource_h resource, iotcon_representation_h representation, void *user_data) |
Specifies the type of function passed to iotcon_remote_resource_start_caching().
[in] | resource | The handle of the remote resource |
[in] | representation | The handle of the representation |
[in] | user_data | The user data to pass to the function |
typedef void(* iotcon_remote_resource_observe_cb)(iotcon_remote_resource_h resource, iotcon_error_e err, int sequence_number, iotcon_response_h response, void *user_data) |
Specifies the type of observe callback passed to iotcon_remote_resource_observe_register(). The err could be one of iotcon_error_e.
The response is created by a server. Therefore, you can't get any values that the server didn't set.
[in] | resource | The handle of the remote resource |
[in] | err | The error code |
[in] | sequence_number | The sequence number of observe |
[in] | response | The handle of the response |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* iotcon_remote_resource_response_cb)(iotcon_remote_resource_h resource, iotcon_error_e err, iotcon_request_type_e request_type, iotcon_response_h response, void *user_data) |
Specifies the type of response function.
The function passed to iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post(), iotcon_remote_resource_delete().
The err could be one of iotcon_error_e.
The request_type could be one of iotcon_request_type_e.
The response is created by a server. Therefore, you can't get any values that the server didn't set.
[in] | resource | The handle of the resource |
[in] | err | The error code |
[in] | request_type | The request type |
[in] | response | The handle of the response |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* iotcon_remote_resource_state_changed_cb)(iotcon_remote_resource_h resource, iotcon_remote_resource_state_e state, void *user_data) |
Specifies the type of function passed to iotcon_remote_resource_start_monitoring().
[in] | resource | The handle of the remote resource |
[in] | state | The state of the remote resource |
[in] | user_data | The user data to pass to the function |
int iotcon_remote_resource_clone | ( | iotcon_remote_resource_h | src, |
iotcon_remote_resource_h * | dest | ||
) |
Clones a clone of a remote resource.
[in] | src | The Source of resource |
[out] | dest | The cloned resource handle |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_create | ( | const char * | host_address, |
iotcon_connectivity_type_e | connectivity_type, | ||
const char * | uri_path, | ||
uint8_t | policies, | ||
iotcon_resource_types_h | resource_types, | ||
iotcon_resource_interfaces_h | resource_ifaces, | ||
iotcon_remote_resource_h * | remote_resource | ||
) |
Creates a new resource handle.
Creates a resource proxy object so that iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post(), iotcon_remote_resource_delete(), iotcon_remote_resource_observe_register(), iotcon_remote_resource_start_caching() and iotcon_remote_resource_start_monitoring() API can be used without discovering the object in advance.
To use this API, you should provide all of the details required to correctly contact and observe the object.
If not, you should discover the resource object manually.
The policies can contain multiple policies like IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE.
[in] | host_address | The host address of the resource |
[in] | connectivity_type | The connectivity type. Can not use IOTCON_CONNECTIVITY_ALL. Connectivity type of specific remote resource(It has specific host address, not IOTCON_MULTICAST_ADDRESS) is already decided. Use specific connectivity type of the remote resource. You can refer to the iotcon_remote_resource_get_connectivity_type(). |
[in] | uri_path | The URI path of the resource |
[in] | policies | The policies of the resource Set of iotcon_resource_policy_e |
[in] | resource_types | The resource types of the resource. For example, "core.light" |
[in] | resource_ifaces | The resource interfaces of the resource |
[out] | remote_resource | Generated resource handle |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_IOTIVITY | IoTivity errors |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
int iotcon_remote_resource_delete | ( | iotcon_remote_resource_h | resource, |
iotcon_remote_resource_response_cb | cb, | ||
void * | user_data | ||
) |
Deletes a resource asynchronously.
When server sends response on delete request, iotcon_remote_resource_response_cb() will be called.
[in] | resource | The handle of the resource |
[in] | cb | The callback function |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_destroy | ( | iotcon_remote_resource_h | resource | ) |
Destroys a resource handle.
[in] | resource | The handle of the resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get | ( | iotcon_remote_resource_h | resource, |
iotcon_query_h | query, | ||
iotcon_remote_resource_response_cb | cb, | ||
void * | user_data | ||
) |
Gets the attributes of a resource asynchronously.
When server sends response on get request, iotcon_remote_resource_response_cb() will be called.
[in] | resource | The handle of the resource |
[in] | query | The query to send to server |
[in] | cb | The callback function |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_get_cached_representation | ( | iotcon_remote_resource_h | resource, |
iotcon_representation_h * | representation | ||
) |
Gets cached representation from the remote resource.
[in] | resource | The handle of the remote resource |
[out] | representation | The handle of the representation |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_checking_interval | ( | iotcon_remote_resource_h | resource, |
int * | interval | ||
) |
Gets the checking interval which is using on the monitoring & caching of remote resource.
This API get the checking interval which is using in the process of monitoring and caching() of remote resource.
The monitoring and caching will operate "GET method" with the checking interval. Default checking interval is 10 seconds.
[in] | resource | The handle of the remote resource |
[out] | interval | Seconds for time interval |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_connectivity_type | ( | iotcon_remote_resource_h | resource, |
iotcon_connectivity_type_e * | connectivity_type | ||
) |
Gets a connectivity type of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | connectivity_type | The connectivity type of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_device_id | ( | iotcon_remote_resource_h | resource, |
char ** | device_id | ||
) |
Gets a device ID of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | device_id | The device ID of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_NO_DATA | No data available |
int iotcon_remote_resource_get_device_name | ( | iotcon_remote_resource_h | resource, |
char ** | device_name | ||
) |
Gets the device name of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | device_name | The device name of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_NO_DATA | No data available |
int iotcon_remote_resource_get_host_address | ( | iotcon_remote_resource_h | resource, |
char ** | host_address | ||
) |
Gets a host address of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | host_address | The host address of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_interfaces | ( | iotcon_remote_resource_h | resource, |
iotcon_resource_interfaces_h * | ifaces | ||
) |
Gets resource interfaces of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | ifaces | The resource interfaces of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_options | ( | iotcon_remote_resource_h | resource, |
iotcon_options_h * | options | ||
) |
Gets options of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | options | The handle of the header options |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_policies | ( | iotcon_remote_resource_h | resource, |
uint8_t * | policies | ||
) |
Checks whether the remote resource is observable or not.
The policies can contain multiple policies like IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE.
[in] | resource | The handle of the resource |
[out] | policies | The policies of the resource Set of iotcon_resource_policy_e |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_types | ( | iotcon_remote_resource_h | resource, |
iotcon_resource_types_h * | types | ||
) |
Gets resource types of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | types | The resource types of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_get_uri_path | ( | iotcon_remote_resource_h | resource, |
char ** | uri_path | ||
) |
Gets an URI path of the remote resource.
[in] | resource | The handle of the remote resource |
[out] | uri_path | The URI path of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_observe_deregister | ( | iotcon_remote_resource_h | resource | ) |
Deregisters observe callback on the resource.
[in] | resource | The handle of the resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_SYSTEM | System error |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_observe_register | ( | iotcon_remote_resource_h | resource, |
iotcon_observe_policy_e | observe_policy, | ||
iotcon_query_h | query, | ||
iotcon_remote_resource_observe_cb | cb, | ||
void * | user_data | ||
) |
Registers observe callback on the resource.
When server sends notification message, iotcon_remote_resource_observe_cb() will be called. The observe_policy could be one of iotcon_observe_policy_e.
[in] | resource | The handle of the resource |
[in] | observe_policy | The type to specify how client wants to observe |
[in] | query | The query to send to server |
[in] | cb | The callback function to get notifications from server |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_IOTIVITY | IoTivity errors |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_post | ( | iotcon_remote_resource_h | resource, |
iotcon_representation_h | repr, | ||
iotcon_query_h | query, | ||
iotcon_remote_resource_response_cb | cb, | ||
void * | user_data | ||
) |
Posts on a resource asynchronously.
When server sends response on post request, iotcon_remote_resource_response_cb() will be called.
[in] | resource | The handle of the resource |
[in] | repr | The handle of the representation |
[in] | query | The query to send to server |
[in] | cb | The callback function |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_put | ( | iotcon_remote_resource_h | resource, |
iotcon_representation_h | repr, | ||
iotcon_query_h | query, | ||
iotcon_remote_resource_response_cb | cb, | ||
void * | user_data | ||
) |
Puts the representation of a resource asynchronously.
When server sends response on put request, iotcon_remote_resource_response_cb() will be called.
[in] | resource | The handle of the resource |
[in] | repr | The handle of the representation |
[in] | query | The query to send to server |
[in] | cb | The callback function |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_set_checking_interval | ( | iotcon_remote_resource_h | resource, |
int | interval | ||
) |
Sets the checking interval which is using on the monitoring & caching of remote resource.
This API set the checking interval which is using in the process of monitoring and caching() of remote resource.
The monitoring and caching will operate "GET method" with the checking interval changed by this function. Default checking interval is 10 seconds.
[in] | resource | The handle of the remote resource |
[in] | interval | Seconds for time interval (must be in range from 1 to 3600) |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_set_options | ( | iotcon_remote_resource_h | resource, |
iotcon_options_h | options | ||
) |
Sets options into the remote resource.
[in] | resource | The handle of the remote resource |
[in] | options | The handle of the header options |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_remote_resource_start_caching | ( | iotcon_remote_resource_h | resource, |
iotcon_remote_resource_cached_representation_changed_cb | cb, | ||
void * | user_data | ||
) |
Starts caching of a remote resource.
Use this function to start caching the resource's attribute.
Although, remote resource is not observable, it keeps the representation up-to-date. Because it checks whether representation is changed periodically.
Therefore, you can get the cached representation even when the remote resource is off-line. The default checking interval is 10 seconds. It can be changed by iotcon_remote_resource_set_checking_interval().
[in] | resource | The handle of the remote resource to be cached |
[in] | cb | The callback function to add into callback list |
[in] | user_data | The user data to pass to the callback function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_SYSTEM | System error |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_ALREADY | Already done |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_start_monitoring | ( | iotcon_remote_resource_h | resource, |
iotcon_remote_resource_state_changed_cb | cb, | ||
void * | user_data | ||
) |
Starts monitoring of a remote resource.
When remote resource's state is changed, registered callbacks will be called in turn. Although, remote resource does not call iotcon_start_presence(), it knows the state of resource. Because it checks the state of resource, periodically.
The default checking interval is 10 seconds. It can be changed by iotcon_remote_resource_set_checking_interval().
[in] | resource | The handle of the remote resource |
[in] | cb | The callback function to add into callback list |
[in] | user_data | The user data to pass to the callback function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_ALREADY | Already done |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_stop_caching | ( | iotcon_remote_resource_h | resource | ) |
Stops caching of a remote resource.
Use this function to stop caching the resource's attribute.
[in] | resource | The handle of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_SYSTEM | System error |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |
int iotcon_remote_resource_stop_monitoring | ( | iotcon_remote_resource_h | resource | ) |
Stops monitoring of a remote resource.
Use this function to stop monitoring the remote resource.
[in] | resource | The handle of the remote resource |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_SYSTEM | System error |
IOTCON_ERROR_PERMISSION_DENIED | Permission denied |