diff --git a/include/bluetooth/hci.h b/include/bluetooth/hci.h index 1fe25b50e12..b91fd915b46 100644 --- a/include/bluetooth/hci.h +++ b/include/bluetooth/hci.h @@ -1088,6 +1088,12 @@ struct bt_hci_cp_le_set_ext_scan_rsp_data { u8_t data[251]; } __packed; +/* If the advertising is high duty cycle connectable directed advertising, then + * Duration[i] shall be less than or equal to 1.28 seconds and shall not be + * equal to 0. + */ +#define BT_HCI_LE_EXT_ADV_DURATION_HI_DC_MAX 128 + #define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0039) struct bt_hci_ext_adv_set { u8_t handle; diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 8ee153317a6..29413b9fc9a 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -7415,6 +7415,10 @@ int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, const struct bt_data *sd, size_t sd_len, const bt_addr_le_t *peer) { + struct bt_le_ext_adv_start_param start_param = { + .timeout = 0, + .num_events = 0, + }; bool dir_adv = (peer != NULL); struct bt_conn *conn = NULL; int err = 0; @@ -7453,9 +7457,12 @@ int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, bt_conn_set_state(conn, BT_CONN_CONNECT_ADV); } + } else if (!(param->options & BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY)) { + start_param.timeout = BT_HCI_LE_EXT_ADV_DURATION_HI_DC_MAX; + atomic_set_bit(adv->flags, BT_ADV_LIMITED); } - err = set_le_adv_enable_ext(adv, true, NULL); + err = set_le_adv_enable_ext(adv, true, &start_param); if (err) { BT_ERR("Failed to start advertiser"); if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) {