Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: lwm2m+coap: Cherry-pick fixes and changes to CoAP and LwM2M #2312

Merged
merged 29 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4189e26
[nrf fromtree] net: lwm2m: Remove hostname_verify flag from context
SeppoTakalo Oct 1, 2024
f8d32d2
[nrf fromtree] net: lwm2m: Add shell command for listing resources
SeppoTakalo Oct 2, 2024
6a95e9b
[nrf fromtree] net: lib: lwm2m: lwm2m_rw_senml_cbor: only assign time…
brandon-exact Oct 17, 2024
535cd0d
[nrf fromtree] net: lwm2m: Add TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 to …
jbr-ia Oct 25, 2024
68691be
[nrf fromtree] tests: net: lib: lwm2m: interop: Fix strip-with-multi-…
pdgendt Nov 13, 2024
337a496
[nrf fromtree] tests: coap_client: Improve socket stubs
SeppoTakalo Nov 11, 2024
bd5832f
[nrf fromtree] tests: coap_client: Add test for duplicate response
SeppoTakalo Nov 11, 2024
ab4be52
[nrf fromtree] tests: coap_client: Add test when separate response is…
SeppoTakalo Nov 11, 2024
effb7a6
[nrf fromtree] tests: coap_client: Improve retry testcases
SeppoTakalo Nov 12, 2024
7bb1a14
[nrf fromtree] tests: coap_client: Add testcase for Ack failure
SeppoTakalo Nov 12, 2024
5edd70f
[nrf fromtree] tests: coap_client: Test for operating on socket while…
SeppoTakalo Nov 12, 2024
1ac36d9
[nrf fromtree] tests: coap_client: Add testcase for observation
SeppoTakalo Nov 12, 2024
a29009d
[nrf fromtree] tests: coap_client: Add testcase for receiving RST
SeppoTakalo Nov 12, 2024
d3d5eee
[nrf fromtree] net: lib: coap_client: Don't clear internal structures…
SeppoTakalo Nov 11, 2024
03c3ded
[nrf fromtree] net: lib: coap_client: Parse incoming MID only once
SeppoTakalo Nov 11, 2024
4569c8d
[nrf fromtree] net: lib: coap_client: Don't match zero length tokens
SeppoTakalo Nov 11, 2024
76834f9
[nrf fromtree] net: lib: coap_client: Drop duplicate responses
SeppoTakalo Nov 11, 2024
f562203
[nrf fromtree] net: lib: coap_client: Return -errno from send_request()
SeppoTakalo Nov 11, 2024
5237d64
[nrf fromtree] net: lib: coap_client: Drop duplicate MID only after r…
SeppoTakalo Nov 11, 2024
1db7923
[nrf fromtree] net: lib: coap_client: All error cases should be repor…
SeppoTakalo Nov 11, 2024
ec45a97
[nrf fromtree] net: lib: coap_client: Stop polling on unneeded sockets
SeppoTakalo Nov 12, 2024
c1fd0f3
[nrf fromtree] net: lib: coap_client: Add API to cancel specific request
SeppoTakalo Nov 13, 2024
764f534
[nrf fromtree] net: lwm2m: add set_socketoptions cb to pull context L…
andi-exact Nov 8, 2024
53e0353
[nrf fromtree] tests: coap_client: Proper slow-down
SeppoTakalo Nov 18, 2024
7f33e22
[nrf fromtree] tests: coap_client: Refactor tests
SeppoTakalo Nov 18, 2024
312b2c9
[nrf fromtree] tests: coap_client: Add test for non-confirmable request
SeppoTakalo Nov 18, 2024
83b90e7
[nrf fromtree] net: lib: coap_client: Fix timeout for separate response
SeppoTakalo Nov 18, 2024
f6004fc
[nrf fromtree] net: lib: coap_client: Release non-confirmable requests
SeppoTakalo Nov 18, 2024
4148a01
[nrf fromtree] net: lib: coap_client: Const pointers in request
SeppoTakalo Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/connectivity/networking/api/lwm2m.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,9 @@ required actions from the server side.
resume :LwM2M engine thread resume
lock :Lock the LwM2M registry
unlock :Unlock the LwM2M registry
obs : List observations
ls : ls [PATH]
List objects, instances, resources



