KNX IoT
KNX IoT Point API stack implementation
Server side

Group of server support functions. More...

Functions

bool oc_add_resource (oc_resource_t *resource)
 Add a resource to the stack. More...
 
void oc_delayed_delete_resource (oc_resource_t *resource)
 Schedule a callback to remove a resource. More...
 
bool oc_delete_resource (oc_resource_t *resource)
 Remove a resource from the stack and delete the resource. More...
 
bool oc_get_diagnostic_message (oc_client_response_t *response, const char **msg, size_t *size)
 retrieve the diagnostic payload from a response More...
 
int oc_get_query_value (oc_request_t *request, const char *key, char **value)
 Get a pointer to the start of the value in a URL query parameter key=value pair. More...
 
bool oc_get_request_payload_raw (oc_request_t *request, const uint8_t **payload, size_t *size, oc_content_format_t *content_format)
 retrieve the payload from the request, no processing More...
 
bool oc_get_response_payload_raw (oc_client_response_t *response, const uint8_t **payload, size_t *size, oc_content_format_t *content_format)
 retrieve the response payload, without processing More...
 
void oc_ignore_request (oc_request_t *request)
 Ignore the request. More...
 
void oc_indicate_separate_response (oc_request_t *request, oc_separate_response_t *response)
 Respond to an incoming request asynchronously. More...
 
void oc_init_query_iterator (void)
 This resets the query iterator to the start of the URI query parameter. More...
 
int oc_iterate_query (oc_request_t *request, char **key, size_t *key_len, char **value, size_t *value_len)
 Iterate through the URI query parameters and get each key=value pair. More...
 
bool oc_iterate_query_get_values (oc_request_t *request, const char *key, char **value, int *value_len)
 Iterate though the URI query parameters for a specific key. More...
 
oc_resource_toc_new_resource (const char *name, const char *uri, uint8_t num_resource_types, size_t device)
 Allocate and populate a new oc_resource_t. More...
 
int oc_notify_observers (const oc_resource_t *resource)
 Notify all observers of a change to a given resource's property. More...
 
int oc_query_value_exists (oc_request_t *request, const char *key)
 Checks if a query parameter 'key' exist in the URL query parameter. More...
 
bool oc_query_values_available (oc_request_t *request)
 Checks if a query parameter are available. More...
 
void oc_resource_bind_content_type (oc_resource_t *resource, oc_content_format_t content_type)
 set the content type on the resource More...
 
void oc_resource_bind_dpt (oc_resource_t *resource, const char *dpt)
 Add a Data Point Type "dpt" property to the resource. More...
 
void oc_resource_bind_resource_interface (oc_resource_t *resource, oc_interface_mask_t iface_mask)
 Add the supported interface(s) to the resource. More...
 
void oc_resource_bind_resource_type (oc_resource_t *resource, const char *type)
 Add a Resource Type "rt" property to the resource. More...
 
void oc_resource_make_public (oc_resource_t *resource)
 Expose unsecured coap:// endpoints (in addition to secured coaps:// endpoints) for this resource in /well-known/core. More...
 
void oc_resource_set_discoverable (oc_resource_t *resource, bool state)
 Specify if a resource can be found using .well-known/core discover mechanisms. More...
 
void oc_resource_set_function_block_instance (oc_resource_t *resource, uint8_t instance)
 set a resource to a specific function block instance default is instance 0, if there is just 1 instance of the function block this function does not have to be called. More...
 
void oc_resource_set_observable (oc_resource_t *resource, bool state)
 Specify that a resource should notify clients when a property has been modified. More...
 
void oc_resource_set_periodic_observable (oc_resource_t *resource, uint16_t seconds)
 The resource will periodically notify observing clients of is property values. More...
 
void oc_resource_set_properties_cbs (oc_resource_t *resource, oc_get_properties_cb_t get_properties, void *get_props_user_data, oc_set_properties_cb_t set_properties, void *set_props_user_data)
 sets the callback properties for set properties and get properties More...
 
void oc_resource_set_request_handler (oc_resource_t *resource, oc_method_t method, oc_request_callback_t callback, void *user_data)
 Specify a request_callback for GET, PUT, POST, and DELETE methods. More...
 
