Simulated product dispenser

Dependencies:   HTS221

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

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...
struct  registration_info_
 Used for creating manually registration message with sn_coap_register() More...
struct  sn_nsdl_addr_
 Address structure of Packet data. 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_observe_ sn_coap_observe_e
 Enumeration for CoAP Observe option values.
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.
typedef enum sn_nsdl_capab_ sn_nsdl_capab_e
 Used protocol.
typedef struct registration_info_ registration_info_t
 Used for creating manually registration message with sn_coap_register()
typedef enum sn_nsdl_addr_type_ sn_nsdl_addr_type_e
 Address type of given address.
typedef struct sn_nsdl_addr_ sn_nsdl_addr_s
 Address structure of Packet data.

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_observe_
 

Enumeration for CoAP Observe option values.

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,
  COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED = 8, COAP_STATUS_BUILDER_BLOCK_SENDING_DONE = 9
}
 

Enumeration for CoAP status, used in CoAP Header.

More...
enum  sn_nsdl_capab_ { SN_NSDL_PROTOCOL_HTTP = 0x01, SN_NSDL_PROTOCOL_HTTPS = 0x02, SN_NSDL_PROTOCOL_COAP = 0x04 }
 

Used protocol.

More...
enum  sn_nsdl_addr_type_ { SN_NSDL_ADDRESS_TYPE_IPV6 = 0x01, SN_NSDL_ADDRESS_TYPE_IPV4 = 0x02, SN_NSDL_ADDRESS_TYPE_HOSTNAME = 0x03 }
 

Address type of given address.

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)
 Allocates and initializes options list structure.

Detailed Description

CoAP C-library User header interface header file.

Definition in file sn_coap_header.h.


Typedef Documentation

Enumeration for CoAP Version.

Used for creating manually registration message with sn_coap_register()

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 Observe option values.

draft-ietf-core-observe-16

Enumeration for CoAP Option number, used in CoAP Header.

Structure for CoAP Options.

Enumeration for CoAP status, used in CoAP Header.

typedef struct sn_nsdl_addr_ sn_nsdl_addr_s

Address structure of Packet data.

Address type of given address.

Used protocol.


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 Observe option values.

draft-ietf-core-observe-16

Definition at line 137 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.

COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED 

Blockwise message sending timeout.

The msg_id in sn_coap_hdr_s* parameter of RX callback is set to the same value as in the first block sent, and parameter sn_nsdl_addr_s* is set as NULL.

COAP_STATUS_BUILDER_BLOCK_SENDING_DONE 

Blockwise message sending, last block sent.

The msg_id in sn_coap_hdr_s* parameter of RX callback is set to the same value as in the first block sent, and parameter sn_nsdl_addr_s* is set as NULL.

Definition at line 151 of file sn_coap_header.h.

Address type of given address.

Enumerator:
SN_NSDL_ADDRESS_TYPE_IPV6 

Supported.

SN_NSDL_ADDRESS_TYPE_IPV4 

Supported.

SN_NSDL_ADDRESS_TYPE_HOSTNAME 

Unsupported.

Definition at line 274 of file sn_coap_header.h.

Used protocol.

Enumerator:
SN_NSDL_PROTOCOL_HTTP 

Unsupported.

SN_NSDL_PROTOCOL_HTTPS 

Unsupported.

SN_NSDL_PROTOCOL_COAP 

Supported.

Definition at line 246 of file sn_coap_header.h.


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

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 115 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 67 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 
)

Allocates and initializes options list 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 82 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 51 of file sn_coap_parser.c.

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.

Note!!! Does not release Payload part

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

Definition at line 152 of file sn_coap_parser.c.