|
9 | 9 | /** |
10 | 10 | * @defgroup net_gcoap CoAP |
11 | 11 | * @ingroup net |
12 | | - * @brief sock-based implementation of CoAP protocol, RFC 7252 |
13 | | - * |
14 | | - * ## Architecture ## |
15 | | - * Requests and responses are exchanged via an asynchronous RIOT message |
16 | | - * processing thread. Depends on nanocoap for base level structs and |
17 | | - * functionality. |
18 | | - * |
19 | | - * Uses a single UDP port for communication to support RFC 6282 compression. |
| 12 | + * @brief High-level interface to CoAP messaging |
| 13 | + * |
| 14 | + * gcoap internalizes the event processing loop and provides a simple API for |
| 15 | + * writing CoAP (RFC 7252) protocol data. Server operation requires a list of |
| 16 | + * resource paths with callbacks for writing the response. Client operation uses |
| 17 | + * a function to send a request, with a callback for reading the server |
| 18 | + * response. Generation of request/response data requires from one to three |
| 19 | + * well-defined steps, depending on inclusion of a payload. |
| 20 | + * |
| 21 | + * Internally, requests and responses are exchanged via the sock application |
| 22 | + * networking API from a RIOT message processing thread. Depends on the nanocoap |
| 23 | + * package for base level structs and functionality. Uses a single UDP port for |
| 24 | + * communication to support RFC 6282 compression. |
20 | 25 | * |
21 | 26 | * ## Server Operation ## |
22 | 27 | * |
|
61 | 66 | * |
62 | 67 | * ## Client Operation ## |
63 | 68 | * |
64 | | - * gcoap uses RIOT's asynchronous messaging facility to send and receive |
65 | | - * messages. So, client operation includes two phases: creating and sending a |
66 | | - * request, and handling the response aynchronously in a client supplied |
67 | | - * callback. See `examples/gcoap/gcoap_cli.c` for a simple example of sending |
68 | | - * a request and reading the response. |
| 69 | + * Client operation includes two phases: creating and sending a request, and |
| 70 | + * handling the response aynchronously in a client supplied callback. See |
| 71 | + * `examples/gcoap/gcoap_cli.c` for a simple example of sending a request and |
| 72 | + * reading the response. |
69 | 73 | * |
70 | 74 | * ### Creating a request ### |
71 | 75 | * |
|
85 | 89 | * as described above. The gcoap_request() function is inline, and uses those |
86 | 90 | * two functions. |
87 | 91 | * |
88 | | - * Finally, call gcoap_req_send() with the destination host and port, as well |
89 | | - * as a callback function for the host's response. |
| 92 | + * Finally, call gcoap_req_send2() for the destination endpoint, as well as a |
| 93 | + * callback function for the host's response. |
90 | 94 | * |
91 | 95 | * ### Handling the response ### |
92 | 96 | * |
|
114 | 118 | * header and the payload. So, gcoap provides space in the buffer for them in |
115 | 119 | * the request/response ...init() function, and then writes them during |
116 | 120 | * gcoap_finish(). We trade some inefficiency/work in the buffer for |
117 | | - * simplicity for the user. |
| 121 | + * simplicity in the API. |
118 | 122 | * |
119 | 123 | * ### Waiting for a response ### |
120 | 124 | * |
121 | | - * We take advantage of RIOT's GNRC stack by using an xtimer to wait for a |
122 | | - * response, so the gcoap thread does not block while waiting. The user is |
123 | | - * notified via the same callback whether the message is received or the wait |
| 125 | + * We take advantage of RIOT's asynchronous messaging by using an xtimer to wait |
| 126 | + * for a response, so the gcoap thread does not block while waiting. The user is |
| 127 | + * notified via the same callback, whether the message is received or the wait |
124 | 128 | * times out. We track the response with an entry in the |
125 | 129 | * `_coap_state.open_reqs` array. |
126 | 130 | * |
|
0 commit comments