Skip to content

Commit 2af5e82

Browse files
committed
Updated documentation
1 parent e3eca42 commit 2af5e82

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

examples/gcoap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gcoap Example
22

3-
This application provides command line access to gcoap, a GNRC implementation of CoAP. See the [CoAP spec][1] for background, and the Modules>Networking>GNRC>CoAP topic in the source documentation for the structure of the implementation.
3+
This application provides command line access to gcoap, a high-level API for CoAP messaging. See the [CoAP spec][1] for background, and the Modules>Networking>GNRC>CoAP topic in the source documentation for the structure of the implementation.
44

55
We support two setup options for this example:
66

sys/include/net/gcoap.h

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
/**
1010
* @defgroup net_gcoap CoAP
1111
* @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.
2025
*
2126
* ## Server Operation ##
2227
*
@@ -61,11 +66,10 @@
6166
*
6267
* ## Client Operation ##
6368
*
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.
6973
*
7074
* ### Creating a request ###
7175
*
@@ -85,8 +89,8 @@
8589
* as described above. The gcoap_request() function is inline, and uses those
8690
* two functions.
8791
*
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.
9094
*
9195
* ### Handling the response ###
9296
*
@@ -114,13 +118,13 @@
114118
* header and the payload. So, gcoap provides space in the buffer for them in
115119
* the request/response ...init() function, and then writes them during
116120
* gcoap_finish(). We trade some inefficiency/work in the buffer for
117-
* simplicity for the user.
121+
* simplicity in the API.
118122
*
119123
* ### Waiting for a response ###
120124
*
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
124128
* times out. We track the response with an entry in the
125129
* `_coap_state.open_reqs` array.
126130
*

0 commit comments

Comments
 (0)