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 * p_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

uint16_t coap_message_t::data_len

Internal. Length of the provided data buffer for options and payload.

coap_message_header_t coap_message_t::header

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

coap_option_t coap_message_t::options[COAP_MAX_NUMBER_OF_OPTIONS]

Public. Array options in the message.

uint8_t coap_message_t::options_count

Public. The number of options in the message.

uint8_t coap_message_t::options_delta

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

uint16_t coap_message_t::options_len

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

uint16_t coap_message_t::options_offset

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

void* coap_message_t::p_arg

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

uint8_t* coap_message_t::p_data

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

uint8_t* coap_message_t::p_payload

Public. Pointer to the payload buffer in the message.

uint16_t coap_message_t::payload_len

Public. Size of the payload in the message.

coap_port_t coap_message_t::port

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

coap_remote_t coap_message_t::remote

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

coap_response_callback_t coap_message_t::response_callback

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.

uint8_t coap_message_t::token[8]

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