Expand Down
35 changes: 25 additions & 10 deletions include/zephyr/net/coap_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ typedef void (*coap_client_response_cb_t)(int16_t result_code,
* @brief Representation of a CoAP client request.
*/
struct coap_client_request {
enum coap_method method; /**< Method of the request */
bool confirmable; /**< CoAP Confirmable/Non-confirmable message */
const char *path; /**< Path of the requested resource */
enum coap_content_format fmt; /**< Content format to be used */
uint8_t *payload; /**< User allocated buffer for send request */
size_t len; /**< Length of the payload */
coap_client_response_cb_t cb; /**< Callback when response received */
struct coap_client_option *options; /**< Extra options to be added to request */
uint8_t num_options; /**< Number of extra options */
void *user_data; /**< User provided context */
enum coap_method method; /**< Method of the request */
bool confirmable; /**< CoAP Confirmable/Non-confirmable message */
const char *path; /**< Path of the requested resource */
enum coap_content_format fmt; /**< Content format to be used */
const uint8_t *payload; /**< User allocated buffer for send request */
size_t len; /**< Length of the payload */
coap_client_response_cb_t cb; /**< Callback when response received */
const struct coap_client_option *options; /**< Extra options to be added to request */
uint8_t num_options; /**< Number of extra options */
void *user_data; /**< User provided context */
};

/**
Expand Down Expand Up @@ -158,6 +158,21 @@ int coap_client_req(struct coap_client *client, int sock, const struct sockaddr
*/
void coap_client_cancel_requests(struct coap_client *client);

/**
* @brief Cancel matching requests.
*
* This function cancels all CoAP client request that matches the given request.
* The request is matched based on the method, path, callback and user_data, if provided.
* Any field set to NULL is considered a wildcard.
*
* (struct coap_client_request){0} cancels all requests.
* (struct coap_client_request){.method = COAP_METHOD_GET} cancels all GET requests.
*
* @param client Pointer to the CoAP client instance.
* @param req Pointer to the CoAP client request to be canceled.
*/
void coap_client_cancel_request(struct coap_client *client, struct coap_client_request *req);

/**
* @brief Initialise a Block2 option to be added to a request
*
Expand Down
16 changes: 13 additions & 3 deletions include/zephyr/net/lwm2m.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ enum lwm2m_rd_client_event {
typedef void (*lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx,
enum lwm2m_rd_client_event event);

typedef int (*lwm2m_set_sockopt_cb_t)(struct lwm2m_ctx *client_ctx);

/**
* @brief Different traffic states of the LwM2M socket.
Expand Down Expand Up @@ -245,8 +246,6 @@ struct lwm2m_ctx {
char *desthostname;
/** Destination hostname length */
uint16_t desthostnamelen;
/** Flag to indicate if hostname verification is enabled */
bool hostname_verify;

/** Custom load_credentials function.
* Client can set load_credentials function as a way of overriding
Expand All @@ -260,7 +259,7 @@ struct lwm2m_ctx {
* a callback that is called after a socket is created and before
* connect.
*/
int (*set_socketoptions)(struct lwm2m_ctx *client_ctx);
lwm2m_set_sockopt_cb_t set_socketoptions;

/** Flag to indicate if context should use DTLS.
* Enabled via the use of coaps:// protocol prefix in connection
Expand Down Expand Up @@ -1623,6 +1622,17 @@ int lwm2m_security_mode(struct lwm2m_ctx *ctx);
*/
int lwm2m_set_default_sockopt(struct lwm2m_ctx *ctx);

/**
* @brief Set the @ref lwm2m_ctx::set_socketoptions callback for the pull context's client.
*
* This allows setting specific socket options on the socket that is used to pull
* firmware updates. The callback will be called after the pull context socket has been
* created and before it will connect.
*
* @param[in] set_sockopt_cb A callback function to set sockopts for the pull context client.
*/
void lwm2m_pull_context_set_sockopt_callback(lwm2m_set_sockopt_cb_t set_sockopt_cb);

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading