[riot-notifications] [RIOT-OS/RIOT] drivers/sx126x : r/NETOPT_RX_TIMEOUT/NETOPT_RX_SYMBOL_TIMEOUT (#16599)

Francisco notifications at github.com
Tue Jul 6 18:34:05 CEST 2021


Since I don't have a gateway I sued the following patch @jia200x provided:

```diff
diff --git a/tests/driver_sx126x/main.c b/tests/driver_sx126x/main.c
index 313c95b4ed..f860c1a13a 100644
--- a/tests/driver_sx126x/main.c
+++ b/tests/driver_sx126x/main.c
@@ -30,6 +30,7 @@
 #include "net/lora.h"
 #include "net/netdev.h"
 #include "net/netdev/lora.h"
+#include "mutex.h"

 #include "sx126x.h"
 #include "sx126x_params.h"
@@ -47,6 +48,8 @@ static char message[SX126X_MAX_PAYLOAD_LEN];

 static sx126x_t sx126x;

+static mutex_t lock;
+
 static void _event_cb(netdev_t *dev, netdev_event_t event)
 {
     if (event == NETDEV_EVENT_ISR) {
@@ -86,6 +89,10 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
             puts("Transmission timeout");
             break;

+        case NETDEV_EVENT_RX_TIMEOUT:
+            mutex_unlock(&lock);
+            break;
+
         default:
             printf("Unexpected netdev event received: %d\n", event);
             break;
@@ -318,6 +325,21 @@ static const shell_command_t shell_commands[] = {
     { NULL, NULL, NULL }
 };

+static void _measure_rx_timeout(netdev_t *netdev, uint8_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));
+    if (rx_timeout) {
+        printf("START (%i)\n", rx_timeout);
+        mutex_lock(&lock);
+        puts("STOP");
+    }
+    else {
+        puts("RX_CONTINUOUS");
+    }
+}
+
 int main(void)
 {
     sx126x_setup(&sx126x, &sx126x_params[0], 0);
@@ -341,10 +363,19 @@ int main(void)
         return 1;
     }

+    mutex_init(&lock);
+    mutex_lock(&lock);
     /* start the shell */
     puts("Initialization successful - starting the shell now");
     char line_buf[SHELL_DEFAULT_BUFSIZE];

+    uint8_t sf = LORA_SF11;
+    netdev->driver->get(netdev, NETOPT_SPREADING_FACTOR, &sf, sizeof(uint8_t));
+
+    _measure_rx_timeout(netdev, 10);
+    _measure_rx_timeout(netdev, 50);
+    _measure_rx_timeout(netdev, 0);
+
     shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
     return 0;
 }
```
With this and only pyterm timings, it seems its accurate:

```
2021-07-06 18:32:03,932 # main(): This is RIOT! (Version: 2021.10-devel-37-g34f086-pr-16599)
2021-07-06 18:32:03,939 # Initialization successful - starting the shell now
2021-07-06 18:32:03,940 # START (10)
2021-07-06 18:32:03,950 # STOP
2021-07-06 18:32:03,951 # START (50)
2021-07-06 18:32:04,001 # STOP
2021-07-06 18:32:04,006 # RX_CONTINUOUS
```


-- 
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/16599#issuecomment-874910908
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210706/d08a571e/attachment.htm>


More information about the notifications mailing list