void oc_send_cbor_response (oc_request_t *request, oc_status_t response_code)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_cbor_response_with_payload_size (oc_request_t *request, oc_status_t response_code, size_t payload_size)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_diagnostic_message (oc_request_t *request, const char *msg, size_t msg_len, oc_status_t response_code)
 send a diagnostic payload More...
 
void oc_send_empty_separate_response (oc_separate_response_t *handle, oc_status_t response_code)
 Called to send the deferred response to a GET, PUT, POST or DELETE request, with an empty payload. More...
 
void oc_send_json_response (oc_request_t *request, oc_status_t response_code)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_linkformat_response (oc_request_t *request, oc_status_t response_code, size_t response_length)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_response (oc_request_t *request, oc_status_t response_code)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed, will respond with CBOR. More...
 
void oc_send_response_no_format (oc_request_t *request, oc_status_t response_code)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_response_raw (oc_request_t *request, const uint8_t *payload, size_t size, oc_content_format_t content_format, oc_status_t response_code)
 send the request, no processing More...
 
void oc_send_separate_response (oc_separate_response_t *handle, oc_status_t response_code)
 Called to send the deferred response to a GET, PUT, POST or DELETE request. More...
 
void oc_set_separate_response_buffer (oc_separate_response_t *handle)
 Set a response buffer for holding the response payload. More...
 

Detailed Description

Group of server support functions.

standardized data points

The standardized functions are implemented. The following groups are implemented:

all functions generate the core-link or CBOR formatted responses.

application specific data points

Applications have to define the functions (GET and PUT) for the application level data points. Applications have to define for each instance these functions. The functions are registered with the device and will be called when the other devices are interacting with it.

see for more details the examples.

Function Documentation

◆ oc_add_resource()

bool oc_add_resource ( oc_resource_t resource)

Add a resource to the stack.

The resource will be validated then added to the stack.

Parameters
[in]resourcethe resource to add to the stack
Returns
  • true: the resource was successfully added to the stack.
  • false: the resource can not be added to the stack.

◆ oc_delayed_delete_resource()

void oc_delayed_delete_resource ( oc_resource_t resource)

Schedule a callback to remove a resource.

Parameters
[in]resourcethe resource to delete

◆ oc_delete_resource()

bool oc_delete_resource ( oc_resource_t resource)

Remove a resource from the stack and delete the resource.

Any resource observers will automatically be removed.

This will free the memory associated with the resource.

Parameters
[in]resourcethe resource to delete
Returns
  • true: when the resource has been deleted and memory freed.
  • false: there was an issue deleting the resource.

◆ oc_get_diagnostic_message()

bool oc_get_diagnostic_message ( oc_client_response_t response,
const char **  msg,
size_t *  size 
)

retrieve the diagnostic payload from a response

Parameters
responsethe response to get the diagnostic payload from
msgthe diagnostic payload
sizethe size of the diagnostic payload
Returns
true - retrieved payload
false

◆ oc_get_query_value()

int oc_get_query_value ( oc_request_t request,
const char *  key,
char **  value 
)

Get a pointer to the start of the value in a URL query parameter key=value pair.

Note
The char pointer returned is pointing to the string location in the query string. Do not rely on a null terminator to find the end of the string since there may be additional query parameters.
Parameters
[in]requestthe oc_request_t that contains the query parameters
[in]keythe key being searched for
[out]valuepointer to the value string assigned to the key
Returns
  • The position in the query string of the next key=value string pair
  • -1 if there are no additional query parameters

◆ oc_get_request_payload_raw()

bool oc_get_request_payload_raw ( oc_request_t request,
const uint8_t **  payload,
size_t *  size,
oc_content_format_t content_format 
)

retrieve the payload from the request, no processing

Parameters
requestthe request
payloadthe payload of the request
sizethe size in bytes of the payload
content_formatthe content format of the payload
Returns
true
false

◆ oc_get_response_payload_raw()

bool oc_get_response_payload_raw ( oc_client_response_t response,
const uint8_t **  payload,
size_t *  size,
oc_content_format_t content_format 
)

