Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

sn_coap_builder.c File Reference

sn_coap_builder.c File Reference

CoAP Message builder. More...

Go to the source code of this file.

Functions

static int8_t sn_coap_builder_header_build (uint8_t **dst_packet_data_pptr, sn_coap_hdr_s *src_coap_msg_ptr)
 Builds Header part of Packet data.
static int8_t sn_coap_builder_options_build (uint8_t **dst_packet_data_pptr, sn_coap_hdr_s *src_coap_msg_ptr)
 Builds Options part of Packet data.
static uint16_t sn_coap_builder_options_calc_option_size (uint16_t query_len, uint8_t *query_ptr, sn_coap_option_numbers_e option)
 Calculates needed Packet data memory size for option.
static uint8_t sn_coap_builder_options_build_add_uint_option (uint8_t **dst_packet_data_pptr, uint32_t option_value, sn_coap_option_numbers_e option_number, uint16_t *previous_option_number)
 Constructs a uint Options part of Packet data.
static uint8_t sn_coap_builder_options_get_option_part_count (uint16_t query_len, uint8_t *query_ptr, sn_coap_option_numbers_e option)
 Gets query part count from whole option string.
static uint16_t sn_coap_builder_options_get_option_part_length_from_whole_option_string (uint16_t query_len, uint8_t *query_ptr, uint8_t query_index, sn_coap_option_numbers_e option)
 Gets one's query part length from whole query string.
static int16_t sn_coap_builder_options_get_option_part_position (uint16_t query_len, uint8_t *query_ptr, uint8_t query_index, sn_coap_option_numbers_e option)
 Gets query part position in whole query.
static void sn_coap_builder_payload_build (uint8_t **dst_packet_data_pptr, sn_coap_hdr_s *src_coap_msg_ptr)
 Builds Options part of Packet data.
sn_coap_hdr_ssn_coap_build_response (struct coap_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)
 Prepares generic response packet from a request packet.
int16_t sn_coap_builder (uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr)
 Builds an outgoing message buffer from a CoAP header structure.
int16_t sn_coap_builder_2 (uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size)
 Builds an outgoing message buffer from a CoAP header structure.
uint16_t sn_coap_builder_calc_needed_packet_data_size (sn_coap_hdr_s *src_coap_msg_ptr)
 Calculates needed Packet data memory size for given CoAP message.
uint16_t sn_coap_builder_calc_needed_packet_data_size_2 (sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size)
 Calculates needed Packet data memory size for given CoAP message.

Detailed Description

CoAP Message builder.

Functionality: Builds CoAP message

Definition in file sn_coap_builder.c.


Function Documentation

sn_coap_hdr_s* sn_coap_build_response ( struct coap_s *  handle,
sn_coap_hdr_s coap_packet_ptr,
uint8_t  msg_code 
)

Prepares generic response packet from a request packet.

This function allocates memory for the resulting sn_coap_hdr_s

Parameters:
*handlePointer to CoAP library handle
*coap_packet_ptrThe request packet pointer
msg_coderesponse messages code
Returns:
*coap_packet_ptr The allocated and pre-filled response packet pointer NULL Error in parsing the request

Definition at line 52 of file sn_coap_builder.c.

int16_t sn_coap_builder ( uint8_t *  dst_packet_data_ptr,
sn_coap_hdr_s src_coap_msg_ptr 
)

Builds an outgoing message buffer from a CoAP header structure.

Parameters:
*dst_packet_data_ptris pointer to allocated destination to built CoAP packet
*src_coap_msg_ptris pointer to source structure for building Packet data
Returns:
Return value is byte count of built Packet data. In failure cases:
-1 = Failure in given CoAP header structure
-2 = Failure in given pointer (= NULL)

Definition at line 100 of file sn_coap_builder.c.

int16_t sn_coap_builder_2 ( uint8_t *  dst_packet_data_ptr,
sn_coap_hdr_s src_coap_msg_ptr,
uint16_t  blockwise_payload_size 
)

Builds an outgoing message buffer from a CoAP header structure.

Parameters:
*dst_packet_data_ptris pointer to allocated destination to built CoAP packet
*src_coap_msg_ptris pointer to source structure for building Packet data
blockwise_payload_sizeBlockwise message maximum payload size
Returns:
Return value is byte count of built Packet data. In failure cases:
-1 = Failure in given CoAP header structure
-2 = Failure in given pointer (= NULL)

Definition at line 105 of file sn_coap_builder.c.

uint16_t sn_coap_builder_calc_needed_packet_data_size ( sn_coap_hdr_s src_coap_msg_ptr )

