IoTivity-Lite
|
#include "messaging/coap/constants.h"
#include "oc_config.h"
#include "oc_endpoint.h"
#include "oc_enums.h"
#include "oc_export.h"
#include "oc_rep.h"
#include "oc_uuid.h"
#include "port/oc_clock.h"
#include "util/oc_features.h"
#include "util/oc_compiler.h"
#include <stdbool.h>
Data Structures | |
struct | oc_properties_cb_t |
properties callback structure More... | |
struct | oc_request_handler_s |
request handler type More... | |
struct | oc_request_t |
request information structure More... | |
struct | oc_resource_s |
resource structure More... | |
Macros | |
#define | OC_NUM_CORE_RESOURCES_PER_DEVICE (1 + OCF_D) |
#define | oc_ri_add_timed_event_callback_seconds(cb_data, event_callback, seconds) |
add timed event callback in seconds | |
Typedefs | |
typedef struct oc_collection_s | oc_collection_t |
typedef void(* | oc_get_properties_cb_t) (const oc_resource_t *, oc_interface_mask_t, void *) |
get properties callback More... | |
typedef void(* | oc_payload_callback_t) (void) |
application should define this callback which builds updated contents of pushable Resource More... | |
typedef struct oc_properties_cb_t | oc_properties_cb_t |
properties callback structure More... | |
typedef void(* | oc_request_callback_t) (oc_request_t *, oc_interface_mask_t, void *) |
request callback More... | |
typedef struct oc_request_handler_s | oc_request_handler_t |
request handler type More... | |
typedef struct oc_request_t | oc_request_t |
request information structure More... | |
typedef struct oc_resource_s | oc_resource_t |
typedef struct oc_response_s | oc_response_t |
response type More... | |
typedef void(* | oc_ri_delete_resource_cb_t) (oc_resource_t *resource) |
Callback invoked on resource before it is deleted by oc_delayed_delete_resource. More... | |
typedef bool(* | oc_ri_timed_event_filter_t) (const void *cb_data, const void *filter_data) |
Filtering function used to match scheduled timed events by context data. More... | |
typedef void(* | oc_ri_timed_event_on_delete_t) (void *cb_data) |
Function invoked with timed event context data before the timed event is deallocated. More... | |
typedef struct oc_separate_response_s | oc_separate_response_t |
seperate response type More... | |
typedef bool(* | oc_set_properties_cb_t) (const oc_resource_t *, const oc_rep_t *, void *) |
set properties callback More... | |
typedef oc_event_callback_retval_t(* | oc_trigger_t) (void *) |
Functions | |
int | oc_coap_status_to_status (coap_status_t status) |
convert the CoAP status code to status code More... | |
const char * | oc_method_to_str (oc_method_t method) |
Convert method to string. More... | |
bool | oc_ri_add_resource (oc_resource_t *resource) |
add resource to the system More... | |
void | oc_ri_add_timed_event_callback_ticks (void *cb_data, oc_trigger_t event_callback, oc_clock_time_t ticks) |
add timed event callback More... | |
bool | oc_ri_delete_resource (oc_resource_t *resource) |
remove the resource from the list of application resources More... | |
oc_resource_t * | oc_ri_get_app_resource_by_uri (const char *uri, size_t uri_len, size_t device) |
retrieve the resource by uri and device index More... | |
oc_resource_t * | oc_ri_get_app_resources (void) |
retrieve list of resources More... | |
oc_interface_mask_t | oc_ri_get_interface_mask (const char *iface, size_t iface_len) |
retrieve the interface mask from the interface name More... | |
int | oc_ri_get_query_nth_key_value (const char *query, size_t query_len, const char **key, size_t *key_len, const char **value, size_t *value_len, size_t n) |
retrieve the query value at the nth position More... | |
int | oc_ri_get_query_value (const char *query, size_t query_len, const char *key, const char **value) |
retrieve the value of the query parameter "key" More... | |
int | oc_ri_get_query_value_v1 (const char *query, size_t query_len, const char *key, size_t key_len, const char **value) |
retrieve the value of the query parameter "key" More... | |
bool | oc_ri_has_timed_event_callback (const void *cb_data, oc_trigger_t event_callback, bool ignore_cb_data) |
check if the timed event callback already exists. More... | |
bool | oc_ri_is_app_resource_to_be_deleted (const oc_resource_t *resource) |
Check if the resource has been scheduled to by deleted by oc_delayed_delete_resource. More... | |
bool | oc_ri_is_app_resource_valid (const oc_resource_t *resource) |
checks if the resource is valid More... | |
bool | oc_ri_on_delete_resource_add_callback (oc_ri_delete_resource_cb_t cb) |
Add to the global list of callbacks invoked by oc_delayed_delete_resource before each resource is deleted. More... | |
bool | oc_ri_on_delete_resource_remove_callback (oc_ri_delete_resource_cb_t cb) |
Remove callback from the list of callbacks invoked by oc_delayed_delete_resource. More... | |
int | oc_ri_query_exists (const char *query, size_t query_len, const char *key) |
Checks if key exist in query. More... | |
bool | oc_ri_query_exists_v1 (const char *query, size_t query_len, const char *key, size_t key_len) |
Checks if key exist in query. More... | |
int | oc_ri_query_nth_key_exists (const char *query, size_t query_len, const char **key, size_t *key_len, size_t n) |
check if the nth key exists More... | |
void | oc_ri_remove_timed_event_callback (const void *cb_data, oc_trigger_t event_callback) |
remove the timed event callback More... | |
void | oc_ri_remove_timed_event_callback_by_filter (oc_trigger_t cb, oc_ri_timed_event_filter_t filter, const void *filter_data, bool match_all, oc_ri_timed_event_on_delete_t on_delete) |
remove the timed event callback by filter More... | |
int | oc_status_code (oc_status_t key) |
convert the status code to CoAP status code More... | |
const char * | oc_status_to_str (oc_status_t key) |
Convert the status code to string. More... | |
#define oc_ri_add_timed_event_callback_seconds | ( | cb_data, | |
event_callback, | |||
seconds | |||
) |
add timed event callback in seconds
cb_data | the timed event callback info |
event_callback | the callback |
seconds | time in seconds |
typedef void(* oc_get_properties_cb_t) (const oc_resource_t *, oc_interface_mask_t, void *) |
get properties callback
typedef void(* oc_payload_callback_t) (void) |
application should define this callback which builds updated contents of pushable Resource
typedef struct oc_properties_cb_t oc_properties_cb_t |
properties callback structure
typedef void(* oc_request_callback_t) (oc_request_t *, oc_interface_mask_t, void *) |
request callback
typedef struct oc_request_handler_s oc_request_handler_t |
request handler type
typedef struct oc_request_t oc_request_t |
request information structure
typedef struct oc_response_s oc_response_t |
response type
typedef void(* oc_ri_delete_resource_cb_t) (oc_resource_t *resource) |
Callback invoked on resource before it is deleted by oc_delayed_delete_resource.
resource | Resource to be deleted |
typedef bool(* oc_ri_timed_event_filter_t) (const void *cb_data, const void *filter_data) |
Filtering function used to match scheduled timed events by context data.
cb_data | Data for the timed event callback |
filter_data | User data passed from the caller to the filtering function |
typedef void(* oc_ri_timed_event_on_delete_t) (void *cb_data) |
Function invoked with timed event context data before the timed event is deallocated.
typedef struct oc_separate_response_s oc_separate_response_t |
seperate response type
typedef bool(* oc_set_properties_cb_t) (const oc_resource_t *, const oc_rep_t *, void *) |
set properties callback
enum oc_content_format_t |
payload content formats
https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#rd-parameters
enum oc_interface_mask_t |
interface masks
enum oc_method_t |
resource properties (bit mask)
enum oc_status_t |
response status can be translated to HTTP or CoAP.
int oc_coap_status_to_status | ( | coap_status_t | status | ) |
convert the CoAP status code to status code
status | CoAP status code |
const char* oc_method_to_str | ( | oc_method_t | method | ) |
Convert method to string.
It is thread safe.
bool oc_ri_add_resource | ( | oc_resource_t * | resource | ) |
add resource to the system
resource | the resource to be added to the list of application resources |
void oc_ri_add_timed_event_callback_ticks | ( | void * | cb_data, |
oc_trigger_t | event_callback, | ||
oc_clock_time_t | ticks | ||
) |
add timed event callback
cb_data | the timed event callback info |
event_callback | the callback (cannot be NULL) |
ticks | time in ticks |
bool oc_ri_delete_resource | ( | oc_resource_t * | resource | ) |
remove the resource from the list of application resources
resource | the resource to be removed from the list of application resources |
oc_resource_t* oc_ri_get_app_resource_by_uri | ( | const char * | uri, |
size_t | uri_len, | ||
size_t | device | ||
) |
retrieve the resource by uri and device index
uri | the uri of the resource |
uri_len | the length of the uri |
device | the device index |
oc_resource_t* oc_ri_get_app_resources | ( | void | ) |
retrieve list of resources
oc_interface_mask_t oc_ri_get_interface_mask | ( | const char * | iface, |
size_t | iface_len | ||
) |
retrieve the interface mask from the interface name
iface | the interface string (e.g. "oic.if.s", cannot be NULL) |
iface_len | length of the interface string |
int oc_ri_get_query_nth_key_value | ( | const char * | query, |
size_t | query_len, | ||
const char ** | key, | ||
size_t * | key_len, | ||
const char ** | value, | ||
size_t * | value_len, | ||
size_t | n | ||
) |
retrieve the query value at the nth position
query | the input query | |
query_len | the query length | |
[out] | key | the key (cannot be NULL) |
[out] | key_len | the length of the key (cannot be NULL) |
[out] | value | the value belonging to the key |
[out] | value_len | the length of the value |
n | the position to query (must be > 0) |
int oc_ri_get_query_value | ( | const char * | query, |
size_t | query_len, | ||
const char * | key, | ||
const char ** | value | ||
) |
retrieve the value of the query parameter "key"
int oc_ri_get_query_value_v1 | ( | const char * | query, |
size_t | query_len, | ||
const char * | key, | ||
size_t | key_len, | ||
const char ** | value | ||
) |
retrieve the value of the query parameter "key"
query | the input query |
query_len | the query length |
key | the wanted key (cannot be NULL) |
key_len | the length of the wanted key |
value | the returned value |
bool oc_ri_has_timed_event_callback | ( | const void * | cb_data, |
oc_trigger_t | event_callback, | ||
bool | ignore_cb_data | ||
) |
check if the timed event callback already exists.
Iterate through the list of timed event callbacks and check if a matching item is found. To match: 1) function pointers must be equal 2) the callback info pointers must be equal or ignore_cb_data must be true
cb_data | the timed event callback info |
event_callback | the callback (cannot be NULL) |
ignore_cb_data | don't compare the timed event callback info pointers |
bool oc_ri_is_app_resource_to_be_deleted | ( | const oc_resource_t * | resource | ) |
Check if the resource has been scheduled to by deleted by oc_delayed_delete_resource.
Such resource should not be used.
resource | resource to be checked |
bool oc_ri_is_app_resource_valid | ( | const oc_resource_t * | resource | ) |
checks if the resource is valid
resource | resource to be tested |
bool oc_ri_on_delete_resource_add_callback | ( | oc_ri_delete_resource_cb_t | cb | ) |
Add to the global list of callbacks invoked by oc_delayed_delete_resource before each resource is deleted.
cb | the callback to be added (cannot be NULL) |
bool oc_ri_on_delete_resource_remove_callback | ( | oc_ri_delete_resource_cb_t | cb | ) |
Remove callback from the list of callbacks invoked by oc_delayed_delete_resource.
cb | the callback to be removed (cannot be NULL) |
int oc_ri_query_exists | ( | const char * | query, |
size_t | query_len, | ||
const char * | key | ||
) |
Checks if key exist in query.
bool oc_ri_query_exists_v1 | ( | const char * | query, |
size_t | query_len, | ||
const char * | key, | ||
size_t | key_len | ||
) |
Checks if key exist in query.
query | the query to inspect |
query_len | the length of the query |
key | the key to be checked if exist, key is null terminated (cannot be NULL) |
key_len | the key length |
int oc_ri_query_nth_key_exists | ( | const char * | query, |
size_t | query_len, | ||
const char ** | key, | ||
size_t * | key_len, | ||
size_t | n | ||
) |
check if the nth key exists
query | the query to inspect |
query_len | the length of the query |
key | the key to be checked if exist, key is not null terminated (cannot be NULL) |
key_len | the key length (cannot be NULL) |
n | index of the key (must be > 0) |
void oc_ri_remove_timed_event_callback | ( | const void * | cb_data, |
oc_trigger_t | event_callback | ||
) |
remove the timed event callback
cb_data | timed event callback info |
event_callback | timed event callback |
void oc_ri_remove_timed_event_callback_by_filter | ( | oc_trigger_t | cb, |
oc_ri_timed_event_filter_t | filter, | ||
const void * | filter_data, | ||
bool | match_all, | ||
oc_ri_timed_event_on_delete_t | on_delete | ||
) |
remove the timed event callback by filter
cb | timed event callback (cannot be NULL) |
filter | filtering function (cannot be NULL) |
filter_data | user data provided to the filtering function |
match_all | iterate over all timed events (otherwise the iteration will stop after the first match) |
on_delete | function invoked with the context data of the timed event, before the event is deallocated |
on_delete
callback will be invoked when the processing is finished. So it might occurr some time after the call to oc_ri_remove_timed_event_callback_by_filter has finished.int oc_status_code | ( | oc_status_t | key | ) |
convert the status code to CoAP status code
key | the application level key of the code |
const char* oc_status_to_str | ( | oc_status_t | key | ) |
Convert the status code to string.
[in] | key | key the application level key of the code |