retrieve the response payload, without processing

Parameters
responsethe response
payloadthe payload of the response
sizethe size of the payload
content_formatthe content format of the payload
Returns
true - retrieved payload
false

◆ oc_ignore_request()

void oc_ignore_request ( oc_request_t request)

Ignore the request.

The GET, PUT, POST or DELETE requests can be ignored. For example a oc_request_callback_t may only want to respond to multi-cast requests. Thus any request that is not over multi-cast endpoint could be ignored.

Using oc_ignore(request) is preferred over oc_send_response(request, OC_IGNORE) since it does not attempt to fill the response buffer before sending the response.

Parameters
[in]requestthe request being responded to
See also
oc_request_callback_t
oc_send_response

◆ oc_indicate_separate_response()

void oc_indicate_separate_response ( oc_request_t request,
oc_separate_response_t response 
)

Respond to an incoming request asynchronously.

If for some reason the response to a request would take a long time or is not immediately available, then this function may be used defer responding to the request.

Example:

static oc_separate_response_t sep_response;
handle_separate_response(void *data)
{
if (sep_response.active) {
printf("Handle separate response for GET handler:\n");
oc_rep_set_boolean(root, value, true);
oc_rep_set_int(root, dimmingSetting, 75);
}
}
static void
get_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
void *user_data)
{
printf("GET handler:\n");
oc_indicate_separate_response(request, &sep_response);
oc_set_delayed_callback(NULL, &handle_separate_response, 10);
}
void oc_set_delayed_callback(void *cb_data, oc_trigger_t callback, uint16_t seconds)
Schedule a callback to be invoked after a set number of seconds.
void oc_set_separate_response_buffer(oc_separate_response_t *handle)
Set a response buffer for holding the response payload.
void oc_send_separate_response(oc_separate_response_t *handle, oc_status_t response_code)
Called to send the deferred response to a GET, PUT, POST or DELETE request.
void oc_indicate_separate_response(oc_request_t *request, oc_separate_response_t *response)
Respond to an incoming request asynchronously.
#define oc_rep_set_boolean(object, key, value)
Add an boolean value to the cbor object under the key name Example:
Definition: oc_rep.h:353
#define oc_rep_end_root_object()
End the root object.
Definition: oc_rep.h:624
#define oc_rep_begin_root_object()
Begin the root object.
Definition: oc_rep.h:607
#define oc_rep_set_int(object, key, value)
Add an integer value to the cbor object under the key name Example:
Definition: oc_rep.h:249
@ OC_STATUS_OK
OK 2.00.
Definition: oc_ri.h:153
oc_event_callback_retval_t
callback return values
Definition: oc_ri.h:517
@ OC_EVENT_DONE
callback done, e.g.
Definition: oc_ri.h:518
oc_interface_mask_t
interface masks security access scopes defined as interfaces note that scope = 1 is not used.
Definition: oc_ri.h:261
struct oc_separate_response_s oc_separate_response_t
separate response type
Definition: oc_ri.h:238
request information structure
Definition: oc_ri.h:412
Parameters
[in]requestthe request that will be responded to as a separate response
[in]responseinstance of an internal struct that is used to track the state of the separate response.
See also
oc_set_separate_response_buffer
oc_send_separate_response

◆ oc_init_query_iterator()

void oc_init_query_iterator ( void  )

This resets the query iterator to the start of the URI query parameter.

This is used together with oc_iterate_query_get_values() or oc_iterate_query() to iterate through query parameter of a URI that are part of an oc_request_t

◆ oc_iterate_query()

int oc_iterate_query ( oc_request_t request,
char **  key,
size_t *  key_len,
char **  value,
size_t *  value_len 
)

Iterate through the URI query parameters and get each key=value pair.

Before calling oc_iterate_query() the first time oc_init_query_iterator() must be called to reset the query iterator to the first query parameter.

Note
the char pointers returned are pointing to the string location in the query string. Do not rely on a null terminator to find the end of the string since there may be additional query parameters.

Example:

