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

Fetch LwM2M related updates from upstream #1264

Merged
merged 10 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion include/zephyr/net/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ typedef int (*coap_reply_t)(const struct coap_packet *response,
*/
struct coap_pending {
struct sockaddr addr;
uint32_t t0;
int64_t t0;
uint32_t timeout;
uint16_t id;
uint8_t *data;
Expand Down
15 changes: 0 additions & 15 deletions include/zephyr/net/lwm2m.h
Original file line number Diff line number Diff line change
Expand Up @@ -1911,21 +1911,6 @@ int lwm2m_engine_delete_res_inst(const char *pathstr);
*/
int lwm2m_delete_res_inst(const struct lwm2m_obj_path *path);

/**
* @brief Update the period of a given service.
*
* Allow the period modification on an existing service created with
* lwm2m_engine_add_service().
* Example to frequency at which a periodic_service changes it's values :
* lwm2m_engine_update_service(device_periodic_service,5*MSEC_PER_SEC);
*
* @param[in] service Handler of the periodic_service
* @param[in] period_ms New period for the periodic_service (in milliseconds)
*
* @return 0 for success or negative in case of error.
*/
int lwm2m_engine_update_service_period(k_work_handler_t service, uint32_t period_ms);

/**
* @brief Update the period of the device service.
*
Expand Down
3 changes: 3 additions & 0 deletions samples/net/lwm2m_client/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ samples/net/lwm2m_client directory:
- :file:`overlay-queue.conf`
This overlay config can be added to enable LWM2M Queue Mode support.

- :file:`overlay-tickless.conf`
This overlay config can be used to stop LwM2M engine for periodically interrupting socket polls. It can have significant effect on power usage on certain devices.

Build the lwm2m-client sample application like this:

.. zephyr-app-commands::
Expand Down
2 changes: 2 additions & 0 deletions samples/net/lwm2m_client/overlay-tickless.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_NET_SOCKETPAIR=y
CONFIG_LWM2M_TICKLESS=y
4 changes: 2 additions & 2 deletions samples/net/sockets/coap_server/src/coap-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ static int large_create_post(struct coap_resource *resource,
static void schedule_next_retransmission(void)
{
struct coap_pending *pending;
int32_t remaining;
uint32_t now = k_uptime_get_32();
int64_t remaining;
int64_t now = k_uptime_get();

/* Get the first pending retransmission to expire after cycling. */
pending = coap_pending_next_to_expire(pendings, NUM_PENDINGS);
Expand Down
6 changes: 3 additions & 3 deletions subsys/net/lib/coap/coap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ int coap_pending_init(struct coap_pending *pending,

pending->data = request->data;
pending->len = request->offset;
pending->t0 = k_uptime_get_32();
pending->t0 = k_uptime_get();
pending->retries = retries;

return 0;
Expand Down Expand Up @@ -1382,7 +1382,7 @@ struct coap_pending *coap_pending_next_to_expire(
{
struct coap_pending *p, *found = NULL;
size_t i;
uint32_t expiry, min_expiry;
int64_t expiry, min_expiry = INT64_MAX;

for (i = 0, p = pendings; i < len; i++, p++) {
if (!p->timeout) {
Expand All @@ -1391,7 +1391,7 @@ struct coap_pending *coap_pending_next_to_expire(

expiry = p->t0 + p->timeout;

if (!found || (int32_t)(expiry - min_expiry) < 0) {
if (expiry < min_expiry) {
min_expiry = expiry;
found = p;
}
Expand Down
14 changes: 14 additions & 0 deletions subsys/net/lib/lwm2m/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ config LWM2M_DNS_SUPPORT
bool "DNS support in the LWM2M client"
default y if DNS_RESOLVER

choice
prompt "LwM2M Engine operation mode"
default LWM2M_TICKLESS if NET_SOCKETPAIR
default LWM2M_INTERVAL if !NET_SOCKETPAIR

config LWM2M_TICKLESS
bool "Tickless operation mode"
depends on NET_SOCKETPAIR

config LWM2M_INTERVAL
bool "Interval based polling mode"

endchoice

config LWM2M_ENGINE_STACK_SIZE
int "LWM2M engine stack size"
default 2560 if NET_LOG
Expand Down
Loading