[riot-notifications] [RIOT-OS/RIOT] pkg/nimble/netif: allow to apply and enforce random and unique connection intervals (#16372)

Hauke Petersen notifications at github.com
Wed Jun 16 11:39:50 CEST 2021


@haukepetersen commented on this pull request.



> +    uint16_t start = random_uint32_range(min, max);
+    if (IS_ACTIVE(NIMBLE_NETIF_FORCE_CONN_ITVL_SPACING)) {
+        for (uint16_t itvl = start;
+             itvl <= max;
+             itvl += NIMBLE_NETIF_CONN_ITVL_SPACING_MS) {
+            if (!nimble_netif_conn_itvl_used(itvl, NIMBLE_NETIF_CONN_INVALID)) {
+                return itvl;
+            }
+        }
+        for (uint16_t itvl = start - NIMBLE_NETIF_CONN_ITVL_SPACING_MS;
+             itvl >= min;
+             itvl -= NIMBLE_NETIF_CONN_ITVL_SPACING_MS) {
+            if (!nimble_netif_conn_itvl_used(itvl, NIMBLE_NETIF_CONN_INVALID)) {
+                return itvl;
+            }
+        }
+        return 0;
+    }

correct. Compared to choosing a random value in a loop, this has the huge advantage of a fully deterministic runtime, and also it will return an error if not suitable conn itvl is available anymore.

-- 
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/16372#discussion_r652525185
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210616/ae7e5773/attachment.htm>


More information about the notifications mailing list