问题
This issue I am observing with kernel above 5.0. And with controllers that have extended advertising enabled. I have currently tested with bluez-5.50.
The issue is something to do with "MGMT_ADV_FLAG_SEC_MASK" flag is what I could get from the code. But when and how will this flag be modified is what I dont understand.
Config: kernel 5.4.24(issue seen with any 5.0+ kernel) , bluez 5.50 I am doing following steps: 1. hciattach the BLE extended ADV enabled controller. 2. hciconfig hci0 reset.
I am getting following error for Extended Scan rsp command (during the hciconfig hci0 reset sequence):
LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1
Status: Invalid HCI Command Parameters (0x12)
And this I am getting because of below written in core_v5.2: "If the advertising set is non-scannable and the Host uses this command other than to discard existing data, the Controller shall return the error code Invalid HCI Command Parameters (0x12). If the advertising set uses scannable legacy advertising PDUs and either Operation is not 0x03 or the Scan_Response_Data_Length parameter exceeds 31 octets, the Controller shall return the error code Invalid HCI Command Parameters (0x12). If Operation is not 0x03 and Scan_Response_Data_Length is zero, the Controller shall return the error code Invalid HCI Command Parameters (0x12) "
So in my extended HCI Command Extended Advertising set command just before extended scan rsp set:
*LE Set Extended Advertising Parameters (0x08|0x0036) plen 25
Handle: 0x00
Properties: 0x0010
Use legacy advertising PDUs: ADV_NONCONN_IND
This legacy advertising is set because of the MGMT_ADV_FLAG_SEC_MASK as checked in kernel code. I want to know which parameter from the controller LE features or anything else is required to set it right.
In my bluetooth controller multi ADV is not supported , extended ADV is supported.
回答1:
Got the issue, it was with extended adv for kernel 5.4.24. In the kernel version 5.7.7. I found this difference in file hci_request.c, function get_adv_instance_scan_rsp_len, currently(kernel 5.4.24) the code is:
static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance)
{
struct adv_info *adv_instance;
/* Ignore instance 0 */
if (instance == 0x00)
return 0;
In the 5.7.7 it is changed to:
static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance)
{
struct adv_info *adv_instance;
/* Instance 0x00 always set local name */
if (instance == 0x00)
return 1;
What this should change is, it should satisfy the condition below, which currently wasn’t. So basically should set the scannable flag by which the scan rsp data cmd doesnt fail:
} else if (get_adv_instance_scan_rsp_len(hdev, instance)) {
if (secondary_adv)
cp.evt_properties = cpu_to_le16(LE_EXT_ADV_SCAN_IND);
else
cp.evt_properties = cpu_to_le16(LE_LEGACY_ADV_SCAN_IND);
来源:https://stackoverflow.com/questions/61935284/invalid-params-issue-when-doing-hciconfig-hci0-reset