acassis commented on code in PR #17763:
URL: https://github.com/apache/nuttx/pull/17763#discussion_r2661229866


##########
drivers/wireless/lpwan/sx127x/sx127x.c:
##########
@@ -1276,6 +1278,50 @@ static int sx127x_poll(FAR struct file *filep, FAR 
struct pollfd *fds,
 #endif
 }
 
+/****************************************************************************
+ * Name: sx127x_rx_watchdog
+ *
+ * Description:
+ *   Watchdog to detect SX127x RX communication stall
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_LPWAN_SX127X_RXSUPPORT
+static void sx127x_rx_watchdog(FAR void *arg)
+{
+  FAR struct sx127x_dev_s *dev = (FAR struct sx127x_dev_s *) arg;
+  clock_t now = clock_systime_ticks();
+
+  if (dev->opmode == SX127X_OPMODE_RX &&
+      (now - dev->last_rx_tick) > MSEC2TICK(dev->rx_timeout))
+    {
+      wlerr("RX stall detected, restarting RX\n");
+
+      /* Leave RX mode to clear AFC + bit sync */
+
+      sx127x_opmode_set(dev, SX127X_OPMODE_STANDBY);
+
+      /* datasheet-safe delay */
+
+      nxsched_usleep(100);
+
+      /* Re-enter RX */
+
+      sx127x_opmode_set(dev, SX127X_OPMODE_RX);
+
+      /* Avoid using old RX tick, otherwise it always will fail */
+
+      dev->last_rx_tick = now;
+    }
+
+  /* Reschedule watchdog */
+
+  work_queue(LPWORK, &dev->rx_watchdog,

Review Comment:
   true, I need to stop/cancel it when closing or unregistering the driver



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to