KNX IoT
KNX IoT Point API stack implementation
|
Client side support functions. More...
Functions | |
void | oc_close_session (oc_endpoint_t *endpoint) |
close the tls session on the indicated endpoint More... | |
bool | oc_do_delete (const char *uri, 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_get (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data) |
issues a get request with accept-content CBOR More... | |
bool | oc_do_get_ex (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, oc_content_format_t content, oc_content_format_t accept, void *user_data) |
Issue a GET request to obtain the current value of all properties a resource. More... | |
bool | oc_do_multicast_update (void) |
initiate the multi-cast update More... | |
bool | oc_do_observe (const char *uri, 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 wiht content type and accept type CBOR. More... | |
bool | oc_do_post_ex (oc_content_format_t content, oc_content_format_t accept) |
Dispatch the CoAP POST request. More... | |
bool | oc_do_put (void) |
Dispatch the CoAP PUT request wiht content type and accept type CBOR. More... | |
bool | oc_do_put_ex (oc_content_format_t content, oc_content_format_t accept) |
Dispatch the CoAP PUT request. More... | |
bool | oc_do_wk_discovery_all (const char *uri_query, int scope, oc_discovery_all_handler_t handler, void *user_data) |
Discover all servers that have a resource type using the 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_multicast_update (oc_endpoint_t *mcast, const char *uri, const char *query) |
initialize the multicast update More... | |
bool | oc_init_post (const char *uri, 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, 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... | |
int | oc_lf_get_entry_param (const char *payload, int payload_len, int entry, const char *param, const char **p_out, int *p_len) |
link format parser, retrieve a parameter value More... | |
int | oc_lf_get_entry_uri (const char *payload, int payload_len, int entry, const char **uri, int *uri_len) |
link format parser, retrieve the URL of an entry. More... | |
int | oc_lf_number_of_entries (const char *payload, int payload_len) |
link format parser, retrieve the number of entries in a response More... | |
bool | oc_send_ping (bool custody, 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, oc_endpoint_t *endpoint) |
Unsubscribe for notifications from a resource. More... | |
Client side support functions.
This module contains functions to communicate to a KNX server for an Client.
The multicast communication is for:
The multicast Discovery is issued is on CoAP .well-known/core The s-mode communication is performed at the (specific) group addresses.
The following functions can be used to communicate on CoAP level e.g. issuing:
void oc_close_session | ( | oc_endpoint_t * | endpoint | ) |
close the tls session on the indicated endpoint
endpoint | endpoint indicating a session |
bool oc_do_delete | ( | const char * | uri, |
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 | The function invoked once the client has received the servers response to the DELETE request |
[in] | qos | The quality of service current options are HIGH_QOS or LOW_QOS |
[in] | user_data | The context pointer that will be sent to the oc_response_handler_t |
bool oc_do_get | ( | const char * | uri, |
oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
void * | user_data | ||
) |
issues a get request with accept-content CBOR
uri | the uri to be used |
endpoint | the endpoint of the device |
query | the query |
handler | the callback handler |
qos | the qos type confirmable / not confirmable |
user_data | the user data |
bool oc_do_get_ex | ( | const char * | uri, |
oc_endpoint_t * | endpoint, | ||
const char * | query, | ||
oc_response_handler_t | handler, | ||
oc_qos_t | qos, | ||
oc_content_format_t | content, | ||
oc_content_format_t | accept, | ||
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] | content | The content format of the request payload |
[in] | accept | The content format of the response payload |
[in] | user_data | context pointer that will be sent to the oc_response_handler_t |
bool oc_do_multicast_update | ( | void | ) |
initiate the multi-cast update
bool oc_do_observe | ( | const char * | uri, |
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 wiht content type and accept type CBOR.
bool oc_do_post_ex | ( | oc_content_format_t | content, |
oc_content_format_t | accept | ||
) |
Dispatch the CoAP POST request.
content | The content format of the request payload |
accept | The content format of the response payload |
bool oc_do_put | ( | void | ) |
Dispatch the CoAP PUT request wiht content type and accept type CBOR.
bool oc_do_put_ex | ( | oc_content_format_t | content, |
oc_content_format_t | accept | ||
) |
Dispatch the CoAP PUT request.
content | The content format of the request payload |
accept | The content format of the response payload |
bool oc_do_wk_discovery_all | ( | const char * | uri_query, |
int | scope, | ||
oc_discovery_all_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 multi-cast request to the IPv6 scope
multi-cast address scope. The address scope is the domain in which the multi-cast discovery packet should be propagated.
Read RFC4291 and RFC7346 for more information about IPv6 Reference Scopes.
[in] | uri_query | the query to be added the .well-known/core URI. |
[in] | scope | the scope of the request, for example: 0x2 |
[in] | handler | the oc_discovery_all_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. |
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_multicast_update | ( | oc_endpoint_t * | mcast, |
const char * | uri, | ||
const char * | query | ||
) |
initialize the multicast update
mcast | the multicast address to be used |
uri | the uri to be used |
query | the query of uri |
bool oc_init_post | ( | const char * | uri, |
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, |
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 |
int oc_lf_get_entry_param | ( | const char * | payload, |
int | payload_len, | ||
int | entry, | ||
const char * | param, | ||
const char ** | p_out, | ||
int * | p_len | ||
) |
link format parser, retrieve a parameter value
payload | The link-format response |
payload_len | The length of the response |
entry | The index of entries, starting with 0. |
param | The query parameter, e.g. "rt" |
p_out | The pointer to store the value, e.g. "blah" |
p_len | The length of the URI |
int oc_lf_get_entry_uri | ( | const char * | payload, |
int | payload_len, | ||
int | entry, | ||
const char ** | uri, | ||
int * | uri_len | ||
) |
link format parser, retrieve the URL of an entry.
payload | The link-format response |
payload_len | The length of the response |
entry | The index of entries, starting with 0. |
uri | The pointer to store the URI |
uri_len | The length of the URI |
int oc_lf_number_of_entries | ( | const char * | payload, |
int | payload_len | ||
) |
link format parser, retrieve the number of entries in a response
payload | The link-format response |
payload_len | The length of the response |
bool oc_send_ping | ( | bool | custody, |
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, |
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 |