char *value = NULL;
int value_len = -1;
char *key
while (oc_iterate_query(request, &key, &key_len, &value, &value_len) > 0) {
printf("%.*s = %.*s\n", key_len, key, query_value_len, query_value);
}
void oc_init_query_iterator(void)
This resets the query iterator to the start of the URI query parameter.
int oc_iterate_query(oc_request_t *request, char **key, size_t *key_len, char **value, size_t *value_len)
Iterate through the URI query parameters and get each key=value pair.
Parameters
[in]requestthe oc_request_t that contains the query parameters
[out]keypointer to the location of the key of the key=value pair
[out]key_lenthe length of the key string
[out]valuepointer the location of the value string assigned to the key=value pair
[out]value_lenthe length of the value string
Returns
  • The position in the query string of the next key=value string pair
  • -1 if there are no additional query parameters

◆ oc_iterate_query_get_values()

bool oc_iterate_query_get_values ( oc_request_t request,
const char *  key,
char **  value,
int *  value_len 
)

Iterate though the URI query parameters for a specific key.

Before calling oc_iterate_query_get_values() the first time oc_init_query_iterator() must be called to reset the query iterator to the first query parameter.

Note
The char pointer returned is pointing to the string location in the query string. Do not rely on a null terminator to find the end of the string since there may be additional query parameters.

Example:

bool more_query_params = false;
const char* expected_value = "world"
char *value = NULL;
int value_len = -1;
do {
more_query_params = oc_iterate_query_get_values(request, "hello",
&value, &value_len);
if (rt_len > 0) {
printf("Found %s = %.*s\n", "hello", value_len, value);
}
} while (more_query_params);
bool oc_iterate_query_get_values(oc_request_t *request, const char *key, char **value, int *value_len)
Iterate though the URI query parameters for a specific key.
Parameters
[in]requestthe oc_request_t that contains the query parameters
[in]keythe key being searched for
[out]valuepointer to the value string for to the key=value pair
[out]value_lenthe length of the value string
Returns
True if there are more query parameters to iterate through

◆ oc_new_resource()

oc_resource_t* oc_new_resource ( const char *  name,
const char *  uri,
uint8_t  num_resource_types,
size_t  device 
)

Allocate and populate a new oc_resource_t.

Resources are the primary interface between code and real world devices.

Each resource has a Uniform Resource Identifier (URI) that identifies it. All resources must specify one or more Resource Types to be considered a valid resource. The number of Resource Types is specified by the num_resource_types the actual Resource Types are added later using the oc_resource_bind_resource_type() function.

Many properties associated with a resource are set or modified after the new resource has been created.

The resource is not added to the device till oc_add_resource() is called.

Example:

static void register_resources(void)
{
oc_resource_t *bswitch = oc_new_resource("light switch", "/switch", 1, 0);
oc_resource_bind_resource_type(bswitch, "urn:knx:dpa.417.61");
oc_resource_bind_dpt(bswitch, "urn:knx:dpt.switch");
oc_resource_set_request_handler(bswitch, OC_GET, get_switch, NULL);
oc_resource_set_request_handler(bswitch, OC_POST, post_switch, NULL);
oc_resource_set_request_handler(bswitch, OC_PUT, put_switch, NULL);
oc_add_resource(bswitch);
}
void oc_resource_set_discoverable(oc_resource_t *resource, bool state)
Specify if a resource can be found using .well-known/core discover mechanisms.
oc_resource_t * oc_new_resource(const char *name, const char *uri, uint8_t num_resource_types, size_t device)
Allocate and populate a new oc_resource_t.
void oc_resource_bind_dpt(oc_resource_t *resource, const char *dpt)
Add a Data Point Type "dpt" property to the resource.
bool oc_add_resource(oc_resource_t *resource)
Add a resource to the stack.
void oc_resource_bind_resource_type(oc_resource_t *resource, const char *type)
Add a Resource Type "rt" property to the resource.
void oc_resource_bind_resource_interface(oc_resource_t *resource, oc_interface_mask_t iface_mask)
Add the supported interface(s) to the resource.
void oc_resource_set_observable(oc_resource_t *resource, bool state)
Specify that a resource should notify clients when a property has been modified.
void oc_resource_set_request_handler(oc_resource_t *resource, oc_method_t method, oc_request_callback_t callback, void *user_data)
Specify a request_callback for GET, PUT, POST, and DELETE methods.
void register_resources(void)
register all the resources to the stack this function registers all application level resources:
@ OC_POST
POST.
Definition: oc_ri.h:126
@ OC_PUT
PUT.
Definition: oc_ri.h:127
@ OC_GET
GET.
Definition: oc_ri.h:125
@ OC_IF_A
if.a (128)
Definition: oc_ri.h:269
resource structure
Definition: oc_ri.h:482
Parameters
[in]namethe name of the new resource this will set the property n
[in]urithe Uniform Resource Identifier for the resource
[in]num_resource_typesthe number of Resource Types that will be added/bound to the resource
[in]deviceindex of the logical device the resource will be added to
See also
oc_resource_bind_resource_interface
oc_resource_bind_resource_type
oc_resource_bind_dpt
oc_process_baseline_interface
oc_resource_set_discoverable
oc_resource_set_periodic_observable
oc_resource_set_request_handler

