Skip to content

Commit

Permalink
Merge pull request #527 from zxzxwu/scan
Browse files Browse the repository at this point in the history
Support Interlaced Scan config
  • Loading branch information
zxzxwu authored Aug 12, 2024
2 parents 4433184 + 3824e38 commit 3c12be5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

from pyee import EventEmitter

from bumble import hci
from .colors import color
from .att import ATT_CID, ATT_DEFAULT_MTU, ATT_PDU
from .gatt import Characteristic, Descriptor, Service
Expand Down Expand Up @@ -168,6 +169,7 @@
OwnAddressType,
LeFeature,
LeFeatureMask,
LmpFeatureMask,
Phy,
phy_list_to_bits,
)
Expand Down Expand Up @@ -1583,6 +1585,7 @@ class DeviceConfiguration:
classic_ssp_enabled: bool = True
classic_smp_enabled: bool = True
classic_accept_any: bool = True
classic_interlaced_scan_enabled: bool = True
connectable: bool = True
discoverable: bool = True
advertising_data: bytes = bytes(
Expand Down Expand Up @@ -1895,6 +1898,7 @@ def __init__(
self.classic_sc_enabled = config.classic_sc_enabled
self.classic_ssp_enabled = config.classic_ssp_enabled
self.classic_smp_enabled = config.classic_smp_enabled
self.classic_interlaced_scan_enabled = config.classic_interlaced_scan_enabled
self.discoverable = config.discoverable
self.connectable = config.connectable
self.classic_accept_any = config.classic_accept_any
Expand Down Expand Up @@ -2268,6 +2272,21 @@ async def power_on(self) -> None:
await self.set_connectable(self.connectable)
await self.set_discoverable(self.discoverable)

if self.classic_interlaced_scan_enabled:
if self.host.supports_lmp_features(LmpFeatureMask.INTERLACED_PAGE_SCAN):
await self.send_command(
hci.HCI_Write_Page_Scan_Type_Command(page_scan_type=1),
check_result=True,
)

if self.host.supports_lmp_features(
LmpFeatureMask.INTERLACED_INQUIRY_SCAN
):
await self.send_command(
hci.HCI_Write_Inquiry_Scan_Type_Command(scan_type=1),
check_result=True,
)

# Done
self.powered_on = True

Expand Down

0 comments on commit 3c12be5

Please sign in to comment.