[riot-notifications] [RIOT-OS/RIOT] net/lorawan: Revert #16604 and fix NETOPT_RX_SYMBOL_TIMEOUT documentation (#16640)

José Alamos notifications at github.com
Tue Jul 13 22:11:14 CEST 2021


Test results:
Symbol time is ~32 ms in SF12. Therefore the timings are right.

```
2021-07-13 22:02:49,757 # main(): This is RIOT! (Version: 2021.10-devel-139-g61e24-pr/revert/rx_symbol)
2021-07-13 22:02:49,790 # [START] (10)
2021-07-13 22:02:50,119 # [STOP]: Took 326876 us
2021-07-13 22:02:50,121 # [START] (50)
2021-07-13 22:02:51,761 # [STOP]: Took 1632464 us
2021-07-13 22:02:51,763 # [2003620us]: RX_CONTINOUS
2021-07-13 22:02:51,768 # Initialization successful - starting the shell now
```

Using the patch:
```patch
diff --git a/tests/driver_sx127x/main.c b/tests/driver_sx127x/main.c
index 4fe1257c04..e36bec8e05 100644
--- a/tests/driver_sx127x/main.c
+++ b/tests/driver_sx127x/main.c
@@ -42,6 +42,8 @@
 
 #include "fmt.h"
 
+#include "mutex.h"
+
 #define SX127X_LORA_MSG_QUEUE   (16U)
 #define SX127X_STACKSIZE        (THREAD_STACKSIZE_DEFAULT)
 
@@ -53,6 +55,8 @@ static kernel_pid_t _recv_pid;
 static char message[32];
 static sx127x_t sx127x;
 
+static mutex_t lock;
+
 int lora_setup_cmd(int argc, char **argv)
 {
 
@@ -511,6 +515,10 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
             sx127x_set_sleep(&sx127x);
             break;
 
+        case NETDEV_EVENT_RX_TIMEOUT:
+            mutex_unlock(&lock);
+            break;
+
         default:
             printf("Unexpected netdev event received: %d\n", event);
             break;
@@ -518,6 +526,24 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
     }
 }
 
+static void _measure_rx_timeout(netdev_t *netdev, uint16_t rx_timeout)
+{
+    netdev->driver->set(netdev, NETOPT_RX_SYMBOL_TIMEOUT, &rx_timeout, sizeof(rx_timeout));
+    netopt_state_t state = NETOPT_STATE_IDLE;
+    netdev->driver->set(netdev, NETOPT_STATE, &state, sizeof(state));
+    uint32_t tmp = ztimer_now(ZTIMER_USEC);
+
+    if (rx_timeout) {
+        printf("[START] (%i)\n", rx_timeout);
+        mutex_lock(&lock);
+        printf("[STOP]: Took %li us\n", ztimer_now(ZTIMER_USEC) - tmp);
+    
+    }
+    else {
+        printf("[%"PRIu32"us]: RX_CONTINOUS\n", ztimer_now(ZTIMER_USEC));
+    }
+}
+
 void *_recv_thread(void *arg)
 {
     (void)arg;
@@ -545,6 +571,8 @@ int main(void)
     netdev_t *netdev = &sx127x.netdev;
 
     netdev->driver = &sx127x_driver;
+    mutex_init(&lock);
+    mutex_lock(&lock);
 
     if (netdev->driver->init(netdev) < 0) {
         puts("Failed to initialize SX127x device, exiting");
@@ -563,6 +591,15 @@ int main(void)
     }
 
     /* start the shell */
+    bool single = true;
+    netdev->driver->set(netdev, NETOPT_SINGLE_RECEIVE, &single, sizeof(single));
+
+    uint8_t sf = LORA_SF12;
+    netdev->driver->set(netdev, NETOPT_SPREADING_FACTOR, &sf, sizeof(sf));
+
+    _measure_rx_timeout(netdev, 10);
+    _measure_rx_timeout(netdev, 50);
+    _measure_rx_timeout(netdev, 0);
     puts("Initialization successful - starting the shell now");
     char line_buf[SHELL_DEFAULT_BUFSIZE];
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16640#issuecomment-879369283
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210713/832dc7d2/attachment-0001.htm>


More information about the notifications mailing list