◆ oc_notify_observers()

int oc_notify_observers ( const oc_resource_t resource)

Notify all observers of a change to a given resource's property.

Note
no need to call oc_notify_observers about resource changes that result from a PUT, or POST oc_request_callback_t.
Parameters
[in]resourcethe oc_resource_t that has a modified property
Returns
  • the number observers notified on success
  • 0 on failure could also mean no registered observers

◆ oc_query_value_exists()

int oc_query_value_exists ( oc_request_t request,
const char *  key 
)

Checks if a query parameter 'key' exist in the URL query parameter.

Parameters
[in]requestthe oc_request_t that contains the query parameters
[in]keythe key being searched for
Returns
  • 1 exist
  • -1 does not exist

◆ oc_query_values_available()

bool oc_query_values_available ( oc_request_t request)

Checks if a query parameter are available.

Parameters
[in]requestthe oc_request_t that contains the query parameters
Returns
  • False no queries available
  • True queries available

◆ oc_resource_bind_content_type()

void oc_resource_bind_content_type ( oc_resource_t resource,
oc_content_format_t  content_type 
)

set the content type on the resource

Parameters
resourcethe resource
content_typethe content type

◆ oc_resource_bind_dpt()

void oc_resource_bind_dpt ( oc_resource_t resource,
const char *  dpt 
)

Add a Data Point Type "dpt" property to the resource.

Parameters
[in]resourcethe resource that the Data Point Type will be set on
[in]dptthe Data Point Type to add to the Data Point Type "dpt" property
See also
oc_new_resource
oc_device_bind_resource_type

◆ oc_resource_bind_resource_interface()

void oc_resource_bind_resource_interface ( oc_resource_t resource,
oc_interface_mask_t  iface_mask 
)

Add the supported interface(s) to the resource.

Resource interfaces specify how the code is able to interact with the resource

The iface_mask is bitwise OR of the interfaces

Parameters
[in]resourcethe resource that the interface(s) will be added to
[in]iface_maska bitwise ORed list of all interfaces supported by the resource.
See also
oc_interface_mask_t

◆ oc_resource_bind_resource_type()

void oc_resource_bind_resource_type ( oc_resource_t resource,
const char *  type 
)

Add a Resource Type "rt" property to the resource.

All resources require at least one Resource Type. The number of Resource Types the resource contains is declared when the resource it created using oc_new_resource() function.

Multi-value "rt" Resource means a resource with multiple Resource Types. i.e. oc_resource_bind_resource_type() is called multiple times for a single resource. When using a Multi-value Resource the different resources properties must not conflict.

Parameters
[in]resourcethe resource that the Resource Type will be set on
[in]typethe Resource Type to add to the Resource Type "rt" property
See also
oc_new_resource
oc_device_bind_resource_type

◆ oc_resource_make_public()

void oc_resource_make_public ( oc_resource_t resource)

Expose unsecured coap:// endpoints (in addition to secured coaps:// endpoints) for this resource in /well-known/core.

