NSDL C library

Dependents:   NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more

Fork of nsdl_lib by Tero Heinonen

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
}
 

Enumeration for CoAP status, used in CoAP Header.

More...

Functions

void sn_coap_builder_and_parser_init (void *(*used_malloc_func_ptr)(uint16_t), void(*used_free_func_ptr)(void *))
 Sets the memory allocation and deallocation functions the library will use, and must be called first.
sn_coap_hdr_ssn_coap_parser (uint16_t packet_data_len, uint8_t *packet_data_ptr, coap_version_e *coap_version_ptr)
 Parses an incoming message buffer to a CoAP header structure.
void sn_coap_parser_release_allocated_coap_msg_mem (sn_coap_hdr_s *freed_coap_msg_ptr)
 Releases any memory allocated by a CoAP message structure.
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 the needed message buffer size from a CoAP message structure.
sn_coap_hdr_ssn_coap_build_response (sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)
 Automates the building of a response to an incoming request.
void sn_coap_packet_debug (sn_coap_hdr_s *coap_packet_ptr)
 CoAP packet debugging.

Detailed Description

CoAP C-library User header interface header file.

Created on: Jun 30, 2011 Author: tero

Note:
Supports draft-ietf-core-coap-18

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 26 of file sn_coap_header.h.

Enumeration for CoAP Content Format codes.

Definition at line 109 of file sn_coap_header.h.

Enumeration for CoAP Message code, used in CoAP Header.

Definition at line 46 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 35 of file sn_coap_header.h.

Enumeration for CoAP Option number, used in CoAP Header.

Definition at line 81 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

Definition at line 123 of file sn_coap_header.h.


Function Documentation

sn_coap_hdr_s* sn_coap_build_response ( sn_coap_hdr_s coap_packet_ptr,
uint8_t  msg_code 
)

Automates the building of a response to an incoming request.

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.

void sn_coap_builder_and_parser_init ( void *(*)(uint16_t)  used_malloc_func_ptr,
void(*)(void *)  used_free_func_ptr 
)

Sets the memory allocation and deallocation functions the library will use, and must be called first.

uint16_t sn_coap_builder_calc_needed_packet_data_size ( sn_coap_hdr_s src_coap_msg_ptr )

Calculates the needed message buffer size from a CoAP message structure.

void sn_coap_packet_debug ( sn_coap_hdr_s coap_packet_ptr )

CoAP packet debugging.

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

Parses an incoming message buffer to a CoAP header structure.

void sn_coap_parser_release_allocated_coap_msg_mem ( sn_coap_hdr_s freed_coap_msg_ptr )

Releases any memory allocated by a CoAP message structure.