diff --git a/bumble/device.py b/bumble/device.py index 452bff23..4defac8e 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -794,6 +794,17 @@ class AdvertisingSet(EventEmitter): ) del self.device.extended_advertising_sets[self.advertising_handle] + async def transfer_periodic_info( + self, connection: Connection, service_data: int = 0 + ) -> None: + if not self.periodic_enabled: + raise core.InvalidStateError( + f"Periodic Advertising is not enabled on Advertising Set 0x{self.advertising_handle:02X}" + ) + await connection.transfer_periodic_set_info( + self.advertising_handle, service_data + ) + def on_termination(self, status: int) -> None: self.enabled = False self.emit('termination', status) @@ -1782,6 +1793,13 @@ class Connection(CompositeEventEmitter): ) -> None: await self.device.transfer_periodic_sync(self, sync_handle, service_data) + async def transfer_periodic_set_info( + self, advertising_handle: int, service_data: int = 0 + ) -> None: + await self.device.transfer_periodic_set_info( + self, advertising_handle, service_data + ) + # [Classic only] async def request_remote_name(self): return await self.device.request_remote_name(self) @@ -4001,6 +4019,18 @@ class Device(CompositeEventEmitter): check_result=True, ) + async def transfer_periodic_set_info( + self, connection: Connection, advertising_handle: int, service_data: int = 0 + ) -> None: + return await self.send_command( + hci.HCI_LE_Periodic_Advertising_Set_Info_Transfer_Command( + connection_handle=connection.handle, + service_data=service_data, + advertising_handle=advertising_handle, + ), + check_result=True, + ) + async def find_peer_by_name(self, name, transport=BT_LE_TRANSPORT): """ Scan for a peer with a given name and return its address. diff --git a/bumble/hci.py b/bumble/hci.py index e720cb8c..5f8c63a8 100644 --- a/bumble/hci.py +++ b/bumble/hci.py @@ -4883,6 +4883,20 @@ class HCI_LE_Periodic_Advertising_Sync_Transfer_Command(HCI_Command): ''' +# ----------------------------------------------------------------------------- +@HCI_Command.command( + fields=[('connection_handle', 2), ('service_data', 2), ('advertising_handle', 1)], + return_parameters_fields=[ + ('status', STATUS_SPEC), + ('connection_handle', 2), + ], +) +class HCI_LE_Periodic_Advertising_Set_Info_Transfer_Command(HCI_Command): + ''' + See Bluetooth spec @ 7.8.90 LE Periodic Advertising Set Info Transfer Command + ''' + + # ----------------------------------------------------------------------------- @HCI_Command.command( fields=[