Note
While the resource may advertise unsecured endpoints, the resource shall remain inaccessible until the hosting device is configured with an anon-clear Access Control Entry (ACE).
Parameters
[in]resourcethe resource to make public
See also
oc_new_resource

◆ oc_resource_set_discoverable()

void oc_resource_set_discoverable ( oc_resource_t resource,
bool  state 
)

Specify if a resource can be found using .well-known/core discover mechanisms.

Parameters
[in]resourceto specify as discoverable or non-discoverable
[in]stateif true the resource will be discoverable if false the resource will be non-discoverable
See also
oc_new_resource for example code using this function

◆ oc_resource_set_function_block_instance()

void oc_resource_set_function_block_instance ( oc_resource_t resource,
uint8_t  instance 
)

set a resource to a specific function block instance default is instance 0, if there is just 1 instance of the function block this function does not have to be called.

Parameters
resourcethe resource
instancethe instance id.

◆ oc_resource_set_observable()

void oc_resource_set_observable ( oc_resource_t resource,
bool  state 
)

Specify that a resource should notify clients when a property has been modified.

Note
this function can be used to make a periodic observable resource unobservable.
Parameters
[in]resourcethe resource to specify the observability
[in]statetrue to make resource observable, false to make resource unobservable
See also
oc_new_resource to see example code using this function
oc_resource_set_periodic_observable

◆ oc_resource_set_periodic_observable()

void oc_resource_set_periodic_observable ( oc_resource_t resource,
uint16_t  seconds 
)

The resource will periodically notify observing clients of is property values.

The oc_resource_set_observable() function can be used to turn off a periodic observable resource.

Setting a seconds frequency of zero 0 is invalid and will result in an invalid resource.

Parameters
[in]resourcethe resource to specify the periodic observability
[in]secondsthe frequency in seconds that the resource will send out an notification of is property values.

◆ oc_resource_set_properties_cbs()

void oc_resource_set_properties_cbs ( oc_resource_t resource,
oc_get_properties_cb_t  get_properties,
void *  get_props_user_data,
oc_set_properties_cb_t  set_properties,
void *  set_props_user_data 
)

sets the callback properties for set properties and get properties

Parameters
resourcethe resource for the callback data
get_propertiescallback function for retrieving the properties
get_props_user_datathe user data for the get_properties callback function
set_propertiescallback function for setting the properties
set_props_user_datathe user data for the set_properties callback function

◆ oc_resource_set_request_handler()

void oc_resource_set_request_handler ( oc_resource_t resource,
oc_method_t  method,
oc_request_callback_t  callback,
void *  user_data 
)

Specify a request_callback for GET, PUT, POST, and DELETE methods.

All resources must provide at least one request handler to be a valid resource.

method types:

  • OC_GET the oc_request_callback_t is responsible for returning the current value of all of the resource properties.
  • OC_PUT the oc_request_callback_t is responsible for updating one or more of the resource properties.
  • OC_POST the oc_request_callback_t is responsible for updating one or more of the resource properties. The callback may also be responsible for creating new resources.
  • OC_DELETE the oc_request_callback_t is responsible for deleting a resource
Note
Some methods may never by invoked based on the resources Interface as well as the provisioning permissions of the client.
Parameters
[in]resourcethe resource the callback handler will be registered to
[in]methodspecify if type method the callback is responsible for handling
[in]callbackthe callback handler that will be invoked when a the method is called on the resource.
[in]user_datacontext pointer that is passed to the oc_request_callback_t. The pointer must remain valid as long as the resource exists.
See also
oc_new_resource to see example code using this function

◆ oc_send_cbor_response()

