Contiki-NG
Loading...
Searching...
No Matches

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.
 

Detailed Description

This is an implementation of the Constrained Application Protocol

Function Documentation

◆ coap_activate_resource()

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).

Parameters
resourceA CoAP resource defined through the RESOURCE macros.
pathThe local URI path where to provide the resource.

Definition at line 397 of file coap-engine.c.

References coap_timer_set(), coap_timer_set_callback(), coap_timer_set_user_data(), and list_add().

◆ coap_block1_handler()

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
Parameters
requestRequest pointer from the handler.
responseResponse pointer from the handler.
targetPointer to the buffer where the request payload can be assembled.
lenPointer to the variable where the function stores the actual length.
max_lenLength of the target buffer.
Returns
0 if the initialisation was successful, 1 if more blocks will follow, or -1 if the initialisation failed.

Definition at line 84 of file coap-block1.c.

◆ coap_get_first_resource()

coap_resource_t * coap_get_first_resource ( void )

Returns the first of the registered CoAP resources.

Returns
The first registered CoAP resource or NULL if none exists.

Definition at line 422 of file coap-engine.c.

References list_head().

◆ coap_get_next_resource()

coap_resource_t * coap_get_next_resource ( coap_resource_t * resource)

Returns the next registered CoAP resource.

Returns
The next resource or NULL if no more exists.

Definition at line 428 of file coap-engine.c.

References list_item_next().

◆ coap_log_string()

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.

Parameters
textThe CoAP string.
lenThe number of characters in the CoAP string.

Definition at line 47 of file coap-log.c.

◆ coap_send_request()

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.

Parameters
callback_stateThe callback state to handle the CoAP request.
endpointThe destination endpoint.
requestThe request to be sent.
callbackcallback to execute when the response arrives or the timeout expires.
Returns
1 if there is a transaction available to send, 0 otherwise.

Definition at line 149 of file coap-callback-api.c.

◆ coap_separate_accept()

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.

Parameters
coap_reqThe request to accept.
separate_storeA 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().

◆ coap_separate_reject()

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.