nRF51 IoT SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
coap_message_t Struct Reference

Structure to hold a CoAP message. More...

#include <coap_api.h>

Data Fields

coap_remote_t remote
 
coap_message_header_t header
 
uint8_t * p_payload
 
uint16_t payload_len
 
uint8_t options_count
 
coap_option_t options [COAP_MAX_NUMBER_OF_OPTIONS]
 
void * arg
 
coap_response_callback_t response_callback
 
uint8_t token [8]
 
coap_port_t port
 
uint16_t options_len
 
uint16_t options_offset
 
uint8_t options_delta
 
uint8_t * p_data
 
uint16_t data_len
 

Detailed Description

Structure to hold a CoAP message.

The CoAP message structure contains both internal and public members to serialize and deserialize data supplied from the application to a byte buffer sent over UDP. The message structure is used both in transmission and reception, which makes it easy to handle in an application. Updating the message should be done using the provided APIs, not by manually assigning new values to the members directly. Reading the members, on the other hand, is fine.

Field Documentation

void* coap_message_t::arg

Public. Array options in the message.

uint16_t coap_message_t::data_len

Internal. Data buffer for adding dynamically sized options and payload.

coap_message_header_t coap_message_t::header

Public. Structure containing address information and port number to the remote.

coap_option_t coap_message_t::options[COAP_MAX_NUMBER_OF_OPTIONS]

Public. The number of options in the message.

uint8_t coap_message_t::options_count

Public. Size of the payload in the message.

uint8_t coap_message_t::options_delta

Internal. Index to where the next option or payload can be added in the message's data buffer

uint16_t coap_message_t::options_len

Internal. Transport layer variable to associate the message with an underlying Transport Layer socket descriptor.

uint16_t coap_message_t::options_offset

Internal. Length of the options including the mandatory header with extension bytes and option data. Accumulated every time a new options is added.

uint8_t* coap_message_t::p_data

Internal. Current option number. Used to calculate the next option delta when adding new options to the message.

uint8_t* coap_message_t::p_payload

Public. Header structure containing the mandatory CoAP 4-byte header fields.

uint16_t coap_message_t::payload_len

Public. Pointer to the payload buffer in the message.

coap_port_t coap_message_t::port

Internal. Array holding the variable-sized message token. Should be set by the application through a configuration parameter.

coap_response_callback_t coap_message_t::response_callback

Public. Miscellaneous pointer to application provided data that is associated with the message.

uint8_t coap_message_t::token[8]

Internal. Function callback set by the application to be called when a response to this message is received. Should be set by the application through a configuration parameter.