87 #include "messaging/coap/oc_coap.h"
108 #define OC_MAX_URL_LENGTH (30)
149 void (*signal_event_loop)(void);
214 void (*requests_entry)(void);
502 #define oc_set_custom_device_property(prop, value) \
503 oc_rep_set_text_string(root, prop, value)
541 #define oc_set_custom_platform_property(prop, value) \
542 oc_rep_set_text_string(root, prop, value)
619 uint8_t num_resource_types,
size_t device);
786 void *get_props_user_data,
788 void *set_props_user_data);
878 char **value,
size_t *value_len);
915 char **value,
int *value_len);
1009 size_t payload_size);
1040 size_t response_length);
1092 const uint8_t **payload,
size_t *size,
1329 const char **uri,
int *uri_len);
1343 const char *param,
const char **p_out,
int *p_len);
1699 uint16_t miliseconds);
1711 #define oc_signal_interrupt_handler(name) \
1713 oc_process_poll(&(name##_interrupt_x)); \
1714 _oc_signal_event_loop(); \
1718 #define oc_activate_interrupt_handler(name) \
1719 (oc_process_start(&(name##_interrupt_x), 0))
1722 #define oc_define_interrupt_handler(name) \
1723 void name##_interrupt_x_handler(void); \
1724 OC_PROCESS(name##_interrupt_x, ""); \
1725 OC_PROCESS_THREAD(name##_interrupt_x, ev, data) \
1728 OC_PROCESS_POLLHANDLER(name##_interrupt_x_handler()); \
1729 OC_PROCESS_BEGIN(); \
1730 while (oc_process_is_running(&(name##_interrupt_x))) { \
1731 OC_PROCESS_YIELD(); \
1735 void name##_interrupt_x_handler(void)
void oc_stop_multicast(oc_client_response_t *response)
stop the multicast update (e.g.
int oc_lf_number_of_entries(const char *payload, int payload_len)
link format parser, retrieve the number of entries in a 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
bool oc_do_multicast_update(void)
initiate the multi-cast update
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.
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
bool oc_do_put_ex(oc_content_format_t content, oc_content_format_t accept)
Dispatch the CoAP PUT request.
void oc_close_session(oc_endpoint_t *endpoint)
close the tls session on the indicated endpoint
bool oc_init_multicast_update(oc_endpoint_t *mcast, const char *uri, const char *query)
initialize the multicast update
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.
bool oc_do_put(void)
Dispatch the CoAP PUT request wiht content type and accept type CBOR.
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.
bool oc_do_post_ex(oc_content_format_t content, oc_content_format_t accept)
Dispatch the CoAP POST request.
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.
bool oc_stop_observe(const char *uri, oc_endpoint_t *endpoint)
Unsubscribe for notifications from a resource.
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.
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.
void oc_free_server_endpoints(oc_endpoint_t *endpoint)
Free a list of endpoints from the oc_endpoint_t.
bool oc_do_post(void)
Dispatch the CoAP POST request wiht content type and accept type CBOR.
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
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.
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_delayed_callback_ms(void *cb_data, oc_trigger_t callback, uint16_t miliseconds)
Schedule a callback to be invoked after a set number of miliseconds.
void oc_remove_delayed_callback(void *cb_data, oc_trigger_t callback)
used to cancel a delayed callback
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 instan...
int oc_notify_observers(const oc_resource_t *resource)
Notify all observers of a change to a given resource's property.
void oc_set_separate_response_buffer(oc_separate_response_t *handle)
Set a response buffer for holding the response payload.
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.
void oc_resource_set_discoverable(oc_resource_t *resource, bool state)
Specify if a resource can be found using .well-known/core discover mechanisms.
void oc_init_query_iterator(void)
This resets the query iterator to the start of the URI query parameter.
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_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,...
bool oc_get_diagnostic_message(oc_client_response_t *response, const char **msg, size_t *size)
retrieve the diagnostic payload from a response
void oc_resource_bind_content_type(oc_resource_t *resource, oc_content_format_t content_type)
set the content type on the resource
void oc_resource_bind_dpt(oc_resource_t *resource, const char *dpt)
Add a Data Point Type "dpt" property to the resource.
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.
bool oc_delete_resource(oc_resource_t *resource)
Remove a resource from the stack and delete the resource.
bool oc_add_resource(oc_resource_t *resource)
Add a resource to the stack.
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.
int oc_query_value_exists(oc_request_t *request, const char *key)
Checks if a query parameter 'key' exist in the URL query parameter.
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.
void oc_resource_make_public(oc_resource_t *resource)
Expose unsecured coap:// endpoints (in addition to secured coaps:// endpoints) for this resource in /...
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.
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.
void oc_resource_bind_resource_type(oc_resource_t *resource, const char *type)
Add a Resource Type "rt" property to the resource.
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
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_delayed_delete_resource(oc_resource_t *resource)
Schedule a callback to remove a resource.
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.
void oc_ignore_request(oc_request_t *request)
Ignore the request.
bool oc_query_values_available(oc_request_t *request)
Checks if a query parameter are available.
void oc_resource_set_periodic_observable(oc_resource_t *resource, uint16_t seconds)
The resource will periodically notify observing clients of is property values.
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
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.
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
void oc_indicate_separate_response(oc_request_t *request, oc_separate_response_t *response)
Respond to an incoming request asynchronously.
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
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 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
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.
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.
void register_resources(void)
register all the resources to the stack this function registers all application level resources:
int oc_add_device(const char *name, const char *version, const char *base, const char *serial_number, oc_add_device_cb_t add_device_cb, void *data)
Add an a device to the stack.
void oc_set_reset_cb(oc_reset_cb_t cb, void *data)
Set the reset callback.
void(* oc_programming_mode_cb_t)(size_t device, bool programming_mode, void *data)
Set the programming mode callback NOTE: It is the responsibility of this callback (if registered),...
void(* oc_init_platform_cb_t)(void *data)
Callback invoked during oc_init_platform().
void oc_set_restart_cb(oc_restart_cb_t cb, void *data)
Set the restart callback.
void(* oc_add_device_cb_t)(void *data)
Callback invoked during oc_add_device().
void oc_set_factory_presets_cb(oc_factory_presets_cb_t cb, void *data)
Set the factory presets callback.
void oc_main_shutdown(void)
Shutdown and free all stack related resources.
void oc_set_programming_mode_cb(oc_programming_mode_cb_t cb, void *data)
Set the programming mode callback.
int oc_init_platform(const char *mfg_name, oc_init_platform_cb_t init_platform_cb, void *data)
Initialize the platform.
void(* oc_restart_cb_t)(size_t device, void *data)
Callback invoked by the stack to invoke a restart.
void(* oc_hostname_cb_t)(size_t device, oc_string_t host_name, void *data)
Callback invoked by the stack to set the host name.
oc_clock_time_t oc_main_poll(void)
poll to process tasks
int oc_main_init(const oc_handler_t *handler)
Register and call handler functions responsible for controlling the stack.
void(* oc_reset_cb_t)(size_t device, int reset_value, void *data)
Callback invoked by the stack initialization to perform any application reset.
void(* oc_factory_presets_cb_t)(size_t device, void *data)
Callback invoked by the stack initialization to perform any "factory settings", e....
void oc_set_hostname_cb(oc_hostname_cb_t cb, void *data)
Set the host name callback.
CoAP message buffer setting implementation.
oc_qos_t
Quality of Service.
oc_discovery_flags_t(* oc_discovery_all_handler_t)(const char *, int len, oc_endpoint_t *endpoint, void *)
discovery_all handler
void(* oc_response_handler_t)(oc_client_response_t *)
client response handler
implementation of /.well-known/knx and /k resources
client code for the device (s-mode)
request and response payload handling in cbor
oc_status_t
CoAP status codes.
oc_content_format_t
payload content formats
oc_interface_mask_t
interface masks security access scopes defined as interfaces note that scope = 1 is not used.
struct oc_separate_response_s oc_separate_response_t
separate response type
void(* oc_request_callback_t)(oc_request_t *, oc_interface_mask_t, void *)
request callback
void(* oc_get_properties_cb_t)(oc_resource_t *, oc_interface_mask_t, void *)
get properties callback
bool(* oc_set_properties_cb_t)(oc_resource_t *, oc_rep_t *, void *)
set properties callback
platform abstraction for storage (e.g.
Client response information.
Call back handlers that are invoked in response to oc_main_init()
request information structure