Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use le extended commands set if supported #30

Conversation

vicamo
Copy link
Contributor

@vicamo vicamo commented Oct 8, 2020

On some devices, observed on RTL8822CE and Intel AX201, issue 5.0 LE commands while bluetoothd has preconfigured 5.1 LE extended commands may cause Command Disallowed error and fails following scan:

@ RAW Open: python3 (privileged) version 2.22 {0x0003} [hci0] 4.021364
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #1 [hci0] 4.021692
        Type: Passive (0x00)
        Interval: 10.000 msec (0x0010)
        Window: 10.000 msec (0x0010)
        Own address type: Public (0x00)
        Filter policy: Accept all advertisement (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #2 [hci0] 4.139014
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Command Disallowed (0x0c)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #3 [hci0] 4.139129
        Scanning: Enabled (0x01)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #4 [hci0] 4.139962
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Command Disallowed (0x0c)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #5 [hci0] 121.924256
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
@ RAW Close: python3

This pull request adds HCI_Read_Local_Supported_Commands, HCI_LE_Set_Extended_Scan_Params and HCI_LE_Set_Extended_Scan_Enable to the support list and refactor a bit to ensure all further commands will only be issued after full initialized.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
This is to allow Commmand Complete response processing in the protocol
to determine correct handling of scan requests in later commits.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
@vicamo
Copy link
Contributor Author

vicamo commented Oct 8, 2020

LE Advertising should have the same issue, but I'll file another pull request for that separately.

@vicamo vicamo changed the title For upstream/use le extended commands set if supported use le extended commands set if supported Oct 21, 2020
@frawau
Copy link
Owner

frawau commented Oct 24, 2020

Hi,

Thank you for the pull request and sorry for waiting so long to reply... Was busy with work.

I do have one issue with you PR. The signature of the 'process' method changes in a non backward compatible way. If it is unavoidable, could you add a note in the README file to highlight the changes and give a short explanation as to why it was necessary.

I do not have a way to test those extended commands, but what tests I did seem to work.

Cheers,
François

@vicamo
Copy link
Contributor Author

vicamo commented Oct 24, 2020

You're right. It seems this project is also used in others, e.g. python-bluezero. Breaking any, inclusive of other send_foo_request calls, API would not be acceptable. However, I have a strong feeling that trying to initiate a LE scan using raw HCI packets is going to create more problems as more and more new devices get involved. I'm working a replacement leveraging BlueZ bluetoothd using DBus APIs instead. So I'm going to close this PR. Should you find any bit useful here, please don't hesitate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants