IoTivity-Lite
|
Client side support functions. More...
Functions | |
void | oc_close_session (const oc_endpoint_t *endpoint) |
close the tls session on the indicated endpoint More... | |
bool | oc_do_delete (const char *uri, const oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Issue a DELETE request to delete a resource. More... | |
bool | oc_do_delete_with_timeout (const char *uri, const oc_endpoint_t *endpoint, const char *query, uint16_t timeout_seconds, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Issue a DELETE request to delete a resource. More... | |
bool | oc_do_get (const char *uri, const oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Issue a GET request to obtain the current value of all properties a resource. More... | |
bool | oc_do_get_with_timeout (const char *uri, const oc_endpoint_t *endpoint, const char *query, uint16_t timeout_seconds, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Issue a GET request to obtain the current value of all properties a resource. More... | |
bool | oc_do_ip_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data) |
Discover all servers that have a resource type. More... | |
bool | oc_do_ip_discovery_all (oc_discovery_all_handler_t handler, void *user_data) |
Discover all servers. More... | |
bool | oc_do_ip_discovery_all_at_endpoint (oc_discovery_all_handler_t handler, const oc_endpoint_t *endpoint, void *user_data) |
Discover all resources in a specific endpoint. More... | |
bool | oc_do_ip_discovery_at_endpoint (const char *rt, oc_discovery_handler_t handler, const oc_endpoint_t *endpoint, void *user_data) |
Discover resources in a specific endpoint. More... | |
bool | oc_do_ip_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data) |
invoke multicast discovery of devices More... | |
bool | oc_do_observe (const char *uri, const oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Dispatch a GET request with the CoAP Observe option to subscribe for notifications from a resource. More... | |
bool | oc_do_post (void) |
Dispatch the CoAP POST request. More... | |
bool | oc_do_post_with_timeout (uint16_t timeout_seconds) |
Dispatch the CoAP POST request. More... | |
bool | oc_do_put (void) |
Dispatch the CoAP PUT request. More... | |
bool | oc_do_put_with_timeout (uint16_t timeout_seconds) |
Dispatch the CoAP POST request. More... | |
bool | oc_do_realm_local_ipv6_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data) |
Discover all servers that have a resource type using the realm-local scope. More... | |
bool | oc_do_realm_local_ipv6_discovery_all (oc_discovery_all_handler_t handler, void *user_data) |
Discover all servers using the realm-local scope. More... | |
bool | oc_do_realm_local_ipv6_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data) |
invoke multicast discovery of devices on IPV6 realm local scope More... | |
bool | oc_do_site_local_ipv6_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data) |
Discover all servers that have a resource type using the site-local scope. More... | |
bool | oc_do_site_local_ipv6_discovery_all (oc_discovery_all_handler_t handler, void *user_data) |
Discover all servers using the realm-local scope. More... | |
bool | oc_do_site_local_ipv6_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data) |
invoke multicast discovery of devices on IPV6 site local scope More... | |
void | oc_free_server_endpoints (oc_endpoint_t *endpoint) |
Free a list of endpoints from the oc_endpoint_t. More... | |
bool | oc_init_post (const char *uri, const oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Prepare the stack to issue a POST request. More... | |
bool | oc_init_put (const char *uri, const oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
Prepare the stack to issue a PUT request. More... | |
bool | oc_send_ping (bool custody, const oc_endpoint_t *endpoint, uint16_t timeout_seconds, oc_response_handler_t handler, void *user_data) |
send CoAP ping over the TCP connection More... | |
void | oc_stop_multicast (oc_client_response_t *response) |
stop the multicast update (e.g. More... | |
bool | oc_stop_observe (const char *uri, const oc_endpoint_t *endpoint) |
Unsubscribe for notifications from a resource. More... | |
Client side support functions.
void oc_close_session | ( | const oc_endpoint_t * | endpoint | ) |
close the tls session on the indicated endpoint
endpoint | endpoint indicating a session |
bool oc_do_delete | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Issue a DELETE request to delete a resource.
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | handler | function invoked once the client has received the servers response to the DELETE request (cannot be NULL) |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_delete_with_timeout | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
uint16_t | timeout_seconds, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Issue a DELETE request to delete a resource.
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | timeout_seconds | timeout for the get |
[in] | handler | function invoked once the client has received the servers response to the DELETE request (cannot be NULL) |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
timeout_seconds
expires then the response handler is invoked with OC_REQUEST_TIMEOUT code bool oc_do_get | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Issue a GET request to obtain the current value of all properties a resource.
Example:
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | handler | function invoked once the client has received the servers response to the GET request |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_get_with_timeout | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
uint16_t | timeout_seconds, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Issue a GET request to obtain the current value of all properties a resource.
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | timeout_seconds | timeout for the get |
[in] | handler | function invoked once the client has received the servers response to the GET request |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
timeout_seconds
expires then the response handler is invoked with OC_REQUEST_TIMEOUT code bool oc_do_ip_discovery | ( | const char * | rt, |
oc_discovery_handler_t | handler, | ||
void * | user_data | ||
) |
Discover all servers that have a resource type.
The discovery request will make a muli-cast request to the IPv6 link-local multicast address scope and over IPv4.
Multicast discovery over IPv4 will only happen if the stack is built with the OC_IPV4 build flag.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | rt | the resource type the client is trying to discover |
[in] | handler | the oc_discovery_handler_t that will be called once a server containing the resource type is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_handler_t. |
bool oc_do_ip_discovery_all | ( | oc_discovery_all_handler_t | handler, |
void * | user_data | ||
) |
Discover all servers.
The discovery request will make a muli-cast request to the IPv6 link-local multicast address scope and over IPv4.
Multicast discovery over IPv4 will only happen if the stack is built with the OC_IPV4 build flag.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | handler | the oc_discovery_all_handler_t that will be called once a server is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_all_handler_t. |
bool oc_do_ip_discovery_all_at_endpoint | ( | oc_discovery_all_handler_t | handler, |
const oc_endpoint_t * | endpoint, | ||
void * | user_data | ||
) |
Discover all resources in a specific endpoint.
handler | The callback for discovered resources. Must not be NULL. |
endpoint | Endpoint at which to discover resources. Must not be NULL. |
user_data | Callback parameter for user defined value. |
bool oc_do_ip_discovery_at_endpoint | ( | const char * | rt, |
oc_discovery_handler_t | handler, | ||
const oc_endpoint_t * | endpoint, | ||
void * | user_data | ||
) |
Discover resources in a specific endpoint.
rt | Resource type query to discover. |
handler | The callback for discovered resources. Must not be NULL. |
endpoint | Endpoint at which to discover resources. Must not be NULL. |
user_data | Callback parameter for user defined value. |
bool oc_do_ip_multicast | ( | const char * | uri, |
const char * | query, | ||
oc_response_handler_t | handler, | ||
void * | user_data | ||
) |
invoke multicast discovery of devices
[in] | uri | the uri for multicast command to be used |
[in] | query | the query of the multicast command |
[in] | handler | function invoked once the client has received the servers response to the discovery request |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_observe | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Dispatch a GET request with the CoAP Observe option to subscribe for notifications from a resource.
The oc_response_handler_t will be invoked each time upon receiving a notification.
The handler will continue to be invoked till oc_stop_observe() is called.
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | handler | function invoked once the client has received the servers response to the POST request |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_post | ( | void | ) |
Dispatch the CoAP POST request.
Before the POST request is dispatched it must be initialized using oc_init_post
bool oc_do_post_with_timeout | ( | uint16_t | timeout_seconds | ) |
Dispatch the CoAP POST request.
[in] | timeout_seconds | timeout for the POST response |
timeout_seconds
expires then the response handler is invoked with OC_REQUEST_TIMEOUT codebool oc_do_put | ( | void | ) |
Dispatch the CoAP PUT request.
Before the PUT request is dispatched it must be initialized using oc_init_put
bool oc_do_put_with_timeout | ( | uint16_t | timeout_seconds | ) |
Dispatch the CoAP POST request.
Before the POST request is dispatched it must be initialized using oc_init_put.
[in] | timeout_seconds | timeout for the PUT response |
timeout_seconds
expires then the response handler is invoked with OC_REQUEST_TIMEOUT codebool oc_do_realm_local_ipv6_discovery | ( | const char * | rt, |
oc_discovery_handler_t | handler, | ||
void * | user_data | ||
) |
Discover all servers that have a resource type using the realm-local scope.
The discovery request will make a muli-cast request to the IPv6 realm-local multicast address scope. The address scope is the domain in which the multicast discovery packet should be propagated.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | rt | the resource type the client is trying to discover |
[in] | handler | the oc_discovery_handler_t that will be called once a server containing the resource type is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_handler_t. |
bool oc_do_realm_local_ipv6_discovery_all | ( | oc_discovery_all_handler_t | handler, |
void * | user_data | ||
) |
Discover all servers using the realm-local scope.
The discovery request will make a muli-cast request to the IPv6 realm-local multicast address scope. The address scope is the domain in which the multicast discovery packet should be propagated.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | handler | the oc_discovery_all_handler_t that will be called once a server is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_all_handler_t. |
bool oc_do_realm_local_ipv6_multicast | ( | const char * | uri, |
const char * | query, | ||
oc_response_handler_t | handler, | ||
void * | user_data | ||
) |
invoke multicast discovery of devices on IPV6 realm local scope
[in] | uri | the uri for multicast command to be used |
[in] | query | the query of the multicast command |
[in] | handler | function invoked once the client has received the servers response to the discovery request |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_site_local_ipv6_discovery | ( | const char * | rt, |
oc_discovery_handler_t | handler, | ||
void * | user_data | ||
) |
Discover all servers that have a resource type using the site-local scope.
The discovery request will make a muli-cast request to the IPv6 site-local multicast address scope. The address scope is the domain in which the multicast discovery packet should be propagated.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | rt | the resource type the client is trying to discover |
[in] | handler | the oc_discovery_handler_t that will be called once a server containing the resource type is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_handler_t. |
bool oc_do_site_local_ipv6_discovery_all | ( | oc_discovery_all_handler_t | handler, |
void * | user_data | ||
) |
Discover all servers using the realm-local scope.
The discovery request will make a muli-cast request to the IPv6 site-local multicast address scope. The address scope is the domain in which the multicast discovery packet should be propagated.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | handler | the oc_discovery_all_handler_t that will be called once a server is discovered |
[in] | user_data | context pointer that is passed to the oc_discovery_all_handler_t. |
bool oc_do_site_local_ipv6_multicast | ( | const char * | uri, |
const char * | query, | ||
oc_response_handler_t | handler, | ||
void * | user_data | ||
) |
invoke multicast discovery of devices on IPV6 site local scope
[in] | uri | the uri for multicast command to be used |
[in] | query | the query of the multicast command |
[in] | handler | function invoked once the client has received the servers response to the discovery request |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
void oc_free_server_endpoints | ( | oc_endpoint_t * | endpoint | ) |
Free a list of endpoints from the oc_endpoint_t.
note: oc_endpoint_t is a linked list. This will walk the list an free all endpoints found in the list. Even if the list only consists of a single endpoint.
[in,out] | endpoint | the endpoint list to free |
bool oc_init_post | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Prepare the stack to issue a POST request.
After oc_init_post has been called a CoAP message can be built using oc_rep_*
functions. Then oc_do_post is called to dispatch the CoAP request.
Example:
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | handler | function invoked once the client has received the servers response to the POST request |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_init_put | ( | const char * | uri, |
const oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
Prepare the stack to issue a PUT request.
After oc_init_put has been called a CoAP message can be built using oc_rep_*
functions. Then oc_do_put is called to dispatch the CoAP request.
Example:
[in] | uri | the uri of the resource |
[in] | endpoint | the endpoint of the server |
[in] | query | a query parameter that will be sent to the server's oc_request_callback_t. |
[in] | handler | function invoked once the client has received the servers response to the PUT request |
[in] | qos | the quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_send_ping | ( | bool | custody, |
const oc_endpoint_t * | endpoint, | ||
uint16_t | timeout_seconds, | ||
oc_response_handler_t | handler, | ||
void * | user_data | ||
) |
send CoAP ping over the TCP connection
custody | custody on/off |
endpoint | endpoint to be used |
timeout_seconds | timeout for the ping |
handler | the response handler |
user_data | the user data to be conveyed to the response handler |
void oc_stop_multicast | ( | oc_client_response_t * | response | ) |
stop the multicast update (e.g.
do not handle the responses)
[in] | response | the response that should not be handled. |
bool oc_stop_observe | ( | const char * | uri, |
const oc_endpoint_t * | endpoint | ||
) |
Unsubscribe for notifications from a resource.
[in] | uri | the uri of the resource being observed |
[in] | endpoint | the endpoint of the server |