version of nsdl to work with lwm2m, updated RD parameters and location option handling
Dependents: ArchPro_LWM2M_LED_Client Weather_Station_LWM2M mbedEndpointNetwork
Fork of nanoservice_client_1_12 by
sn_coap_header.h@10:b5ecd6660d71, 2015-04-13 (annotated)
- Committer:
- michaeljkoster
- Date:
- Mon Apr 13 22:13:40 2015 +0000
- Revision:
- 10:b5ecd6660d71
- Parent:
- 0:aafd54b05111
Add error return from sn_nsdl_register_endpoint() in sn_nsdl.c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zdshelby | 0:aafd54b05111 | 1 | /** |
zdshelby | 0:aafd54b05111 | 2 | * \file sn_coap_header.h |
zdshelby | 0:aafd54b05111 | 3 | * |
zdshelby | 0:aafd54b05111 | 4 | * \brief CoAP C-library User header interface header file |
zdshelby | 0:aafd54b05111 | 5 | * |
zdshelby | 0:aafd54b05111 | 6 | * Created on: Jun 30, 2011 |
zdshelby | 0:aafd54b05111 | 7 | * Author: tero |
zdshelby | 0:aafd54b05111 | 8 | * |
zdshelby | 0:aafd54b05111 | 9 | * \note Supports draft-ietf-core-coap-18 |
zdshelby | 0:aafd54b05111 | 10 | */ |
zdshelby | 0:aafd54b05111 | 11 | |
zdshelby | 0:aafd54b05111 | 12 | #ifndef SN_COAP_HEADER_H_ |
zdshelby | 0:aafd54b05111 | 13 | #define SN_COAP_HEADER_H_ |
zdshelby | 0:aafd54b05111 | 14 | |
zdshelby | 0:aafd54b05111 | 15 | #ifdef __cplusplus |
zdshelby | 0:aafd54b05111 | 16 | extern "C" { |
zdshelby | 0:aafd54b05111 | 17 | #endif |
zdshelby | 0:aafd54b05111 | 18 | |
zdshelby | 0:aafd54b05111 | 19 | /* * * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 20 | /* * * * ENUMERATIONS * * * */ |
zdshelby | 0:aafd54b05111 | 21 | /* * * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 22 | |
zdshelby | 0:aafd54b05111 | 23 | /** |
zdshelby | 0:aafd54b05111 | 24 | * \brief Enumeration for CoAP Version |
zdshelby | 0:aafd54b05111 | 25 | */ |
zdshelby | 0:aafd54b05111 | 26 | typedef enum coap_version_ |
zdshelby | 0:aafd54b05111 | 27 | { |
zdshelby | 0:aafd54b05111 | 28 | COAP_VERSION_1 = 0x40, |
zdshelby | 0:aafd54b05111 | 29 | COAP_VERSION_UNKNOWN = 0xFF |
zdshelby | 0:aafd54b05111 | 30 | } coap_version_e; |
zdshelby | 0:aafd54b05111 | 31 | |
zdshelby | 0:aafd54b05111 | 32 | /** |
zdshelby | 0:aafd54b05111 | 33 | * \brief Enumeration for CoAP Message type, used in CoAP Header |
zdshelby | 0:aafd54b05111 | 34 | */ |
zdshelby | 0:aafd54b05111 | 35 | typedef enum sn_coap_msg_type_ |
zdshelby | 0:aafd54b05111 | 36 | { |
zdshelby | 0:aafd54b05111 | 37 | COAP_MSG_TYPE_CONFIRMABLE = 0x00, /**< Reliable Request messages */ |
zdshelby | 0:aafd54b05111 | 38 | COAP_MSG_TYPE_NON_CONFIRMABLE = 0x10, /**< Non-reliable Request and Response messages */ |
zdshelby | 0:aafd54b05111 | 39 | COAP_MSG_TYPE_ACKNOWLEDGEMENT = 0x20, /**< Response to a Confirmable Request */ |
zdshelby | 0:aafd54b05111 | 40 | COAP_MSG_TYPE_RESET = 0x30 /**< Answer a Bad Request */ |
zdshelby | 0:aafd54b05111 | 41 | } sn_coap_msg_type_e; |
zdshelby | 0:aafd54b05111 | 42 | |
zdshelby | 0:aafd54b05111 | 43 | /** |
zdshelby | 0:aafd54b05111 | 44 | * \brief Enumeration for CoAP Message code, used in CoAP Header |
zdshelby | 0:aafd54b05111 | 45 | */ |
zdshelby | 0:aafd54b05111 | 46 | typedef enum sn_coap_msg_code_ |
zdshelby | 0:aafd54b05111 | 47 | { |
zdshelby | 0:aafd54b05111 | 48 | COAP_MSG_CODE_EMPTY = 0, |
zdshelby | 0:aafd54b05111 | 49 | COAP_MSG_CODE_REQUEST_GET = 1, |
zdshelby | 0:aafd54b05111 | 50 | COAP_MSG_CODE_REQUEST_POST = 2, |
zdshelby | 0:aafd54b05111 | 51 | COAP_MSG_CODE_REQUEST_PUT = 3, |
zdshelby | 0:aafd54b05111 | 52 | COAP_MSG_CODE_REQUEST_DELETE = 4, |
zdshelby | 0:aafd54b05111 | 53 | |
zdshelby | 0:aafd54b05111 | 54 | COAP_MSG_CODE_RESPONSE_CREATED = 65, |
zdshelby | 0:aafd54b05111 | 55 | COAP_MSG_CODE_RESPONSE_DELETED = 66, |
zdshelby | 0:aafd54b05111 | 56 | COAP_MSG_CODE_RESPONSE_VALID = 67, |
zdshelby | 0:aafd54b05111 | 57 | COAP_MSG_CODE_RESPONSE_CHANGED = 68, |
zdshelby | 0:aafd54b05111 | 58 | COAP_MSG_CODE_RESPONSE_CONTENT = 69, |
zdshelby | 0:aafd54b05111 | 59 | COAP_MSG_CODE_RESPONSE_BAD_REQUEST = 128, |
zdshelby | 0:aafd54b05111 | 60 | COAP_MSG_CODE_RESPONSE_UNAUTHORIZED = 129, |
zdshelby | 0:aafd54b05111 | 61 | COAP_MSG_CODE_RESPONSE_BAD_OPTION = 130, |
zdshelby | 0:aafd54b05111 | 62 | COAP_MSG_CODE_RESPONSE_FORBIDDEN = 131, |
zdshelby | 0:aafd54b05111 | 63 | COAP_MSG_CODE_RESPONSE_NOT_FOUND = 132, |
zdshelby | 0:aafd54b05111 | 64 | COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED = 133, |
zdshelby | 0:aafd54b05111 | 65 | COAP_MSG_CODE_RESPONSE_NOT_ACCEPTABLE = 134, |
zdshelby | 0:aafd54b05111 | 66 | COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_INCOMPLETE = 136, |
zdshelby | 0:aafd54b05111 | 67 | COAP_MSG_CODE_RESPONSE_PRECONDITION_FAILED = 140, |
zdshelby | 0:aafd54b05111 | 68 | COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE = 141, |
zdshelby | 0:aafd54b05111 | 69 | COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT = 143, |
zdshelby | 0:aafd54b05111 | 70 | COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR = 160, |
zdshelby | 0:aafd54b05111 | 71 | COAP_MSG_CODE_RESPONSE_NOT_IMPLEMENTED = 161, |
zdshelby | 0:aafd54b05111 | 72 | COAP_MSG_CODE_RESPONSE_BAD_GATEWAY = 162, |
zdshelby | 0:aafd54b05111 | 73 | COAP_MSG_CODE_RESPONSE_SERVICE_UNAVAILABLE = 163, |
zdshelby | 0:aafd54b05111 | 74 | COAP_MSG_CODE_RESPONSE_GATEWAY_TIMEOUT = 164, |
zdshelby | 0:aafd54b05111 | 75 | COAP_MSG_CODE_RESPONSE_PROXYING_NOT_SUPPORTED = 165 |
zdshelby | 0:aafd54b05111 | 76 | } sn_coap_msg_code_e; |
zdshelby | 0:aafd54b05111 | 77 | |
zdshelby | 0:aafd54b05111 | 78 | /** |
zdshelby | 0:aafd54b05111 | 79 | * \brief Enumeration for CoAP Option number, used in CoAP Header |
zdshelby | 0:aafd54b05111 | 80 | */ |
zdshelby | 0:aafd54b05111 | 81 | typedef enum sn_coap_option_numbers_ |
zdshelby | 0:aafd54b05111 | 82 | { |
zdshelby | 0:aafd54b05111 | 83 | COAP_OPTION_IF_MATCH = 1, |
zdshelby | 0:aafd54b05111 | 84 | COAP_OPTION_URI_HOST = 3, |
zdshelby | 0:aafd54b05111 | 85 | COAP_OPTION_ETAG = 4, |
zdshelby | 0:aafd54b05111 | 86 | COAP_OPTION_IF_NONE_MATCH = 5, |
zdshelby | 0:aafd54b05111 | 87 | COAP_OPTION_OBSERVE = 6, |
zdshelby | 0:aafd54b05111 | 88 | COAP_OPTION_URI_PORT = 7, |
zdshelby | 0:aafd54b05111 | 89 | COAP_OPTION_LOCATION_PATH = 8, |
zdshelby | 0:aafd54b05111 | 90 | COAP_OPTION_URI_PATH = 11, |
zdshelby | 0:aafd54b05111 | 91 | COAP_OPTION_CONTENT_FORMAT = 12, |
zdshelby | 0:aafd54b05111 | 92 | COAP_OPTION_MAX_AGE = 14, |
zdshelby | 0:aafd54b05111 | 93 | COAP_OPTION_URI_QUERY = 15, |
zdshelby | 0:aafd54b05111 | 94 | COAP_OPTION_ACCEPT = 17, |
zdshelby | 0:aafd54b05111 | 95 | COAP_OPTION_LOCATION_QUERY = 20, |
zdshelby | 0:aafd54b05111 | 96 | COAP_OPTION_BLOCK2 = 23, |
zdshelby | 0:aafd54b05111 | 97 | COAP_OPTION_BLOCK1 = 27, |
zdshelby | 0:aafd54b05111 | 98 | COAP_OPTION_PROXY_URI = 35, |
zdshelby | 0:aafd54b05111 | 99 | COAP_OPTION_PROXY_SCHEME = 39, |
zdshelby | 0:aafd54b05111 | 100 | COAP_OPTION_SIZE1 = 60 |
zdshelby | 0:aafd54b05111 | 101 | // 128 = (Reserved) |
zdshelby | 0:aafd54b05111 | 102 | // 132 = (Reserved) |
zdshelby | 0:aafd54b05111 | 103 | // 136 = (Reserved) |
zdshelby | 0:aafd54b05111 | 104 | } sn_coap_option_numbers_e; |
zdshelby | 0:aafd54b05111 | 105 | |
zdshelby | 0:aafd54b05111 | 106 | /** |
zdshelby | 0:aafd54b05111 | 107 | * \brief Enumeration for CoAP Content Format codes |
zdshelby | 0:aafd54b05111 | 108 | */ |
zdshelby | 0:aafd54b05111 | 109 | typedef enum sn_coap_content_format_ |
zdshelby | 0:aafd54b05111 | 110 | { |
zdshelby | 0:aafd54b05111 | 111 | COAP_CT_NONE = -1, |
zdshelby | 0:aafd54b05111 | 112 | COAP_CT_TEXT_PLAIN = 0, |
zdshelby | 0:aafd54b05111 | 113 | COAP_CT_LINK_FORMAT = 40, |
zdshelby | 0:aafd54b05111 | 114 | COAP_CT_XML = 41, |
zdshelby | 0:aafd54b05111 | 115 | COAP_CT_OCTET_STREAM = 42, |
zdshelby | 0:aafd54b05111 | 116 | COAP_CT_EXI = 47, |
zdshelby | 0:aafd54b05111 | 117 | COAP_CT_JSON = 50, |
zdshelby | 0:aafd54b05111 | 118 | } sn_coap_content_format_e; |
zdshelby | 0:aafd54b05111 | 119 | |
zdshelby | 0:aafd54b05111 | 120 | /** |
zdshelby | 0:aafd54b05111 | 121 | * \brief Enumeration for CoAP status, used in CoAP Header |
zdshelby | 0:aafd54b05111 | 122 | */ |
zdshelby | 0:aafd54b05111 | 123 | typedef enum sn_coap_status_ |
zdshelby | 0:aafd54b05111 | 124 | { |
zdshelby | 0:aafd54b05111 | 125 | COAP_STATUS_OK = 0, /**< Default value is OK */ |
zdshelby | 0:aafd54b05111 | 126 | COAP_STATUS_PARSER_ERROR_IN_HEADER = 1, /**< CoAP will send Reset message to invalid message sender */ |
zdshelby | 0:aafd54b05111 | 127 | COAP_STATUS_PARSER_DUPLICATED_MSG = 2, /**< CoAP will send Acknowledgement message to duplicated message sender */ |
zdshelby | 0:aafd54b05111 | 128 | COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVING = 3, /**< User will get whole message after all message blocks received. |
zdshelby | 0:aafd54b05111 | 129 | User must release messages with this status. */ |
zdshelby | 0:aafd54b05111 | 130 | COAP_STATUS_PARSER_BLOCKWISE_ACK = 4, /**< Acknowledgement for sent Blockwise message received */ |
zdshelby | 0:aafd54b05111 | 131 | COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED = 5, /**< Blockwise message received but not supported by compiling switch */ |
zdshelby | 0:aafd54b05111 | 132 | COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED = 6 /**< Blockwise message fully received and returned to app. |
zdshelby | 0:aafd54b05111 | 133 | User must take care of releasing whole payload of the blockwise messages */ |
zdshelby | 0:aafd54b05111 | 134 | } sn_coap_status_e; |
zdshelby | 0:aafd54b05111 | 135 | |
zdshelby | 0:aafd54b05111 | 136 | |
zdshelby | 0:aafd54b05111 | 137 | /* * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 138 | /* * * * STRUCTURES * * * */ |
zdshelby | 0:aafd54b05111 | 139 | /* * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 140 | |
zdshelby | 0:aafd54b05111 | 141 | /** |
zdshelby | 0:aafd54b05111 | 142 | * \brief Structure for CoAP Options |
zdshelby | 0:aafd54b05111 | 143 | */ |
zdshelby | 0:aafd54b05111 | 144 | typedef struct sn_coap_options_list_ |
zdshelby | 0:aafd54b05111 | 145 | { |
zdshelby | 0:aafd54b05111 | 146 | |
zdshelby | 0:aafd54b05111 | 147 | uint8_t max_age_len; /**< 0-4 bytes. */ |
zdshelby | 0:aafd54b05111 | 148 | uint8_t *max_age_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 149 | |
zdshelby | 0:aafd54b05111 | 150 | uint16_t proxy_uri_len; /**< 1-1034 bytes. */ |
zdshelby | 0:aafd54b05111 | 151 | uint8_t *proxy_uri_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 152 | |
zdshelby | 0:aafd54b05111 | 153 | uint8_t etag_len; /**< 1-8 bytes. Repeatable */ |
zdshelby | 0:aafd54b05111 | 154 | uint8_t *etag_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 155 | |
zdshelby | 0:aafd54b05111 | 156 | uint16_t uri_host_len; /**< 1-255 bytes. */ |
zdshelby | 0:aafd54b05111 | 157 | uint8_t *uri_host_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 158 | |
zdshelby | 0:aafd54b05111 | 159 | uint16_t location_path_len; /**< 0-255 bytes. Repeatable */ |
zdshelby | 0:aafd54b05111 | 160 | uint8_t *location_path_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 161 | |
zdshelby | 0:aafd54b05111 | 162 | uint8_t uri_port_len; /**< 0-2 bytes. */ |
zdshelby | 0:aafd54b05111 | 163 | uint8_t *uri_port_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 164 | |
zdshelby | 0:aafd54b05111 | 165 | uint16_t location_query_len; /**< 0-255 bytes. Repeatable */ |
zdshelby | 0:aafd54b05111 | 166 | uint8_t *location_query_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 167 | |
zdshelby | 0:aafd54b05111 | 168 | uint8_t observe; |
zdshelby | 0:aafd54b05111 | 169 | uint8_t observe_len; /**< 0-2 bytes. */ |
zdshelby | 0:aafd54b05111 | 170 | uint8_t *observe_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 171 | |
zdshelby | 0:aafd54b05111 | 172 | uint8_t accept_len; /**< 0-2 bytes. Repeatable */ |
zdshelby | 0:aafd54b05111 | 173 | uint8_t *accept_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 174 | |
zdshelby | 0:aafd54b05111 | 175 | uint16_t uri_query_len; /**< 1-255 bytes. Repeatable */ |
zdshelby | 0:aafd54b05111 | 176 | uint8_t *uri_query_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 177 | |
zdshelby | 0:aafd54b05111 | 178 | uint8_t block1_len; /**< 0-3 bytes. */ |
zdshelby | 0:aafd54b05111 | 179 | uint8_t *block1_ptr; /**< Not for User */ |
zdshelby | 0:aafd54b05111 | 180 | |
zdshelby | 0:aafd54b05111 | 181 | uint8_t block2_len; /**< 0-3 bytes. */ |
zdshelby | 0:aafd54b05111 | 182 | uint8_t *block2_ptr; /**< Not for User */ |
zdshelby | 0:aafd54b05111 | 183 | } sn_coap_options_list_s; |
zdshelby | 0:aafd54b05111 | 184 | |
zdshelby | 0:aafd54b05111 | 185 | |
zdshelby | 0:aafd54b05111 | 186 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
zdshelby | 0:aafd54b05111 | 187 | /* !!! Main CoAP message struct !!! */ |
zdshelby | 0:aafd54b05111 | 188 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
zdshelby | 0:aafd54b05111 | 189 | |
zdshelby | 0:aafd54b05111 | 190 | /** |
zdshelby | 0:aafd54b05111 | 191 | * \brief Main CoAP message struct |
zdshelby | 0:aafd54b05111 | 192 | */ |
zdshelby | 0:aafd54b05111 | 193 | typedef struct sn_coap_hdr_ |
zdshelby | 0:aafd54b05111 | 194 | { |
zdshelby | 0:aafd54b05111 | 195 | sn_coap_status_e coap_status; /**< Used for telling to User special cases when parsing message */ |
zdshelby | 0:aafd54b05111 | 196 | |
zdshelby | 0:aafd54b05111 | 197 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 198 | /* * * * Header * * * */ |
zdshelby | 0:aafd54b05111 | 199 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 200 | |
zdshelby | 0:aafd54b05111 | 201 | sn_coap_msg_type_e msg_type; /**< Confirmable, Non-Confirmable, Acknowledgement or Reset */ |
zdshelby | 0:aafd54b05111 | 202 | sn_coap_msg_code_e msg_code; /**< Empty: 0; Requests: 1-31; Responses: 64-191 */ |
zdshelby | 0:aafd54b05111 | 203 | uint16_t msg_id; /**< Message ID. Parser sets parsed message ID, builder sets message ID of built coap message */ |
zdshelby | 0:aafd54b05111 | 204 | |
zdshelby | 0:aafd54b05111 | 205 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 206 | /* * * * Options * * * */ |
zdshelby | 0:aafd54b05111 | 207 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 208 | |
zdshelby | 0:aafd54b05111 | 209 | /* Here are most often used Options */ |
zdshelby | 0:aafd54b05111 | 210 | |
zdshelby | 0:aafd54b05111 | 211 | uint16_t uri_path_len; /**< 0-255 bytes. Repeatable. */ |
zdshelby | 0:aafd54b05111 | 212 | uint8_t *uri_path_ptr; /**< Must be set to NULL if not used. E.g: temp1/temp2 */ |
zdshelby | 0:aafd54b05111 | 213 | |
zdshelby | 0:aafd54b05111 | 214 | uint8_t token_len; /**< 1-8 bytes. */ |
zdshelby | 0:aafd54b05111 | 215 | uint8_t *token_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 216 | |
zdshelby | 0:aafd54b05111 | 217 | uint8_t content_type_len; /**< 0-2 bytes. */ |
zdshelby | 0:aafd54b05111 | 218 | uint8_t *content_type_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 219 | |
zdshelby | 0:aafd54b05111 | 220 | /* Here are not so often used Options */ |
zdshelby | 0:aafd54b05111 | 221 | sn_coap_options_list_s *options_list_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 222 | |
zdshelby | 0:aafd54b05111 | 223 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 224 | /* * * * Payload * * * */ |
zdshelby | 0:aafd54b05111 | 225 | /* * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 226 | |
zdshelby | 0:aafd54b05111 | 227 | uint16_t payload_len; /**< Must be set to zero if not used */ |
zdshelby | 0:aafd54b05111 | 228 | uint8_t *payload_ptr; /**< Must be set to NULL if not used */ |
zdshelby | 0:aafd54b05111 | 229 | } sn_coap_hdr_s; |
zdshelby | 0:aafd54b05111 | 230 | |
zdshelby | 0:aafd54b05111 | 231 | /* * * * * * * * * * * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 232 | /* * * * EXTERNAL FUNCTION PROTOTYPES * * * */ |
zdshelby | 0:aafd54b05111 | 233 | /* * * * * * * * * * * * * * * * * * * * * * */ |
zdshelby | 0:aafd54b05111 | 234 | |
zdshelby | 0:aafd54b05111 | 235 | /** |
zdshelby | 0:aafd54b05111 | 236 | * \brief Sets the memory allocation and deallocation functions the library will use, and must be called first. |
zdshelby | 0:aafd54b05111 | 237 | */ |
zdshelby | 0:aafd54b05111 | 238 | extern void sn_coap_builder_and_parser_init(void* (*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void*)); |
zdshelby | 0:aafd54b05111 | 239 | |
zdshelby | 0:aafd54b05111 | 240 | /** |
zdshelby | 0:aafd54b05111 | 241 | * \brief Parses an incoming message buffer to a CoAP header structure. |
zdshelby | 0:aafd54b05111 | 242 | */ |
zdshelby | 0:aafd54b05111 | 243 | extern sn_coap_hdr_s *sn_coap_parser(uint16_t packet_data_len, uint8_t *packet_data_ptr, coap_version_e *coap_version_ptr); |
zdshelby | 0:aafd54b05111 | 244 | |
zdshelby | 0:aafd54b05111 | 245 | /** |
zdshelby | 0:aafd54b05111 | 246 | * \brief Releases any memory allocated by a CoAP message structure. |
zdshelby | 0:aafd54b05111 | 247 | */ |
zdshelby | 0:aafd54b05111 | 248 | extern void sn_coap_parser_release_allocated_coap_msg_mem(sn_coap_hdr_s *freed_coap_msg_ptr); |
zdshelby | 0:aafd54b05111 | 249 | |
zdshelby | 0:aafd54b05111 | 250 | /** |
zdshelby | 0:aafd54b05111 | 251 | * \brief Builds an outgoing message buffer from a CoAP header structure. |
zdshelby | 0:aafd54b05111 | 252 | */ |
zdshelby | 0:aafd54b05111 | 253 | extern int16_t sn_coap_builder(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr); |
zdshelby | 0:aafd54b05111 | 254 | |
zdshelby | 0:aafd54b05111 | 255 | /** |
zdshelby | 0:aafd54b05111 | 256 | * \brief Calculates the needed message buffer size from a CoAP message structure. |
zdshelby | 0:aafd54b05111 | 257 | */ |
zdshelby | 0:aafd54b05111 | 258 | extern uint16_t sn_coap_builder_calc_needed_packet_data_size(sn_coap_hdr_s *src_coap_msg_ptr); |
zdshelby | 0:aafd54b05111 | 259 | |
zdshelby | 0:aafd54b05111 | 260 | /** |
zdshelby | 0:aafd54b05111 | 261 | * \brief Automates the building of a response to an incoming request. |
zdshelby | 0:aafd54b05111 | 262 | */ |
zdshelby | 0:aafd54b05111 | 263 | extern sn_coap_hdr_s *sn_coap_build_response(sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code); |
zdshelby | 0:aafd54b05111 | 264 | |
zdshelby | 0:aafd54b05111 | 265 | /** |
zdshelby | 0:aafd54b05111 | 266 | * \brief CoAP packet debugging. |
zdshelby | 0:aafd54b05111 | 267 | */ |
zdshelby | 0:aafd54b05111 | 268 | extern void sn_coap_packet_debug(sn_coap_hdr_s *coap_packet_ptr); |
zdshelby | 0:aafd54b05111 | 269 | |
zdshelby | 0:aafd54b05111 | 270 | #endif /* SN_COAP_HEADER_H_ */ |
zdshelby | 0:aafd54b05111 | 271 | |
zdshelby | 0:aafd54b05111 | 272 | #ifdef __cplusplus |
zdshelby | 0:aafd54b05111 | 273 | } |
zdshelby | 0:aafd54b05111 | 274 | #endif |
zdshelby | 0:aafd54b05111 | 275 |