Calculates needed Packet data memory size for given CoAP message.

Parameters:
*src_coap_msg_ptris pointer to data which needed Packet data length is calculated
Returns:
Return value is count of needed memory as bytes for build Packet data Null if failed

Definition at line 150 of file sn_coap_builder.c.

uint16_t sn_coap_builder_calc_needed_packet_data_size_2 ( sn_coap_hdr_s src_coap_msg_ptr,
uint16_t  blockwise_payload_size 
)

Calculates needed Packet data memory size for given CoAP message.

Parameters:
*src_coap_msg_ptris pointer to data which needed Packet data length is calculated
blockwise_payload_sizeBlockwise message maximum payload size
Returns:
Return value is count of needed memory as bytes for build Packet data Null if failed

Definition at line 155 of file sn_coap_builder.c.

static int8_t sn_coap_builder_header_build ( uint8_t **  dst_packet_data_pptr,
sn_coap_hdr_s src_coap_msg_ptr 
) [static]

Builds Header part of Packet data.

Parameters:
**dst_packet_data_pptris destination for built Packet data
*src_coap_msg_ptris source for building Packet data
Returns:
Return value is 0 in ok case and -1 in failure case

Definition at line 502 of file sn_coap_builder.c.

static int8_t sn_coap_builder_options_build ( uint8_t **  dst_packet_data_pptr,
sn_coap_hdr_s src_coap_msg_ptr 
) [static]

Builds Options part of Packet data.

Parameters:
**dst_packet_data_pptris destination for built Packet data
*src_coap_msg_ptris source for building Packet data
Returns:
Return value is 0 in every case

Definition at line 545 of file sn_coap_builder.c.

static uint8_t sn_coap_builder_options_build_add_uint_option ( uint8_t **  dst_packet_data_pptr,
uint32_t  option_value,
sn_coap_option_numbers_e  option_number,
uint16_t *  previous_option_number 
) [static]

Constructs a uint Options part of Packet data.

Parameters:
**dst_packet_data_pptris destination for built Packet data; NULL to compute size only.
option_valueis Option value to be added
option_numberis Option number to be added
Returns:
Return value is total option size, or -1 in write failure case

Definition at line 761 of file sn_coap_builder.c.

static uint16_t sn_coap_builder_options_calc_option_size ( uint16_t  query_len,
uint8_t *  query_ptr,
sn_coap_option_numbers_e  option 
) [static]

Calculates needed Packet data memory size for option.

Parameters:
path_lenis length of calculated strting(s)
*path_ptris pointer to calculated options
Returns:
Return value is count of needed memory as bytes for Uri-query option

Definition at line 842 of file sn_coap_builder.c.

static uint8_t sn_coap_builder_options_get_option_part_count ( uint16_t  query_len,
uint8_t *  query_ptr,
sn_coap_option_numbers_e  option 
) [static]

Gets query part count from whole option string.

Parameters:
query_lenis length of whole Path
*query_ptris pointer to the start of whole Path
Returns:
Return value is count of query parts

Definition at line 923 of file sn_coap_builder.c.

static uint16_t sn_coap_builder_options_get_option_part_length_from_whole_option_string ( uint16_t  query_len,
uint8_t *  query_ptr,
uint8_t  query_index,
sn_coap_option_numbers_e  option 
) [static]

Gets one's query part length from whole query string.

Parameters:
query_lenis length of whole string
*query_ptris pointer to the start of whole string
query_indexis query part index to be found
sn_coap_option_numbers_eoption is option number of the option
Returns:
Return value is length of query part

Definition at line 963 of file sn_coap_builder.c.

static int16_t sn_coap_builder_options_get_option_part_position ( uint16_t  query_len,
uint8_t *  query_ptr,
uint8_t  query_index,
sn_coap_option_numbers_e  option 
) [static]

Gets query part position in whole query.

Parameters:
query_lenis length of whole query
*query_ptris pointer to the start of whole query
query_indexis query part index to be found
Returns:
Return value is position (= offset) of query part in whole query. In fail cases -1 is returned.

Definition at line 1021 of file sn_coap_builder.c.

static void sn_coap_builder_payload_build ( uint8_t **  dst_packet_data_pptr,
sn_coap_hdr_s src_coap_msg_ptr 
) [static]

Builds Options part of Packet data.

Parameters:
**dst_packet_data_pptris destination for built Packet data
*src_coap_msg_ptris source for building Packet data

Definition at line 1076 of file sn_coap_builder.c.