summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Winkler <danielwinkler@google.com>2020-10-29 16:06:18 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-10-29 17:45:17 -0700
commitcf7795a6ad50ab379bb6a0dceff2b0dc99ed5456 (patch)
treedc2698fc6c9fd7914191cdebe7c6cc7bb2abb29d /lib
parentd94551190dd59aac3edcd387e64335406b066779 (diff)
downloadbluez-cf7795a6ad50ab379bb6a0dceff2b0dc99ed5456.tar.gz
advertising: Use new mgmt interface for advertising add
This patch allows bluetoothd to use the new extended advertising add mgmt interface if it is available. The new interface will be used by default, as it allows the client to set advertising intervals, and tx power if the controller and kernel support extended advertising. Each new registered advertisement will submit two requests to kernel; the first sets the advertising parameters for the advertising instance, and the second sets the advertising data and scan response for the instance. The parameters MGMT request will return the tx power selected by the controller (if applicable), which is propagated to the client via a dbus Set method. Note: This patch also fixes a small bug in the packet monitor, where the tx power value 0xff is considered as "Host has no preference". However, the spec states this value to be 0x7f. It is corrected in this patch This change has been tested extensively on Hatch (extended advertising) and Kukui (no extended advertising) chromebooks. Manual tests do the following: - Configure advertisement with custom intervals, tx power with valid and invalid values and combinations - Ensure that with valid parameters, they are propagated and set in hci requests. With invalid parameters, ensure that the registration fails. Automatic tests verify 25 advertising usage scenarios involving single and multi-advertising registration, over-registration, parameter validation, etc. These tests don't test new intervals and tx power, but validate that the new MGMT interface does not regress compatibility in these 25 scenarios.
Diffstat (limited to 'lib')
-rw-r--r--lib/mgmt.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 59608e7ea..7ab4fb797 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -503,6 +503,10 @@ struct mgmt_rp_add_advertising {
#define MGMT_ADV_FLAG_SEC_1M (1 << 7)
#define MGMT_ADV_FLAG_SEC_2M (1 << 8)
#define MGMT_ADV_FLAG_SEC_CODED (1 << 9)
+#define MGMT_ADV_PARAM_DURATION (1 << 12)
+#define MGMT_ADV_PARAM_TIMEOUT (1 << 13)
+#define MGMT_ADV_PARAM_INTERVALS (1 << 14)
+#define MGMT_ADV_PARAM_TX_POWER (1 << 15)
#define MGMT_OP_REMOVE_ADVERTISING 0x003F
struct mgmt_cp_remove_advertising {
@@ -701,8 +705,32 @@ struct mgmt_rp_remove_adv_monitor {
} __packed;
#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054
+struct mgmt_cp_add_ext_adv_params {
+ uint8_t instance;
+ uint32_t flags;
+ uint16_t duration;
+ uint16_t timeout;
+ uint32_t min_interval;
+ uint32_t max_interval;
+ int8_t tx_power;
+} __packed;
+struct mgmt_rp_add_ext_adv_params {
+ uint8_t instance;
+ int8_t tx_power;
+ uint8_t max_adv_data_len;
+ uint8_t max_scan_rsp_len;
+} __packed;
#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055
+struct mgmt_cp_add_ext_adv_data {
+ uint8_t instance;
+ uint8_t adv_data_len;
+ uint8_t scan_rsp_len;
+ uint8_t data[0];
+} __packed;
+struct mgmt_rp_add_ext_adv_data {
+ uint8_t instance;
+} __packed;
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {