Contiki-NG
|
Topics | |
CoAP keystore API | |
CoAP timer API | |
CoAP transport API | |
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 resource. | |
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. | |
void | coap_activate_resource (coap_resource_t *resource, const char *path) |
Makes a resource available under the given URI path. | |
coap_resource_t * | coap_get_first_resource (void) |
Returns the first of the registered CoAP resources. | |
coap_resource_t * | coap_get_next_resource (coap_resource_t *resource) |
Returns the next registered CoAP resource. | |
void | coap_log_string (const char *text, size_t len) |
Logs a CoAP string that has a length specified, but might not be zero-terminated. | |
void | coap_separate_reject () |
Reject a request that would require a separate response with an error message. | |
void | coap_separate_accept (coap_message_t *coap_req, coap_separate_t *separate_store) |
Initiate a separate response with an empty ACK. | |
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.
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 401 of file coap-engine.c.
References coap_timer_set(), coap_timer_set_callback(), coap_timer_set_user_data(), and list_add().
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 resource.
This function will help you to use block 1. If the target parameter is \p NULL, then error handling and response configuration is active. You can find an example in examples/coap/coap-example-server/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 84 of file coap-block1.c.
coap_resource_t * coap_get_first_resource | ( | void | ) |
Returns the first of the registered CoAP resources.
Definition at line 426 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 432 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 specified, but might not be zero-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 149 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.
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.
coap_req | The request to accept. |
separate_store | A pointer to the data structure that will store the relevant information for the response. |
Definition at line 89 of file coap-separate.c.
References coap_databuf(), coap_endpoint_copy(), and coap_sendto().
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 68 of file coap-separate.c.