Closed jbr-ia closed 9 months ago
Thanks for filing this. I have a PR that I need to get started that fixes some sleep issues that will likely fix this.
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Describe the bug I try to use an HL7800 modem on a pinnacle-board (pinnacle-100-dvk) with lwm2m, NBiot and low power options enabled. If the modem goes to Hibernate and it wakes up, than the lwm2m-connection can not be updated (caused by a timeout to connect to an UDP-socket) and a new full lwm2m-registration is carried out. This was seen with firmware 4.6.9.4 of the modem. I also tried with a newer firmware-version (4.7.1.1). With that version, even the initial lwm2m-registration fails.
When looking further at this, I saw that after the modem went to hibernate, and wakes up again, the driver calls reconfigure_IP_connection https://github.com/zephyrproject-rtos/zephyr/blob/96175fcc476dc0a19a870d7da9e893f9f548e06f/drivers/modem/hl7800.c#L5749 In that function an AT+KUDPCFG? is send. In the send_at_cmd-code there is no sock yet, so for the timeout, response_sem is used. https://github.com/zephyrproject-rtos/zephyr/blob/96175fcc476dc0a19a870d7da9e893f9f548e06f/drivers/modem/hl7800.c#L990
Then, the modem sends a response with+KUDPCFG containing a socket that already exists on the modem and the function on_cmd_sockcreate is called. https://github.com/zephyrproject-rtos/zephyr/blob/96175fcc476dc0a19a870d7da9e893f9f548e06f/drivers/modem/hl7800.c#L3904 In that function last_socket_id is changed.
When zephyr than receives the 'OK' from the modem, the driver has a sock, and sock_send_sem is given. https://github.com/zephyrproject-rtos/zephyr/blob/96175fcc476dc0a19a870d7da9e893f9f548e06f/drivers/modem/hl7800.c#L3683 Because send_at_cmd-code waits for the response_sem, but the semaphore sock_send_sem is given by the ok, send_at_cmd errors with a timeout (after some time), and the lwm2m-engine gives the error ‘Cannot connect to UDP’.
It seems that with the newer modem firmware, (4.7.1.1), also after a reset the modem remembers the udp-socket, and also the first AT+KUDPCFG? in booting already returns an socket, leading to problems with taking a different semaphore than is given later.
To Reproduce To reproduce, I have modified the LwM2M-sample to use the pinnacle-modem, with lowpoweroptions enabled and wait in the main-program for the modem to be connected to the network before attempting to start the lwm2m-registration. Also the prj.conf is changed, so the lowpoweroptions are enabled, and some extra logging is added
west build -b pinnacle_100_dvk ./samples/net/lwm2m_client/ -- -DOVERLAY_CONFIG="overlay-queue.conf;overlay-lwm2m-1.1.conf"
west flash
lwm2m update
. Not the lwm2m-stack fails to update, and does a full re-registrationExpected behavior I expect that after the modem had hibernated, that it is possible to update the lwm2m-registration without a full re-registration.
Impact With the 4.6.9.4 firmware of the modem a full registration when an update was only needed. With 4.7.1.1 of the modem-firmware even not able to do an lwm2m registration.
Logs and console output
Environment (please complete the following information):