1313#include <modem/nrf_modem_lib.h>
1414#include <modem/ntn.h>
1515#include <nrf_modem_at.h>
16- #include <modem/at_monitor.h>
1716#include <nrf_modem_gnss.h>
1817#include <modem/modem_info.h>
1918#include <zephyr/task_wdt/task_wdt.h>
2625
2726LOG_MODULE_REGISTER (ntn_module , CONFIG_APP_NTN_LOG_LEVEL );
2827
29- /* AT monitor for network notifications.
30- * The monitor is needed to receive notification when in the case where the modem has been
31- * put into offline mode while keeping registration context.
32- * In this case, the modem will send a +CEREG notification with status 1 or 5 when NTN is
33- * re-enabled. The LTE link controller does not forward this because it is equal to the previous
34- * registration status. To work around this, we monitor the +CEREG notification and forward it
35- * to the NTN module when offline-while-keeping-registration mode is enabled.
36- */
37- AT_MONITOR (cereg_monitor , "CEREG" , cereg_mon , PAUSED );
38-
3928/* Define channels provided by this module */
4029ZBUS_CHAN_DEFINE (NTN_CHAN ,
4130 struct ntn_msg ,
@@ -210,24 +199,6 @@ static void gnss_location_work_handler(struct k_work *work)
210199
211200/* Helper functions */
212201
213- static void cereg_mon (const char * notif )
214- {
215- enum lte_lc_nw_reg_status status = atoi (notif + strlen ("+CEREG: " ));
216-
217- if (status == LTE_LC_NW_REG_REGISTERED_ROAMING ) {
218- LOG_DBG ("Network registration status: ROAMING" );
219- ntn_msg_publish (NTN_NETWORK_CONNECTED );
220- LOG_DBG ("Stop monitoring incoming CEREG Notifications" );
221- at_monitor_pause (& cereg_monitor );
222- } else if (status == LTE_LC_NW_REG_REGISTERED_HOME ) {
223- /* Amari Callbox */
224- LOG_DBG ("Network registration status: HOME" );
225- ntn_msg_publish (NTN_NETWORK_CONNECTED );
226- LOG_DBG ("Stop monitoring incoming CEREG Notifications" );
227- at_monitor_pause (& cereg_monitor );
228- }
229- }
230-
231202static int set_ntn_dormant_mode (void )
232203{
233204 int err ;
@@ -240,17 +211,6 @@ static int set_ntn_dormant_mode(void)
240211 return err ;
241212 }
242213
243- err = nrf_modem_at_printf ("AT+CEREG=1" );
244- if (err ) {
245- LOG_ERR ("AT+CEREG failed, error: %d" , err );
246-
247- return err ;
248- }
249-
250- /* Start monitoring incoming CEREG Notifications */
251- LOG_DBG ("Start monitoring incoming CEREG Notifications" );
252- at_monitor_resume (& cereg_monitor );
253-
254214 return 0 ;
255215}
256216
@@ -931,6 +891,15 @@ static void lte_lc_evt_handler(const struct lte_lc_evt *const evt)
931891 ntn_msg_publish (NTN_NETWORK_DISCONNECTED );
932892
933893 break ;
894+ case LTE_LC_EVT_PDN_SUSPENDED :
895+ LOG_DBG ("PDN connection suspended" );
896+ ntn_msg_publish (NTN_NETWORK_DISCONNECTED );
897+
898+ break ;
899+ case LTE_LC_EVT_PDN_RESUMED :
900+ LOG_DBG ("PDN connection resumed" );
901+ ntn_msg_publish (NTN_NETWORK_CONNECTED );
902+
934903 default :
935904 break ;
936905 }
0 commit comments