Skip to content

Commit 9c7672b

Browse files
kartbenfabiobaltieri
authored andcommitted
net: coap: Improve CoAP Doxygen comments
Improve the Doxygen comments for coap.h by adding missing documentation for most of the compilation units. Signed-off-by: Benjamin Cabé <[email protected]>
1 parent fea507f commit 9c7672b

File tree

1 file changed

+95
-61
lines changed

1 file changed

+95
-61
lines changed

include/zephyr/net/coap.h

Lines changed: 95 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ extern "C" {
4242
* Refer to RFC 7252, section 12.2 for more information.
4343
*/
4444
enum coap_option_num {
45-
COAP_OPTION_IF_MATCH = 1,
46-
COAP_OPTION_URI_HOST = 3,
47-
COAP_OPTION_ETAG = 4,
48-
COAP_OPTION_IF_NONE_MATCH = 5,
49-
COAP_OPTION_OBSERVE = 6,
50-
COAP_OPTION_URI_PORT = 7,
51-
COAP_OPTION_LOCATION_PATH = 8,
52-
COAP_OPTION_URI_PATH = 11,
53-
COAP_OPTION_CONTENT_FORMAT = 12,
54-
COAP_OPTION_MAX_AGE = 14,
55-
COAP_OPTION_URI_QUERY = 15,
56-
COAP_OPTION_ACCEPT = 17,
57-
COAP_OPTION_LOCATION_QUERY = 20,
58-
COAP_OPTION_BLOCK2 = 23,
59-
COAP_OPTION_BLOCK1 = 27,
60-
COAP_OPTION_SIZE2 = 28,
61-
COAP_OPTION_PROXY_URI = 35,
62-
COAP_OPTION_PROXY_SCHEME = 39,
63-
COAP_OPTION_SIZE1 = 60,
45+
COAP_OPTION_IF_MATCH = 1, /**< If-Match */
46+
COAP_OPTION_URI_HOST = 3, /**< Uri-Host */
47+
COAP_OPTION_ETAG = 4, /**< ETag */
48+
COAP_OPTION_IF_NONE_MATCH = 5, /**< If-None-Match */
49+
COAP_OPTION_OBSERVE = 6, /**< Observe (RFC 7641) */
50+
COAP_OPTION_URI_PORT = 7, /**< Uri-Port */
51+
COAP_OPTION_LOCATION_PATH = 8, /**< Location-Path */
52+
COAP_OPTION_URI_PATH = 11, /**< Uri-Path */
53+
COAP_OPTION_CONTENT_FORMAT = 12, /**< Content-Format */
54+
COAP_OPTION_MAX_AGE = 14, /**< Max-Age */
55+
COAP_OPTION_URI_QUERY = 15, /**< Uri-Query */
56+
COAP_OPTION_ACCEPT = 17, /**< Accept */
57+
COAP_OPTION_LOCATION_QUERY = 20, /**< Location-Query */
58+
COAP_OPTION_BLOCK2 = 23, /**< Block2 (RFC 7959) */
59+
COAP_OPTION_BLOCK1 = 27, /**< Block1 (RFC 7959) */
60+
COAP_OPTION_SIZE2 = 28, /**< Size2 (RFC 7959) */
61+
COAP_OPTION_PROXY_URI = 35, /**< Proxy-Uri */
62+
COAP_OPTION_PROXY_SCHEME = 39, /**< Proxy-Scheme */
63+
COAP_OPTION_SIZE1 = 60 /**< Size1 */
6464
};
6565

6666
/**
@@ -69,13 +69,13 @@ enum coap_option_num {
6969
* To be used when creating a request or a response.
7070
*/
7171
enum coap_method {
72-
COAP_METHOD_GET = 1,
73-
COAP_METHOD_POST = 2,
74-
COAP_METHOD_PUT = 3,
75-
COAP_METHOD_DELETE = 4,
76-
COAP_METHOD_FETCH = 5,
77-
COAP_METHOD_PATCH = 6,
78-
COAP_METHOD_IPATCH = 7,
72+
COAP_METHOD_GET = 1, /**< GET */
73+
COAP_METHOD_POST = 2, /**< POST */
74+
COAP_METHOD_PUT = 3, /**< PUT */
75+
COAP_METHOD_DELETE = 4, /**< DELETE */
76+
COAP_METHOD_FETCH = 5, /**< FETCH */
77+
COAP_METHOD_PATCH = 6, /**< PATCH */
78+
COAP_METHOD_IPATCH = 7, /**< IPATCH */
7979
};
8080

8181
#define COAP_REQUEST_MASK 0x07
@@ -120,7 +120,7 @@ enum coap_msgtype {
120120
* @param class Class of the response code (ex. 2, 4, 5, ...)
121121
* @param det Detail of the response code
122122
* @return Response code literal
123-
*/
123+
*/
124124
#define COAP_MAKE_RESPONSE_CODE(class, det) ((class << 5) | (det))
125125

126126
/**
@@ -129,33 +129,60 @@ enum coap_msgtype {
129129
* To be used when creating a response.
130130
*/
131131
enum coap_response_code {
132+
/** 2.00 - OK */
132133
COAP_RESPONSE_CODE_OK = COAP_MAKE_RESPONSE_CODE(2, 0),
134+
/** 2.01 - Created */
133135
COAP_RESPONSE_CODE_CREATED = COAP_MAKE_RESPONSE_CODE(2, 1),
136+
/** 2.02 - Deleted */
134137
COAP_RESPONSE_CODE_DELETED = COAP_MAKE_RESPONSE_CODE(2, 2),
138+
/** 2.03 - Valid */
135139
COAP_RESPONSE_CODE_VALID = COAP_MAKE_RESPONSE_CODE(2, 3),
140+
/** 2.04 - Changed */
136141
COAP_RESPONSE_CODE_CHANGED = COAP_MAKE_RESPONSE_CODE(2, 4),
142+
/** 2.05 - Content */
137143
COAP_RESPONSE_CODE_CONTENT = COAP_MAKE_RESPONSE_CODE(2, 5),
144+
/** 2.31 - Continue */
138145
COAP_RESPONSE_CODE_CONTINUE = COAP_MAKE_RESPONSE_CODE(2, 31),
146+
/** 4.00 - Bad Request */
139147
COAP_RESPONSE_CODE_BAD_REQUEST = COAP_MAKE_RESPONSE_CODE(4, 0),
148+
/** 4.01 - Unauthorized */
140149
COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_MAKE_RESPONSE_CODE(4, 1),
150+
/** 4.02 - Bad Option */
141151
COAP_RESPONSE_CODE_BAD_OPTION = COAP_MAKE_RESPONSE_CODE(4, 2),
152+
/** 4.03 - Forbidden */
142153
COAP_RESPONSE_CODE_FORBIDDEN = COAP_MAKE_RESPONSE_CODE(4, 3),
154+
/** 4.04 - Not Found */
143155
COAP_RESPONSE_CODE_NOT_FOUND = COAP_MAKE_RESPONSE_CODE(4, 4),
156+
/** 4.05 - Method Not Allowed */
144157
COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_MAKE_RESPONSE_CODE(4, 5),
158+
/** 4.06 - Not Acceptable */
145159
COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_MAKE_RESPONSE_CODE(4, 6),
160+
/** 4.08 - Request Entity Incomplete */
146161
COAP_RESPONSE_CODE_INCOMPLETE = COAP_MAKE_RESPONSE_CODE(4, 8),
162+
/** 4.12 - Precondition Failed */
147163
COAP_RESPONSE_CODE_CONFLICT = COAP_MAKE_RESPONSE_CODE(4, 9),
164+
/** 4.12 - Precondition Failed */
148165
COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_MAKE_RESPONSE_CODE(4, 12),
166+
/** 4.13 - Request Entity Too Large */
149167
COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_MAKE_RESPONSE_CODE(4, 13),
168+
/** 4.15 - Unsupported Content-Format */
150169
COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT =
151170
COAP_MAKE_RESPONSE_CODE(4, 15),
171+
/** 4.22 - Unprocessable Entity */
152172
COAP_RESPONSE_CODE_UNPROCESSABLE_ENTITY = COAP_MAKE_RESPONSE_CODE(4, 22),
173+
/** 4.29 - Too Many Requests */
153174
COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_MAKE_RESPONSE_CODE(4, 29),
175+
/** 5.00 - Internal Server Error */
154176
COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_MAKE_RESPONSE_CODE(5, 0),
177+
/** 5.01 - Not Implemented */
155178
COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_MAKE_RESPONSE_CODE(5, 1),
179+
/** 5.02 - Bad Gateway */
156180
COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_MAKE_RESPONSE_CODE(5, 2),
181+
/** 5.03 - Service Unavailable */
157182
COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_MAKE_RESPONSE_CODE(5, 3),
183+
/** 5.04 - Gateway Timeout */
158184
COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_MAKE_RESPONSE_CODE(5, 4),
185+
/** 5.05 - Proxying Not Supported */
159186
COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED =
160187
COAP_MAKE_RESPONSE_CODE(5, 5)
161188
};
@@ -170,15 +197,15 @@ enum coap_response_code {
170197
* To be used when encoding or decoding a Content-Format option.
171198
*/
172199
enum coap_content_format {
173-
COAP_CONTENT_FORMAT_TEXT_PLAIN = 0, /* charset=urf-8 */
174-
COAP_CONTENT_FORMAT_APP_LINK_FORMAT = 40,
175-
COAP_CONTENT_FORMAT_APP_XML = 41,
176-
COAP_CONTENT_FORMAT_APP_OCTET_STREAM = 42,
177-
COAP_CONTENT_FORMAT_APP_EXI = 47,
178-
COAP_CONTENT_FORMAT_APP_JSON = 50,
179-
COAP_CONTENT_FORMAT_APP_JSON_PATCH_JSON = 51,
180-
COAP_CONTENT_FORMAT_APP_MERGE_PATCH_JSON = 52,
181-
COAP_CONTENT_FORMAT_APP_CBOR = 60,
200+
COAP_CONTENT_FORMAT_TEXT_PLAIN = 0, /**< text/plain;charset=utf-8 */
201+
COAP_CONTENT_FORMAT_APP_LINK_FORMAT = 40, /**< application/link-format */
202+
COAP_CONTENT_FORMAT_APP_XML = 41, /**< application/xml */
203+
COAP_CONTENT_FORMAT_APP_OCTET_STREAM = 42, /**< application/octet-stream */
204+
COAP_CONTENT_FORMAT_APP_EXI = 47, /**< application/exi */
205+
COAP_CONTENT_FORMAT_APP_JSON = 50, /**< application/json */
206+
COAP_CONTENT_FORMAT_APP_JSON_PATCH_JSON = 51, /**< application/json-patch+json */
207+
COAP_CONTENT_FORMAT_APP_MERGE_PATCH_JSON = 52, /**< application/merge-patch+json */
208+
COAP_CONTENT_FORMAT_APP_CBOR = 60 /**< application/cbor */
182209
};
183210

184211
/* block option helper */
@@ -239,25 +266,32 @@ struct coap_observer {
239266
* @brief Representation of a CoAP Packet.
240267
*/
241268
struct coap_packet {
242-
uint8_t *data; /* User allocated buffer */
243-
uint16_t offset; /* CoAP lib maintains offset while adding data */
244-
uint16_t max_len; /* Max CoAP packet data length */
245-
uint8_t hdr_len; /* CoAP header length */
246-
uint16_t opt_len; /* Total options length (delta + len + value) */
247-
uint16_t delta; /* Used for delta calculation in CoAP packet */
248-
#if defined(CONFIG_COAP_KEEP_USER_DATA)
249-
void *user_data; /* Application specific user data */
269+
uint8_t *data; /**< User allocated buffer */
270+
uint16_t offset; /**< CoAP lib maintains offset while adding data */
271+
uint16_t max_len; /**< Max CoAP packet data length */
272+
uint8_t hdr_len; /**< CoAP header length */
273+
uint16_t opt_len; /**< Total options length (delta + len + value) */
274+
uint16_t delta; /**< Used for delta calculation in CoAP packet */
275+
#if defined(CONFIG_COAP_KEEP_USER_DATA) || defined(DOXGEN)
276+
/**
277+
* Application specific user data.
278+
* Only available when @kconfig{CONFIG_COAP_KEEP_USER_DATA} is enabled.
279+
*/
280+
void *user_data;
250281
#endif
251282
};
252283

284+
/**
285+
* @brief Representation of a CoAP option.
286+
*/
253287
struct coap_option {
254-
uint16_t delta;
288+
uint16_t delta; /**< Option delta */
255289
#if defined(CONFIG_COAP_EXTENDED_OPTIONS_LEN)
256290
uint16_t len;
257291
uint8_t value[CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE];
258292
#else
259-
uint8_t len;
260-
uint8_t value[12];
293+
uint8_t len; /**< Option length */
294+
uint8_t value[12]; /**< Option value */
261295
#endif
262296
};
263297

@@ -277,13 +311,13 @@ typedef int (*coap_reply_t)(const struct coap_packet *response,
277311
* @brief Represents a request awaiting for an acknowledgment (ACK).
278312
*/
279313
struct coap_pending {
280-
struct sockaddr addr;
281-
int64_t t0;
282-
uint32_t timeout;
283-
uint16_t id;
284-
uint8_t *data;
285-
uint16_t len;
286-
uint8_t retries;
314+
struct sockaddr addr; /**< Remote address */
315+
int64_t t0; /**< Time when the request was sent */
316+
uint32_t timeout; /**< Timeout in ms */
317+
uint16_t id; /**< Message id */
318+
uint8_t *data; /**< User allocated buffer */
319+
uint16_t len; /**< Length of the CoAP packet */
320+
uint8_t retries; /**< Number of times the request has been sent */
287321
};
288322

289323
/**
@@ -563,13 +597,13 @@ int coap_handle_request(struct coap_packet *cpkt,
563597
* https://tools.ietf.org/html/rfc7959
564598
*/
565599
enum coap_block_size {
566-
COAP_BLOCK_16,
567-
COAP_BLOCK_32,
568-
COAP_BLOCK_64,
569-
COAP_BLOCK_128,
570-
COAP_BLOCK_256,
571-
COAP_BLOCK_512,
572-
COAP_BLOCK_1024,
600+
COAP_BLOCK_16, /**< 16-byte block size */
601+
COAP_BLOCK_32, /**< 32-byte block size */
602+
COAP_BLOCK_64, /**< 64-byte block size */
603+
COAP_BLOCK_128, /**< 128-byte block size */
604+
COAP_BLOCK_256, /**< 256-byte block size */
605+
COAP_BLOCK_512, /**< 512-byte block size */
606+
COAP_BLOCK_1024, /**< 1024-byte block size */
573607
};
574608

575609
/**

0 commit comments

Comments
 (0)