Hello,
I use nRFCloud to send CoAP messages, and it's working fine under normal conditions.
I am now trying to simulate a network loss, while sending some data.
To do that, I simply remove the antenna of my device when sending.
Here is my test flow :
- Device has successfully sent some CoAP messages. Modem enters PSM and firmware sleeps.
- After 1 minute, the device wakes up. I remove the antenna.
- The firmware tries to send a CoAP message using nrf_cloud_coap_json_message_send().
After a few seconds, I receive lte_lc_evt LTE_LC_NW_REG_UNKNOWN.
After a few minutes, it succesfully reconnect to network (eventhough the antenna is remove)
Here is a snippet of my log :
[...] Device running properly. [...] Modem in PSM, firmware in sleep. * Wakeup * 11/04/2024 07:18:43 Cellular enable ... Ok (already ready). Sending CoAP Message. Current PSM [TAU=420 ; AT=2] don't match desired [TAU>1080 ; 2<AT<20]. Request PSM [TAU=1080 ; AT=2] [MODEM] PSM Update [TAU=1080 ; AT=2] [MODEM] RCC Idle * Sleep for 1 minute * * Wakeup * [ I REMOVE THE ANTENNA FROM THE DEVICE ] 11/04/2024 07:18:58 Cellular enable ... Ok (already ready). Sending CoAP Message. [MODEM] Network registration - LTE_LC_NW_REG_UNKNOWN [MODEM] Mode: Off [MODEM] Searching network [MODEM] Cell - id:138275874, tac:22582 [MODEM] Mode NB-IoT [MODEM] RRC Connected * REBOOT FROM WATCHDOG *
From what I understand, the function nrf_cloud_coap_json_message_send() is blocking. Since the device can't reach the network, the firmware waits until the connection is re-established.
Is there a way to abort sending if the modem is no loger connected ? Note that this all from the main, I don't use any threads for this.
What I find strange, is that the watchdog is not triggered even if nrf_cloud_coap_json_message_send() hangs for several minutes. My watchdog is setup with a 10 sec window, and I know it works.
Am I missing something ?
Thanks.