joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Embed: (wiki syntax)

« Back to documentation index

sn_coap_header.h File Reference

sn_coap_header.h File Reference

CoAP C-library User header interface header file. More...

Go to the source code of this file.

Data Structures

struct  sn_coap_options_list_
 Structure for CoAP Options. More...
struct  sn_coap_hdr_
 Main CoAP message struct. More...

Typedefs

typedef enum coap_version_ coap_version_e
 Enumeration for CoAP Version.
typedef enum sn_coap_msg_type_ sn_coap_msg_type_e
 Enumeration for CoAP Message type, used in CoAP Header.
typedef enum sn_coap_msg_code_ sn_coap_msg_code_e
 Enumeration for CoAP Message code, used in CoAP Header.
typedef enum
sn_coap_option_numbers_ 
sn_coap_option_numbers_e
 Enumeration for CoAP Option number, used in CoAP Header.
typedef enum
sn_coap_content_format_ 
sn_coap_content_format_e
 Enumeration for CoAP Content Format codes.
typedef enum sn_coap_status_ sn_coap_status_e
 Enumeration for CoAP status, used in CoAP Header.
typedef struct
sn_coap_options_list_ 
sn_coap_options_list_s
 Structure for CoAP Options.
typedef struct sn_coap_hdr_ sn_coap_hdr_s
 Main CoAP message struct.

Enumerations

enum  coap_version_
 

Enumeration for CoAP Version.

More...
enum  sn_coap_msg_type_ { COAP_MSG_TYPE_CONFIRMABLE = 0x00, COAP_MSG_TYPE_NON_CONFIRMABLE = 0x10, COAP_MSG_TYPE_ACKNOWLEDGEMENT = 0x20, COAP_MSG_TYPE_RESET = 0x30 }
 

Enumeration for CoAP Message type, used in CoAP Header.

More...
enum  sn_coap_msg_code_
 

Enumeration for CoAP Message code, used in CoAP Header.

More...
enum  sn_coap_option_numbers_
 

Enumeration for CoAP Option number, used in CoAP Header.

More...
enum  sn_coap_content_format_
 

Enumeration for CoAP Content Format codes.

More...
enum  sn_coap_status_ {
  COAP_STATUS_OK = 0, COAP_STATUS_PARSER_ERROR_IN_HEADER = 1, COAP_STATUS_PARSER_DUPLICATED_MSG = 2, COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVING = 3,
  COAP_STATUS_PARSER_BLOCKWISE_ACK = 4, COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED = 5, COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED = 6, COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED = 7
}
 

Enumeration for CoAP status, used in CoAP Header.

More...

Functions

sn_coap_hdr_ssn_coap_parser (struct coap_s *handle, uint16_t packet_data_len, uint8_t *packet_data_ptr, coap_version_e *coap_version_ptr)
 Parses CoAP message from given Packet data.
void sn_coap_parser_release_allocated_coap_msg_mem (struct coap_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr)
 Releases memory of given CoAP message.
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.
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.
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_2 (sn_coap_hdr_s *src_coap_msg_ptr, uint16_t blockwise_payload_size)
 Calculates needed Packet data memory size for given CoAP message.
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.
sn_coap_hdr_ssn_coap_parser_init_message (sn_coap_hdr_s *coap_msg_ptr)
 Initialise a message structure to empty.
sn_coap_hdr_ssn_coap_parser_alloc_message (struct coap_s *handle)
 Allocate an empty message structure.
sn_coap_options_list_ssn_coap_parser_alloc_options (struct coap_s *handle, sn_coap_hdr_s *coap_msg_ptr)
 Allocate an empty options structure.

Detailed Description

CoAP C-library User header interface header file.

Definition in file sn_coap_header.h.


Typedef Documentation

Enumeration for CoAP Version.

Enumeration for CoAP Content Format codes.

typedef struct sn_coap_hdr_ sn_coap_hdr_s

Main CoAP message struct.

Enumeration for CoAP Message code, used in CoAP Header.

Enumeration for CoAP Message type, used in CoAP Header.

Enumeration for CoAP Option number, used in CoAP Header.

Structure for CoAP Options.

Enumeration for CoAP status, used in CoAP Header.


Enumeration Type Documentation

Enumeration for CoAP Version.

