mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
Receive Periodic Advertising Sync Transfer
This commit is contained in:
@@ -257,7 +257,7 @@ class ExtendedAdvertisement(Advertisement):
|
|||||||
secondary_phy = report.secondary_phy,
|
secondary_phy = report.secondary_phy,
|
||||||
tx_power = report.tx_power,
|
tx_power = report.tx_power,
|
||||||
sid = report.advertising_sid,
|
sid = report.advertising_sid,
|
||||||
data_bytes = report.data
|
data_bytes = report.data,
|
||||||
)
|
)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
@@ -912,11 +912,11 @@ class PeriodicAdvertisingSync(EventEmitter):
|
|||||||
|
|
||||||
def on_establishment(
|
def on_establishment(
|
||||||
self,
|
self,
|
||||||
status,
|
status: int,
|
||||||
sync_handle,
|
sync_handle: int,
|
||||||
advertiser_phy,
|
advertiser_phy: int,
|
||||||
periodic_advertising_interval,
|
periodic_advertising_interval: int,
|
||||||
advertiser_clock_accuracy,
|
advertiser_clock_accuracy: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.status = status
|
self.status = status
|
||||||
|
|
||||||
@@ -3183,6 +3183,41 @@ class Device(CompositeEventEmitter):
|
|||||||
"periodic advertising sync establishment for unknown address/sid"
|
"periodic advertising sync establishment for unknown address/sid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@host_event_handler
|
||||||
|
def on_periodic_advertising_sync_transfer(
|
||||||
|
self,
|
||||||
|
status: int,
|
||||||
|
connection_handle: int,
|
||||||
|
sync_handle: int,
|
||||||
|
advertising_sid: int,
|
||||||
|
advertiser_address: hci.Address,
|
||||||
|
advertiser_phy: int,
|
||||||
|
periodic_advertising_interval: int,
|
||||||
|
advertiser_clock_accuracy: int,
|
||||||
|
) -> None:
|
||||||
|
if not (connection := self.lookup_connection(connection_handle)):
|
||||||
|
logger.error(
|
||||||
|
"Receive PAST from unknown connection 0x%04X", connection_handle
|
||||||
|
)
|
||||||
|
|
||||||
|
pa_sync = PeriodicAdvertisingSync(
|
||||||
|
device=self,
|
||||||
|
advertiser_address=advertiser_address,
|
||||||
|
sid=advertising_sid,
|
||||||
|
skip=0,
|
||||||
|
sync_timeout=0.0,
|
||||||
|
filter_duplicates=False,
|
||||||
|
)
|
||||||
|
self.periodic_advertising_syncs.append(pa_sync)
|
||||||
|
pa_sync.on_establishment(
|
||||||
|
status=status,
|
||||||
|
sync_handle=sync_handle,
|
||||||
|
advertiser_phy=advertiser_phy,
|
||||||
|
periodic_advertising_interval=periodic_advertising_interval,
|
||||||
|
advertiser_clock_accuracy=advertiser_clock_accuracy,
|
||||||
|
)
|
||||||
|
self.emit('periodic_advertising_sync_transfer', pa_sync, connection)
|
||||||
|
|
||||||
@host_event_handler
|
@host_event_handler
|
||||||
@with_periodic_advertising_sync_from_handle
|
@with_periodic_advertising_sync_from_handle
|
||||||
def on_periodic_advertising_sync_loss(
|
def on_periodic_advertising_sync_loss(
|
||||||
|
|||||||
@@ -4878,6 +4878,62 @@ class HCI_LE_Periodic_Advertising_Sync_Transfer_Command(HCI_Command):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
@HCI_Command.command(
|
||||||
|
fields=[
|
||||||
|
('connection_handle', 2),
|
||||||
|
('mode', 1),
|
||||||
|
('skip', 2),
|
||||||
|
('sync_timeout', 2),
|
||||||
|
(
|
||||||
|
'cte_type',
|
||||||
|
{
|
||||||
|
'size': 1,
|
||||||
|
'mapper': lambda x: HCI_LE_Periodic_Advertising_Report_Event.CteType(
|
||||||
|
x
|
||||||
|
).name,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
return_parameters_fields=[
|
||||||
|
('status', STATUS_SPEC),
|
||||||
|
('connection_handle', 2),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
class HCI_LE_Set_Periodic_Advertising_Sync_Transfer_Parameters_Command(HCI_Command):
|
||||||
|
'''
|
||||||
|
See Bluetooth spec @ 7.8.91 LE Set Periodic Advertising Sync Transfer Parameters command
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
@HCI_Command.command(
|
||||||
|
fields=[
|
||||||
|
('mode', 1),
|
||||||
|
('skip', 2),
|
||||||
|
('sync_timeout', 2),
|
||||||
|
(
|
||||||
|
'cte_type',
|
||||||
|
{
|
||||||
|
'size': 1,
|
||||||
|
'mapper': lambda x: HCI_LE_Periodic_Advertising_Report_Event.CteType(
|
||||||
|
x
|
||||||
|
).name,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
return_parameters_fields=[
|
||||||
|
('status', STATUS_SPEC),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
class HCI_LE_Set_Default_Periodic_Advertising_Sync_Transfer_Parameters_Command(
|
||||||
|
HCI_Command
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
See Bluetooth spec @ 7.8.92 LE Set Default Periodic Advertising Sync Transfer Parameters command
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@HCI_Command.command(
|
@HCI_Command.command(
|
||||||
fields=[
|
fields=[
|
||||||
@@ -6231,6 +6287,31 @@ class HCI_LE_Periodic_Advertising_Sync_Transfer_Received_Event(HCI_LE_Meta_Event
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
@HCI_LE_Meta_Event.event(
|
||||||
|
[
|
||||||
|
('status', STATUS_SPEC),
|
||||||
|
('connection_handle', 2),
|
||||||
|
('service_data', 2),
|
||||||
|
('sync_handle', 2),
|
||||||
|
('advertising_sid', 1),
|
||||||
|
('advertiser_address_type', Address.ADDRESS_TYPE_SPEC),
|
||||||
|
('advertiser_address', Address.parse_address_preceded_by_type),
|
||||||
|
('advertiser_phy', 1),
|
||||||
|
('periodic_advertising_interval', 2),
|
||||||
|
('advertiser_clock_accuracy', 1),
|
||||||
|
('num_subevents', 1),
|
||||||
|
('subevent_interval', 1),
|
||||||
|
('response_slot_delay', 1),
|
||||||
|
('response_slot_spacing', 1),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
class HCI_LE_Periodic_Advertising_Sync_Transfer_Received_V2_Event(HCI_LE_Meta_Event):
|
||||||
|
'''
|
||||||
|
See Bluetooth spec @ 7.7.65.24 LE Periodic Advertising Sync Transfer Received Event
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@HCI_LE_Meta_Event.event(
|
@HCI_LE_Meta_Event.event(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1204,6 +1204,32 @@ class Host(AbortableEventEmitter):
|
|||||||
self.remove_big(event.big_handle)
|
self.remove_big(event.big_handle)
|
||||||
self.emit('big_termination', event.reason, event.big_handle)
|
self.emit('big_termination', event.reason, event.big_handle)
|
||||||
|
|
||||||
|
def on_hci_le_periodic_advertising_sync_transfer_received_event(self, event):
|
||||||
|
self.emit(
|
||||||
|
'periodic_advertising_sync_transfer',
|
||||||
|
event.status,
|
||||||
|
event.connection_handle,
|
||||||
|
event.sync_handle,
|
||||||
|
event.advertising_sid,
|
||||||
|
event.advertiser_address,
|
||||||
|
event.advertiser_phy,
|
||||||
|
event.periodic_advertising_interval,
|
||||||
|
event.advertiser_clock_accuracy,
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_hci_le_periodic_advertising_sync_transfer_received_v2_event(self, event):
|
||||||
|
self.emit(
|
||||||
|
'periodic_advertising_sync_transfer',
|
||||||
|
event.status,
|
||||||
|
event.connection_handle,
|
||||||
|
event.sync_handle,
|
||||||
|
event.advertising_sid,
|
||||||
|
event.advertiser_address,
|
||||||
|
event.advertiser_phy,
|
||||||
|
event.periodic_advertising_interval,
|
||||||
|
event.advertiser_clock_accuracy,
|
||||||
|
)
|
||||||
|
|
||||||
def on_hci_le_cis_established_event(self, event):
|
def on_hci_le_cis_established_event(self, event):
|
||||||
# The remaining parameters are unused for now.
|
# The remaining parameters are unused for now.
|
||||||
if event.status == hci.HCI_SUCCESS:
|
if event.status == hci.HCI_SUCCESS:
|
||||||
|
|||||||
Reference in New Issue
Block a user