Skip to content

Commit 1241057

Browse files
dwinkler2Johan Hedberg
authored andcommitted
Bluetooth: Break add adv into two mgmt commands
This patch adds support for the new advertising add interface, with the first command setting advertising parameters and the second to set advertising data. The set parameters command allows the caller to leave some fields "unset", with a params bitfield defining which params were purposefully set. Unset parameters will be given defaults when calling hci_add_adv_instance. The data passed to the param mgmt command is allowed to be flexible, so in the future if bluetoothd passes a larger structure with new params, the mgmt command will ignore the unknown members at the end. This change has been validated on both hatch (extended advertising) and kukui (no extended advertising) chromebooks running bluetoothd that support this new interface. I ran the following manual tests: - Set several (3) advertisements using modified test_advertisement.py - For each, validate correct data and parameters in btmon trace - Verified both for software rotation and extended adv Automatic test suite also run, testing many (25) scenarios of single and multi-advertising for data/parameter correctness. Reviewed-by: Sonny Sasaka <[email protected]> Signed-off-by: Daniel Winkler <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
1 parent 31aab5c commit 1241057

File tree

4 files changed

+407
-11
lines changed

4 files changed

+407
-11
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ struct adv_info {
238238
#define HCI_MAX_ADV_INSTANCES 5
239239
#define HCI_DEFAULT_ADV_DURATION 2
240240

241+
#define HCI_ADV_TX_POWER_NO_PREFERENCE 0x7F
242+
241243
struct adv_pattern {
242244
struct list_head list;
243245
__u8 ad_type;

include/net/bluetooth/mgmt.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ struct mgmt_rp_add_advertising {
574574
#define MGMT_ADV_FLAG_SEC_CODED BIT(9)
575575
#define MGMT_ADV_FLAG_CAN_SET_TX_POWER BIT(10)
576576
#define MGMT_ADV_FLAG_HW_OFFLOAD BIT(11)
577+
#define MGMT_ADV_PARAM_DURATION BIT(12)
578+
#define MGMT_ADV_PARAM_TIMEOUT BIT(13)
579+
#define MGMT_ADV_PARAM_INTERVALS BIT(14)
580+
#define MGMT_ADV_PARAM_TX_POWER BIT(15)
577581

578582
#define MGMT_ADV_FLAG_SEC_MASK (MGMT_ADV_FLAG_SEC_1M | MGMT_ADV_FLAG_SEC_2M | \
579583
MGMT_ADV_FLAG_SEC_CODED)
@@ -782,6 +786,36 @@ struct mgmt_rp_remove_adv_monitor {
782786
__le16 monitor_handle;
783787
} __packed;
784788

789+
#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054
790+
struct mgmt_cp_add_ext_adv_params {
791+
__u8 instance;
792+
__le32 flags;
793+
__le16 duration;
794+
__le16 timeout;
795+
__le32 min_interval;
796+
__le32 max_interval;
797+
__s8 tx_power;
798+
} __packed;
799+
#define MGMT_ADD_EXT_ADV_PARAMS_MIN_SIZE 18
800+
struct mgmt_rp_add_ext_adv_params {
801+
__u8 instance;
802+
__s8 tx_power;
803+
__u8 max_adv_data_len;
804+
__u8 max_scan_rsp_len;
805+
} __packed;
806+
807+
#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055
808+
struct mgmt_cp_add_ext_adv_data {
809+
__u8 instance;
810+
__u8 adv_data_len;
811+
__u8 scan_rsp_len;
812+
__u8 data[];
813+
} __packed;
814+
#define MGMT_ADD_EXT_ADV_DATA_SIZE 3
815+
struct mgmt_rp_add_ext_adv_data {
816+
__u8 instance;
817+
} __packed;
818+
785819
#define MGMT_EV_CMD_COMPLETE 0x0001
786820
struct mgmt_ev_cmd_complete {
787821
__le16 opcode;

net/bluetooth/hci_event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@ static void hci_cc_set_ext_adv_param(struct hci_dev *hdev, struct sk_buff *skb)
17521752
}
17531753
/* Update adv data as tx power is known now */
17541754
hci_req_update_adv_data(hdev, hdev->cur_adv_instance);
1755+
17551756
hci_dev_unlock(hdev);
17561757
}
17571758

0 commit comments

Comments
 (0)