Definition at line 40 of file sn_coap_header.h.

Enumeration for CoAP Content Format codes.

Definition at line 121 of file sn_coap_header.h.

Enumeration for CoAP Message code, used in CoAP Header.

Definition at line 58 of file sn_coap_header.h.

Enumeration for CoAP Message type, used in CoAP Header.

Enumerator:
COAP_MSG_TYPE_CONFIRMABLE 

Reliable Request messages.

COAP_MSG_TYPE_NON_CONFIRMABLE 

Non-reliable Request and Response messages.

COAP_MSG_TYPE_ACKNOWLEDGEMENT 

Response to a Confirmable Request.

COAP_MSG_TYPE_RESET 

Answer a Bad Request.

Definition at line 48 of file sn_coap_header.h.

Enumeration for CoAP Option number, used in CoAP Header.

Definition at line 93 of file sn_coap_header.h.

Enumeration for CoAP status, used in CoAP Header.

Enumerator:
COAP_STATUS_OK 

Default value is OK.

COAP_STATUS_PARSER_ERROR_IN_HEADER 

CoAP will send Reset message to invalid message sender.

COAP_STATUS_PARSER_DUPLICATED_MSG 

CoAP will send Acknowledgement message to duplicated message sender.

COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVING 

User will get whole message after all message blocks received.

User must release messages with this status.

COAP_STATUS_PARSER_BLOCKWISE_ACK 

Acknowledgement for sent Blockwise message received.

COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED 

Blockwise message received but not supported by compiling switch.

COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED 

Blockwise message fully received and returned to app.

User must take care of releasing whole payload of the blockwise messages

COAP_STATUS_BUILDER_MESSAGE_SENDING_FAILED 

When re-transmissions have been done and ACK not received, CoAP library calls RX callback with this status.

Definition at line 134 of file sn_coap_header.h.


Function Documentation

sn_coap_hdr_s* sn_coap_build_response ( struct coap_s *  ,
sn_coap_hdr_s ,
uint8_t   
)

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 231 of file test/mbedclient/utest/stub/common_stub.cpp.

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 95 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_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 100 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 145 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 150 of file sn_coap_builder.c.

sn_coap_hdr_s * sn_coap_parser ( struct coap_s *  handle,
uint16_t  packet_data_len,
uint8_t *  packet_data_ptr,
coap_version_e coap_version_ptr 
)

Parses CoAP message from given Packet data.

Parameters:
*handlePointer to CoAP library handle
packet_data_lenis length of given Packet data to be parsed to CoAP message
*packet_data_ptris source for Packet data to be parsed to CoAP message
*coap_version_ptris destination for parsed CoAP specification version
Returns:
Return value is pointer to parsed CoAP message.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)

Definition at line 103 of file sn_coap_parser.c.

sn_coap_hdr_s* sn_coap_parser_alloc_message ( struct coap_s *  handle )

Allocate an empty message structure.

Parameters:
*handlePointer to CoAP library handle
Returns:
Return value is pointer to an empty CoAP message.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)

Definition at line 63 of file sn_coap_parser.c.

sn_coap_options_list_s* sn_coap_parser_alloc_options ( struct coap_s *  handle,
sn_coap_hdr_s coap_msg_ptr 
)

Allocate an empty options structure.

Parameters:
*handlePointer to CoAP library handle
*coap_msg_ptris pointer to CoAP message that will contain the options

If the message already has a pointer to an option structure, that pointer is returned, rather than a new structure being allocated.

Returns:
Return value is pointer to the CoAP options structure.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)

Definition at line 78 of file sn_coap_parser.c.

sn_coap_hdr_s* sn_coap_parser_init_message ( sn_coap_hdr_s coap_msg_ptr )

Initialise a message structure to empty.

Parameters:
*coap_msg_ptris pointer to CoAP message to initialise
Returns:
Return value is pointer passed in

Definition at line 50 of file sn_coap_parser.c.

void sn_coap_parser_release_allocated_coap_msg_mem ( struct coap_s *  ,
sn_coap_hdr_s  
)

Releases memory of given CoAP message.

Note!!! Does not release Payload part

Parameters:
*handlePointer to CoAP library handle
*freed_coap_msg_ptris pointer to released CoAP message

Definition at line 236 of file test/mbedclient/utest/stub/common_stub.cpp.