Contiki-NG
|
This is an implementation of the Constrained Application Protocol. More...
Modules | |
CoAP keystore API | |
The CoAP keystore API defines a common interface for retrieving authorization information for CoAP/DTLS. | |
CoAP timer API | |
The CoAP timer API defines a common interface for CoAP timer and time functionality. | |
CoAP transport API | |
The CoAP transport API defines a common interface for sending/receiving CoAP messages. | |
Files | |
file | coap-request-state.h |
Common request state for all the APIs | |
Macros | |
#define | COAP_MAX_PACKET_SIZE (COAP_MAX_HEADER_SIZE + COAP_MAX_CHUNK_SIZE) |
The max size of the CoAP messages. | |
Enumerations | |
enum | coap_resource_flags_t |
Resource flags for allowed methods and special functionalities. | |
Functions | |
int | coap_block1_handler (coap_message_t *request, coap_message_t *response, uint8_t *target, size_t *len, size_t max_len) |
Block 1 support within a coap-ressource. More... | |
int | coap_send_request (coap_callback_request_state_t *callback_state, coap_endpoint_t *endpoint, coap_message_t *request, void(*callback)(coap_callback_request_state_t *callback_state)) |
Send a CoAP request to a remote endpoint. More... | |
void | coap_activate_resource (coap_resource_t *resource, const char *path) |
Makes a resource available under the given URI path. More... | |
coap_resource_t * | coap_get_first_resource (void) |
Returns the first of registered CoAP resources. More... | |
coap_resource_t * | coap_get_next_resource (coap_resource_t *resource) |
Returns the next registered CoAP resource. More... | |
void | coap_log_string (const char *text, size_t len) |
Logs a CoAP string that has a length but might not be 0-terminated. More... | |
void | coap_separate_reject () |
Reject a request that would require a separate response with an error message. More... | |
void | coap_separate_accept (coap_message_t *coap_req, coap_separate_t *separate_store) |
Initiate a separate response with an empty ACK. More... | |
This is an implementation of the Constrained Application Protocol.
void coap_activate_resource | ( | coap_resource_t * | resource, |
const char * | path | ||
) |
Makes a resource available under the given URI path.
Resources wanted to be accessible should be activated with the following code.
resource | A pointer to a resource implementation |
path | The URI path string for this resource |
The resource implementation must be imported first using the extern keyword. The build system takes care of compiling every *.c file in the ./resources/ sub-directory (see example Makefile).
resource | A CoAP resource defined through the RESOURCE macros. |
path | The local URI path where to provide the resource. |
Definition at line 399 of file coap-engine.c.
int coap_block1_handler | ( | coap_message_t * | request, |
coap_message_t * | response, | ||
uint8_t * | target, | ||
size_t * | len, | ||
size_t | max_len | ||
) |
Block 1 support within a coap-ressource.
This function will help you to use block 1. If target is null error handling and response configuration is active. On return value 0, the last block was recived, while on return value 1 more blocks will follow. With target, len and maxlen this function will assemble the blocks.
You can find an example in: examples/er-rest-example/resources/res-b1-sep-b2.c
request | Request pointer from the handler |
response | Response pointer from the handler |
target | Pointer to the buffer where the request payload can be assembled |
len | Pointer to the variable, where the function stores the actual length |
max_len | Length of the "target"-Buffer |
Definition at line 79 of file coap-block1.c.
coap_resource_t * coap_get_first_resource | ( | void | ) |
Returns the first of registered CoAP resources.
Definition at line 424 of file coap-engine.c.
References list_head().
coap_resource_t * coap_get_next_resource | ( | coap_resource_t * | resource | ) |
Returns the next registered CoAP resource.
Definition at line 430 of file coap-engine.c.
References list_item_next().
void coap_log_string | ( | const char * | text, |
size_t | len | ||
) |
Logs a CoAP string that has a length but might not be 0-terminated.
text | The CoAP string |
len | The number of characters in the CoAP string |
Definition at line 47 of file coap-log.c.
int coap_send_request | ( | coap_callback_request_state_t * | callback_state, |
coap_endpoint_t * | endpoint, | ||
coap_message_t * | request, | ||
void(*)(coap_callback_request_state_t *callback_state) | callback | ||
) |
Send a CoAP request to a remote endpoint.
callback_state | The callback state to handle the CoAP request |
endpoint | The destination endpoint |
request | The request to be sent |
callback | callback to execute when the response arrives or the timeout expires |
Definition at line 150 of file coap-callback-api.c.
void coap_separate_accept | ( | coap_message_t * | coap_req, |
coap_separate_t * | separate_store | ||
) |
Initiate a separate response with an empty ACK.
coap_req | The request to accept |
separate_store | A pointer to the data structure that will store the relevant information for the response |
When the server does not have enough resources left to store the information for a separate response or otherwise cannot execute the resource handler, this function will respond with 5.03 Service Unavailable. The client can then retry later.
Definition at line 86 of file coap-separate.c.
void coap_separate_reject | ( | ) |
Reject a request that would require a separate response with an error message.
When the server does not have enough resources left to store the information for a separate response or otherwise cannot execute the resource handler, this function will respond with 5.03 Service Unavailable. The client can then retry later.
Definition at line 67 of file coap-separate.c.