You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2022/12/13 21:04:06 UTC

[mynewt-nimble] branch master updated: nimble/host: Add helper macros to set interval min / max for perdiodic adv

This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 62b0fff5 nimble/host: Add helper macros to set interval min / max for perdiodic adv
62b0fff5 is described below

commit 62b0fff5812e770f3addaf09a79b90bcf5dd80f7
Author: Rahul Tank <ra...@espressif.com>
AuthorDate: Tue Dec 13 11:30:46 2022 +0530

    nimble/host: Add helper macros to set interval min / max for perdiodic
    adv
---
 nimble/host/include/host/ble_gap.h | 7 ++++---
 nimble/host/src/ble_gap.c          | 7 +++----
 nimble/include/nimble/hci_common.h | 2 ++
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h
index b132189a..47a1d564 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -44,6 +44,7 @@ struct hci_conn_update;
 #define BLE_GAP_SCAN_WIN_MS(t)              ((t) * 1000 / BLE_HCI_SCAN_ITVL)
 #define BLE_GAP_CONN_ITVL_MS(t)             ((t) * 1000 / BLE_HCI_CONN_ITVL)
 #define BLE_GAP_SUPERVISION_TIMEOUT_MS(t)   ((t) / 10)
+#define BLE_GAP_PERIODIC_ITVL_MS(t)         ((t) * 1000 / BLE_HCI_PERIODIC_ADV_ITVL)
 
 /** 30 ms. */
 #define BLE_GAP_ADV_FAST_INTERVAL1_MIN      BLE_GAP_ADV_ITVL_MS(30)
@@ -1458,14 +1459,14 @@ int ble_gap_ext_adv_active(uint8_t instance);
 /** @brief Periodic advertising parameters  */
 struct ble_gap_periodic_adv_params {
     /** If include TX power in advertising PDU */
-    unsigned int include_tx_power:1;
+    unsigned int include_tx_power : 1;
 
-    /** Minimum advertising interval in 0.625ms units, if 0 stack use sane
+    /** Minimum advertising interval in 1.25ms units, if 0 stack use sane
      *  defaults
      */
     uint16_t itvl_min;
 
-    /** Maximum advertising interval in 0.625ms units, if 0 stack use sane
+    /** Maximum advertising interval in 1.25ms units, if 0 stack use sane
      *  defaults
      */
     uint16_t itvl_max;
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index ba1ec7fb..b6d54bc3 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -3418,12 +3418,11 @@ ble_gap_periodic_adv_params_tx(uint8_t instance,
 
     /* Fill optional fields if application did not specify them. */
     if (params->itvl_min == 0 && params->itvl_max == 0) {
-        /* TODO defines for those */
-        cmd.min_itvl = htole16(30 / 1.25);   //30 ms
-        cmd.max_itvl = htole16(60 / 1.25);   //150 ms
+        cmd.min_itvl = BLE_GAP_PERIODIC_ITVL_MS(30);
+        cmd.max_itvl = BLE_GAP_PERIODIC_ITVL_MS(60);
 
     } else {
-        cmd.min_itvl = htole16( params->itvl_min);
+        cmd.min_itvl = htole16(params->itvl_min);
         cmd.max_itvl = htole16(params->itvl_max);
     }
 
diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h
index 7c5ebe9a..eadb0b0e 100644
--- a/nimble/include/nimble/hci_common.h
+++ b/nimble/include/nimble/hci_common.h
@@ -1265,6 +1265,8 @@ struct ble_hci_vs_set_antenna_cp {
 #define BLE_HCI_ADV_ITVL_DEF                (0x800)         /* 1.28 seconds */
 #define BLE_HCI_ADV_CHANMASK_DEF            (0x7)           /* all channels */
 
+#define BLE_HCI_PERIODIC_ADV_ITVL           (1250)          /* usecs */
+
 /* Set scan parameters */
 #define BLE_HCI_SCAN_TYPE_PASSIVE           (0)
 #define BLE_HCI_SCAN_TYPE_ACTIVE            (1)