void oc_send_cbor_response ( oc_request_t request,
oc_status_t  response_code 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed.

will respond with CBOR as content type.

The function oc_send_response is called at the end of a oc_request_callback_t to inform the caller about the status of the requested action.

Note that OC_STATUS_BAD_REQUEST for multicast will not send a response (e.g. threated as OC_IGNORE)

Parameters
requestthe request being responded to
response_codethe status of the response

◆ oc_send_cbor_response_with_payload_size()

void oc_send_cbor_response_with_payload_size ( oc_request_t request,
oc_status_t  response_code,
size_t  payload_size 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed.

will respond with CBOR.

The function oc_send_response is called at the end of a oc_request_callback_t to inform the caller about the status of the requested action.

Note that OC_STATUS_BAD_REQUEST for multicast will not send a response (e.g. threated as OC_IGNORE)

Parameters
requestthe request being responded to
response_codethe status of the response
payload_sizethe payload size of the response

◆ oc_send_diagnostic_message()

void oc_send_diagnostic_message ( oc_request_t request,
const char *  msg,
size_t  msg_len,
oc_status_t  response_code 
)

send a diagnostic payload

Parameters
requestthe request
msgthe message in ASCII
msg_lenthe length of the message
response_codethe CoAP response code

◆ oc_send_empty_separate_response()

void oc_send_empty_separate_response ( oc_separate_response_t handle,
oc_status_t  response_code 
)

Called to send the deferred response to a GET, PUT, POST or DELETE request, with an empty payload.

The function oc_send_empty_separate_response is called to initiate transfer of the response.

Parameters
[in]handleinstance of the internal struct that was passed to oc_indicate_separate_response()
[in]response_codethe status of the response
See also
oc_indicate_separate_response
oc_send_separate_response
oc_send_response
oc_ignore_request

◆ oc_send_json_response()

void oc_send_json_response ( oc_request_t request,
oc_status_t  response_code 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed.

will respond with JSON.

The function oc_send_response is called at the end of a oc_request_callback_t to inform the caller about the status of the requested action.

Note that OC_STATUS_BAD_REQUEST for multicast will not send a response (e.g. threated as OC_IGNORE)

Parameters
requestthe request being responded to
response_codethe request being responded to

◆ oc_send_linkformat_response()

void oc_send_linkformat_response ( oc_request_t request,
oc_status_t  response_code,
size_t  response_length 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed.

will respond with LINK-FORMAT.

Note that OC_STATUS_BAD_REQUEST for multicast will not send a response (e.g. threated as OC_IGNORE)

Parameters
requestthe request being responded to
response_codethe request being responded to
response_lengththe framed response length

◆ oc_send_response()

void oc_send_response ( oc_request_t request,
oc_status_t  response_code 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed, will respond with CBOR.

The function oc_send_response is called at the end of a oc_request_callback_t to inform the caller about the status of the requested action.

Parameters
[in]requestthe request being responded to
[in]response_codethe status of the response
See also
oc_request_callback_t
oc_ignore_request
oc_indicate_separate_response

◆ oc_send_response_no_format()

void oc_send_response_no_format ( oc_request_t request,
oc_status_t  response_code 
)

Called after the response to a GET, PUT, POST or DELETE call has been prepared completed.

will respond without setting the content format.

Example usecase: When the response has empty payload.

Parameters
requestthe request being responded to
response_codethe request being responded to

◆ oc_send_response_raw()

void oc_send_response_raw ( oc_request_t request,
const uint8_t *  payload,
size_t  size,
oc_content_format_t  content_format,
oc_status_t  response_code 
)

send the request, no processing

Parameters
requestthe request to send
payloadthe payload for the request
sizethe payload size
content_formatthe content format
response_codethe response code to send

◆ oc_send_separate_response()

void oc_send_separate_response ( oc_separate_response_t handle,
oc_status_t  response_code 
)

Called to send the deferred response to a GET, PUT, POST or DELETE request.

The function oc_send_separate_response is called to initiate transfer of the response.

Parameters
[in]handleinstance of the internal struct that was passed to oc_indicate_separate_response()
[in]response_codethe status of the response
See also
oc_indicate_separate_response
oc_send_separate_response
oc_send_response
oc_ignore_request

◆ oc_set_separate_response_buffer()

void oc_set_separate_response_buffer ( oc_separate_response_t handle)

Set a response buffer for holding the response payload.

When a deferred response is ready, pass in the same oc_separate_response_t that was handed to oc_indicate_separate_response() for delaying the initial response.

Parameters
[in]handleinstance of the oc_separate_response_t that was passed to the oc_indicate_separate_response() function
See also
oc_indicate_separate_response
oc_send_separate_response