You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/nrf/libraries/networking/nrf_cloud_rest.rst
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Various `nRF Cloud REST API endpoints <nRF Cloud REST API_>`_ are provided for t
22
22
* Sending and receiving device messages.
23
23
* Interacting with location services.
24
24
25
-
All of these functions operate on a:c:struct:`nrf_cloud_rest_context` structure that you must initialize and provide with your desired parameters.
25
+
All of these functions operate on an:c:struct:`nrf_cloud_rest_context` structure that you must initialize and provide with your desired parameters.
26
26
When each function returns, the context contains the status of the API call.
27
27
28
28
Authentication
@@ -31,24 +31,24 @@ Authentication
31
31
Each HTTP/REST request must include a valid JSON Web Token (JWT) that serves as a proof of identity.
32
32
Usually, these tokens are generated based on the `device credentials <nRF Cloud Security_>`_, and must be passed to the ``auth`` parameter of the :c:struct:`nrf_cloud_rest_context` structure.
33
33
To generate a token, call the :c:func:`nrf_cloud_jwt_generate` function, or use the :ref:`lib_modem_jwt` library.
34
-
Alternatively, if you have enabled the :kconfig:option:`NRF_CLOUD_REST_AUTOGEN_JWT` option (along with its dependencies), the nRF Cloud REST library generates a JWT automatically if one is not provided.
34
+
Alternatively, if you have enabled the :kconfig:option:`CONFIG_NRF_CLOUD_REST_AUTOGEN_JWT` option (along with its dependencies), the nRF Cloud REST library generates a JWT automatically if one is not provided.
35
35
36
36
Socket management and reuse
37
37
===========================
38
38
39
39
The socket used for each HTTP request is determined by the ``connect_socket`` parameter of the :c:struct:`nrf_cloud_rest_context` structure.
40
40
If a valid socket file descriptor is passed, this socket is used.
41
-
If -1 is passed, a socket will be created automatically.
41
+
If ``-1`` is passed, a socket will be created automatically.
42
42
43
43
The selected socket can be reused depending on the passed-in value of the ``keep_alive`` property of the :c:struct:`nrf_cloud_rest_context` structure:
44
44
45
-
* If you set ``keep_alive`` to false, then the selected socket is closed after each request, and the ``connect_socket`` property is reset to ``-1``.
46
-
* If you set ``keep_alive`` to true, the socket remains open and ``connect_socket`` remains unaltered, meaning the socket is reused on the next API call.
45
+
* If you set ``keep_alive`` to false, the selected socket is closed after each request and the ``connect_socket`` property is reset to ``-1``.
46
+
* If you set ``keep_alive`` to true, the socket remains open and ``connect_socket`` remains unaltered, meaning the socket is reused on the next API call.
47
47
48
-
However, if you set ``keep_alive`` to true, make sure that the socket has not been closed externally (for example, due to inactivity) before sending each request.
48
+
However, if you set ``keep_alive`` to true, make sure that the socket has not been closed externally (for example, due to inactivity) before sending further requests.
49
49
Otherwise, the request will be dropped.
50
50
51
-
There are two ways a timed out socket can manifest:
51
+
Timeouts in the socket can happen in two ways:
52
52
53
53
* The socket may be closed immediately on timeout, causing ``-ENOTCONN`` to be returned by the next REST request function call, without reaching nRF Cloud.
54
54
* The socket may be left open, allowing the next REST request to reach nRF Cloud, but the request is ignored and the socket is closed gracefully (FIN,ACK) with null HTTP response.
@@ -81,10 +81,10 @@ If an API call is unsuccessful, the called request function may return a variety
81
81
For instance, ``-ENOTCONN`` if the socket was closed, or was never opened before the request was made.
82
82
* If the remote endpoint closes the connection gracefully without giving a response (a null HTTP response), ``-ESHUTDOWN`` is returned.
83
83
* If the remote endpoint responds with an unexpected HTTP status code (indicating request rejection), ``-EBADMSG`` is returned.
84
-
Possible causes include, but are not limited to: bad endpoint, invalid request data, invalid JWT.
84
+
Possible causes include, but are not limited to: bad endpoint, invalid request data, and invalid JWT.
85
85
* If the response body is empty and the request expects response data, ``-ENODATA`` is returned.
86
86
* If a heap allocation fails, ``-ENOMEM`` is returned.
0 commit comments