Bluetooth: Remove adv set for directed advertising
authorSathish Narsimman <nsathish41@gmail.com>
Mon, 24 Feb 2020 05:32:24 +0000 (11:02 +0530)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 28 Feb 2020 07:38:05 +0000 (08:38 +0100)
Extended advertising Data is set during bluetooth initialization
by default which causes InvalidHCICommandParameters when setting
Extended advertising parameters.

As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
advertising_event_property LE_LEGACY_ADV_DIRECT_IND does not
supports advertising data when the advertising set already
contains some, the controller shall return erroc code
'InvalidHCICommandParameters(0x12).

So it is required to remove adv set for handle 0x00. since we use
instance 0 for directed adv.

Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci.h
net/bluetooth/hci_conn.c

index d878bf8dce2061f80ce745e99dfa84b9679334b0..29b638c6c934cf2522152abd7bce3187fa69830d 100644 (file)
@@ -1724,6 +1724,8 @@ struct hci_cp_le_set_ext_scan_rsp_data {
 
 #define LE_SET_ADV_DATA_NO_FRAG                0x01
 
+#define HCI_OP_LE_REMOVE_ADV_SET       0x203c
+
 #define HCI_OP_LE_CLEAR_ADV_SETS       0x203d
 
 #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR        0x2035
index a582c676e584c9de6c2a3a297827d935566109a6..2731f0ad2a903b3e881c37baf10353c0499f88ff 100644 (file)
@@ -898,6 +898,16 @@ static void hci_req_directed_advertising(struct hci_request *req,
                cp.peer_addr_type = conn->dst_type;
                bacpy(&cp.peer_addr, &conn->dst);
 
+               /* As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
+                * advertising_event_property LE_LEGACY_ADV_DIRECT_IND
+                * does not supports advertising data when the advertising set already
+                * contains some, the controller shall return erroc code 'Invalid
+                * HCI Command Parameters(0x12).
+                * So it is required to remove adv set for handle 0x00. since we use
+                * instance 0 for directed adv.
+                */
+               hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle);
+
                hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
 
                if (own_addr_type == ADDR_LE_DEV_RANDOM &&