Add helper macros to set interval min / max for periodic adv

This commit is contained in:
Rahul Tank
2022-12-13 13:44:11 +05:30
parent df2b82880e
commit 9a355b2b59
3 changed files with 8 additions and 6 deletions
+3 -2
View File
@@ -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)
@@ -1452,12 +1453,12 @@ struct ble_gap_periodic_adv_params {
/** If include TX power in advertising PDU */
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;
+3 -4
View File
@@ -3612,12 +3612,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);
}
+2
View File
@@ -1207,6 +1207,8 @@ struct ble_hci_vs_rd_static_addr_rp {
#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)