Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
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 } |
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_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. | |
| 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_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. | |
| sn_coap_hdr_s * | sn_coap_parser_init_message (sn_coap_hdr_s *coap_msg_ptr) |
| Initialise a message structure to empty. | |
| sn_coap_hdr_s * | sn_coap_parser_alloc_message (struct coap_s *handle) |
| Allocate an empty message structure. | |
| 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. | |
Detailed Description
CoAP C-library User header interface header file.
Definition in file sn_coap_header.h.
Typedef Documentation
| typedef enum coap_version_ coap_version_e |
Enumeration for CoAP Version.
| typedef struct registration_info_ registration_info_t |
Used for creating manually registration message with sn_coap_register()
| typedef enum sn_coap_content_format_ sn_coap_content_format_e |
Enumeration for CoAP Content Format codes.
| typedef struct sn_coap_hdr_ sn_coap_hdr_s |
Main CoAP message struct.
| typedef enum sn_coap_msg_code_ sn_coap_msg_code_e |
Enumeration for CoAP Message code, used in CoAP Header.
| typedef enum sn_coap_msg_type_ sn_coap_msg_type_e |
Enumeration for CoAP Message type, used in CoAP Header.
| typedef enum sn_coap_observe_ sn_coap_observe_e |
Enumeration for CoAP Observe option values.
draft-ietf-core-observe-16
| typedef enum sn_coap_option_numbers_ sn_coap_option_numbers_e |
Enumeration for CoAP Option number, used in CoAP Header.
| typedef struct sn_coap_options_list_ sn_coap_options_list_s |
Structure for CoAP Options.
| typedef enum sn_coap_status_ sn_coap_status_e |
Enumeration for CoAP status, used in CoAP Header.
| typedef struct sn_nsdl_addr_ sn_nsdl_addr_s |
Address structure of Packet data.
| typedef enum sn_nsdl_addr_type_ sn_nsdl_addr_type_e |
Address type of given address.
| typedef enum sn_nsdl_capab_ sn_nsdl_capab_e |
Used protocol.
Enumeration Type Documentation
| enum coap_version_ |
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.
| enum sn_coap_msg_code_ |
Enumeration for CoAP Message code, used in CoAP Header.
Definition at line 58 of file sn_coap_header.h.
| enum sn_coap_msg_type_ |
Enumeration for CoAP Message type, used in CoAP Header.
- Enumerator:
Definition at line 48 of file sn_coap_header.h.
| enum sn_coap_observe_ |
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.
| enum sn_coap_status_ |
Enumeration for CoAP status, used in CoAP Header.
- Enumerator:
Definition at line 151 of file sn_coap_header.h.
| enum sn_nsdl_addr_type_ |
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 266 of file sn_coap_header.h.
| enum sn_nsdl_capab_ |
Used protocol.
- Enumerator:
SN_NSDL_PROTOCOL_HTTP Unsupported.
SN_NSDL_PROTOCOL_HTTPS Unsupported.
SN_NSDL_PROTOCOL_COAP Supported.
Definition at line 238 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:
-
*handle Pointer to CoAP library handle *coap_packet_ptr The request packet pointer msg_code response 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_ptr is pointer to allocated destination to built CoAP packet *src_coap_msg_ptr is 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_ptr is pointer to allocated destination to built CoAP packet *src_coap_msg_ptr is pointer to source structure for building Packet data blockwise_payload_size Blockwise 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_ptr is 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_ptr is pointer to data which needed Packet data length is calculated blockwise_payload_size Blockwise 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:
-
*handle Pointer to CoAP library handle packet_data_len is length of given Packet data to be parsed to CoAP message *packet_data_ptr is source for Packet data to be parsed to CoAP message *coap_version_ptr is 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:
-
*handle Pointer 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:
-
*handle Pointer to CoAP library handle *coap_msg_ptr is 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_ptr is 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:
-
*handle Pointer to CoAP library handle *freed_coap_msg_ptr is pointer to released CoAP message
Definition at line 152 of file sn_coap_parser.c.
Generated on Fri Jul 22 2022 04:54:08 by
1.7.2
