andrzej-kaczmarek commented on a change in pull request #735: nimble/ll: Fix 
HCI checks for periodic advertising
URL: https://github.com/apache/mynewt-nimble/pull/735#discussion_r370358262
 
 

 ##########
 File path: nimble/controller/src/ble_ll_adv.c
 ##########
 @@ -3605,7 +3598,35 @@ ble_ll_adv_clear_all(void)
 
     return BLE_ERR_SUCCESS;
 }
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV)
+static bool
+ble_ll_adv_periodic_check_data_itvl(struct ble_ll_adv_sm *advsm,
+                                    uint16_t payload_len, uint16_t itvl)
+{
+    uint32_t max_usecs = 0;
+    uint32_t chain_usecs;
+    uint32_t itvl_usecs;
+
+    /* this is max PDU + MAFS + MAFS_DELAY, this needs to be summed up for each
+     * chain PDU
+     */
+    chain_usecs = ble_ll_pdu_tx_time_get(BLE_PHY_MAX_PDU_LEN, advsm->sec_phy) +
+                  ble_ll_usecs_to_ticks_round_up(BLE_LL_MAFS +
+                                MYNEWT_VAL(BLE_LL_SCHED_AUX_CHAIN_MAFS_DELAY));
+
+    while (payload_len > BLE_PHY_MAX_PDU_LEN) {
+        max_usecs += chain_usecs;
+        payload_len -= BLE_PHY_MAX_PDU_LEN;
+    }
+
+    max_usecs += ble_ll_pdu_tx_time_get(payload_len, advsm->sec_phy);
+
+    itvl_usecs = (uint32_t)itvl * BLE_LL_ADV_PERIODIC_ITVL;
+
+    return max_usecs < itvl_usecs;
 
 Review comment:
   `max_usecs` is not calculated properly. `payload_len` is just length of 
data, but the actual payload of each PDU includes also ext adv header so 
there's more data to send thus it will take more usecs.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to