bumble 0.0.214__py3-none-any.whl → 0.0.216__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. bumble/_version.py +16 -3
  2. bumble/a2dp.py +15 -16
  3. bumble/apps/auracast.py +13 -38
  4. bumble/apps/bench.py +9 -10
  5. bumble/apps/ble_rpa_tool.py +1 -0
  6. bumble/apps/console.py +22 -25
  7. bumble/apps/controller_info.py +19 -19
  8. bumble/apps/controller_loopback.py +2 -2
  9. bumble/apps/controllers.py +1 -1
  10. bumble/apps/device_info.py +3 -3
  11. bumble/apps/gatt_dump.py +1 -1
  12. bumble/apps/gg_bridge.py +5 -6
  13. bumble/apps/hci_bridge.py +3 -3
  14. bumble/apps/l2cap_bridge.py +3 -3
  15. bumble/apps/lea_unicast/app.py +15 -25
  16. bumble/apps/pair.py +30 -43
  17. bumble/apps/pandora_server.py +5 -4
  18. bumble/apps/player/player.py +19 -22
  19. bumble/apps/rfcomm_bridge.py +3 -8
  20. bumble/apps/scan.py +16 -6
  21. bumble/apps/show.py +3 -4
  22. bumble/apps/speaker/speaker.py +22 -22
  23. bumble/apps/unbond.py +2 -1
  24. bumble/apps/usb_probe.py +1 -2
  25. bumble/att.py +241 -246
  26. bumble/audio/io.py +5 -9
  27. bumble/avc.py +2 -2
  28. bumble/avctp.py +6 -7
  29. bumble/avdtp.py +19 -22
  30. bumble/avrcp.py +1096 -588
  31. bumble/codecs.py +2 -0
  32. bumble/controller.py +52 -13
  33. bumble/core.py +567 -248
  34. bumble/crypto/__init__.py +2 -2
  35. bumble/crypto/builtin.py +1 -1
  36. bumble/crypto/cryptography.py +2 -4
  37. bumble/data_types.py +1025 -0
  38. bumble/device.py +318 -279
  39. bumble/drivers/__init__.py +3 -2
  40. bumble/drivers/intel.py +3 -4
  41. bumble/drivers/rtk.py +26 -9
  42. bumble/gap.py +4 -4
  43. bumble/gatt.py +3 -2
  44. bumble/gatt_adapters.py +3 -11
  45. bumble/gatt_client.py +69 -81
  46. bumble/gatt_server.py +124 -124
  47. bumble/hci.py +67 -18
  48. bumble/helpers.py +19 -26
  49. bumble/hfp.py +10 -21
  50. bumble/hid.py +22 -16
  51. bumble/host.py +181 -103
  52. bumble/keys.py +5 -3
  53. bumble/l2cap.py +121 -74
  54. bumble/link.py +8 -9
  55. bumble/pairing.py +7 -6
  56. bumble/pandora/__init__.py +8 -7
  57. bumble/pandora/config.py +3 -1
  58. bumble/pandora/device.py +3 -2
  59. bumble/pandora/host.py +38 -36
  60. bumble/pandora/l2cap.py +22 -21
  61. bumble/pandora/security.py +15 -15
  62. bumble/pandora/utils.py +5 -3
  63. bumble/profiles/aics.py +11 -11
  64. bumble/profiles/ams.py +7 -8
  65. bumble/profiles/ancs.py +6 -7
  66. bumble/profiles/ascs.py +4 -9
  67. bumble/profiles/asha.py +8 -12
  68. bumble/profiles/bap.py +11 -23
  69. bumble/profiles/bass.py +2 -7
  70. bumble/profiles/battery_service.py +3 -4
  71. bumble/profiles/cap.py +1 -2
  72. bumble/profiles/csip.py +2 -6
  73. bumble/profiles/device_information_service.py +2 -2
  74. bumble/profiles/gap.py +4 -4
  75. bumble/profiles/gatt_service.py +1 -4
  76. bumble/profiles/gmap.py +5 -5
  77. bumble/profiles/hap.py +62 -59
  78. bumble/profiles/heart_rate_service.py +5 -4
  79. bumble/profiles/le_audio.py +3 -1
  80. bumble/profiles/mcp.py +3 -7
  81. bumble/profiles/pacs.py +3 -6
  82. bumble/profiles/pbp.py +2 -0
  83. bumble/profiles/tmap.py +2 -3
  84. bumble/profiles/vcs.py +2 -8
  85. bumble/profiles/vocs.py +8 -8
  86. bumble/rfcomm.py +11 -14
  87. bumble/rtp.py +1 -0
  88. bumble/sdp.py +10 -8
  89. bumble/smp.py +142 -153
  90. bumble/snoop.py +5 -5
  91. bumble/tools/generate_company_id_list.py +1 -0
  92. bumble/tools/intel_fw_download.py +3 -3
  93. bumble/tools/intel_util.py +4 -4
  94. bumble/tools/rtk_fw_download.py +6 -3
  95. bumble/tools/rtk_util.py +24 -7
  96. bumble/transport/__init__.py +19 -15
  97. bumble/transport/android_emulator.py +8 -13
  98. bumble/transport/android_netsim.py +19 -18
  99. bumble/transport/common.py +12 -15
  100. bumble/transport/file.py +1 -1
  101. bumble/transport/hci_socket.py +4 -6
  102. bumble/transport/pty.py +5 -6
  103. bumble/transport/pyusb.py +7 -10
  104. bumble/transport/serial.py +2 -1
  105. bumble/transport/tcp_client.py +2 -2
  106. bumble/transport/tcp_server.py +11 -14
  107. bumble/transport/udp.py +3 -3
  108. bumble/transport/unix.py +67 -1
  109. bumble/transport/usb.py +6 -6
  110. bumble/transport/vhci.py +0 -1
  111. bumble/transport/ws_client.py +2 -1
  112. bumble/transport/ws_server.py +3 -2
  113. bumble/utils.py +20 -5
  114. bumble/vendor/android/hci.py +1 -2
  115. bumble/vendor/zephyr/hci.py +0 -1
  116. {bumble-0.0.214.dist-info → bumble-0.0.216.dist-info}/METADATA +2 -1
  117. bumble-0.0.216.dist-info/RECORD +183 -0
  118. bumble-0.0.214.dist-info/RECORD +0 -182
  119. {bumble-0.0.214.dist-info → bumble-0.0.216.dist-info}/WHEEL +0 -0
  120. {bumble-0.0.214.dist-info → bumble-0.0.216.dist-info}/entry_points.txt +0 -0
  121. {bumble-0.0.214.dist-info → bumble-0.0.216.dist-info}/licenses/LICENSE +0 -0
  122. {bumble-0.0.214.dist-info → bumble-0.0.216.dist-info}/top_level.txt +0 -0
bumble/codecs.py CHANGED
@@ -16,7 +16,9 @@
16
16
  # Imports
17
17
  # -----------------------------------------------------------------------------
18
18
  from __future__ import annotations
19
+
19
20
  from dataclasses import dataclass
21
+
20
22
  from typing_extensions import Self
21
23
 
22
24
  from bumble import core
bumble/controller.py CHANGED
@@ -17,34 +17,32 @@
17
17
  # -----------------------------------------------------------------------------
18
18
  from __future__ import annotations
19
19
 
20
- import logging
21
20
  import asyncio
22
21
  import dataclasses
23
22
  import itertools
23
+ import logging
24
24
  import random
25
25
  import struct
26
- from bumble.colors import color
27
- from bumble.core import (
28
- PhysicalTransport,
29
- )
26
+ from typing import TYPE_CHECKING, Any, Optional, Union
27
+
30
28
  from bumble import hci
29
+ from bumble.colors import color
30
+ from bumble.core import PhysicalTransport
31
31
  from bumble.hci import (
32
32
  HCI_ACL_DATA_PACKET,
33
33
  HCI_COMMAND_DISALLOWED_ERROR,
34
34
  HCI_COMMAND_PACKET,
35
35
  HCI_COMMAND_STATUS_PENDING,
36
- HCI_CONNECTION_TIMEOUT_ERROR,
37
36
  HCI_CONTROLLER_BUSY_ERROR,
38
37
  HCI_EVENT_PACKET,
39
38
  HCI_INVALID_HCI_COMMAND_PARAMETERS_ERROR,
40
39
  HCI_LE_1M_PHY,
40
+ HCI_REMOTE_USER_TERMINATED_CONNECTION_ERROR,
41
41
  HCI_SUCCESS,
42
- HCI_UNKNOWN_HCI_COMMAND_ERROR,
43
42
  HCI_UNKNOWN_CONNECTION_IDENTIFIER_ERROR,
44
- HCI_REMOTE_USER_TERMINATED_CONNECTION_ERROR,
43
+ HCI_UNKNOWN_HCI_COMMAND_ERROR,
45
44
  HCI_VERSION_BLUETOOTH_CORE_5_0,
46
45
  Address,
47
- Role,
48
46
  HCI_AclDataPacket,
49
47
  HCI_AclDataPacketAssembler,
50
48
  HCI_Command_Complete_Event,
@@ -53,7 +51,6 @@ from bumble.hci import (
53
51
  HCI_Connection_Request_Event,
54
52
  HCI_Disconnection_Complete_Event,
55
53
  HCI_Encryption_Change_Event,
56
- HCI_Synchronous_Connection_Complete_Event,
57
54
  HCI_LE_Advertising_Report_Event,
58
55
  HCI_LE_CIS_Established_Event,
59
56
  HCI_LE_CIS_Request_Event,
@@ -62,8 +59,9 @@ from bumble.hci import (
62
59
  HCI_Number_Of_Completed_Packets_Event,
63
60
  HCI_Packet,
64
61
  HCI_Role_Change_Event,
62
+ HCI_Synchronous_Connection_Complete_Event,
63
+ Role,
65
64
  )
66
- from typing import Optional, Union, Any, TYPE_CHECKING
67
65
 
68
66
  if TYPE_CHECKING:
69
67
  from bumble.link import LocalLink
@@ -89,6 +87,7 @@ class CisLink:
89
87
  cis_id: int
90
88
  cig_id: int
91
89
  acl_connection: Optional[Connection] = None
90
+ data_paths: set[int] = dataclasses.field(default_factory=set)
92
91
 
93
92
 
94
93
  # -----------------------------------------------------------------------------
@@ -382,6 +381,11 @@ class Controller:
382
381
  return connection
383
382
  return None
384
383
 
384
+ def find_iso_link_by_handle(self, handle: int) -> Optional[CisLink]:
385
+ return self.central_cis_links.get(handle) or self.peripheral_cis_links.get(
386
+ handle
387
+ )
388
+
385
389
  def on_link_central_connected(self, central_address):
386
390
  '''
387
391
  Called when an incoming connection occurs from a central on the link
@@ -1854,16 +1858,51 @@ class Controller:
1854
1858
  )
1855
1859
  )
1856
1860
 
1857
- def on_hci_le_setup_iso_data_path_command(self, command):
1861
+ def on_hci_le_setup_iso_data_path_command(
1862
+ self, command: hci.HCI_LE_Setup_ISO_Data_Path_Command
1863
+ ) -> bytes:
1858
1864
  '''
1859
1865
  See Bluetooth spec Vol 4, Part E - 7.8.109 LE Setup ISO Data Path Command
1860
1866
  '''
1867
+ if not (iso_link := self.find_iso_link_by_handle(command.connection_handle)):
1868
+ return struct.pack(
1869
+ '<BH',
1870
+ HCI_UNKNOWN_CONNECTION_IDENTIFIER_ERROR,
1871
+ command.connection_handle,
1872
+ )
1873
+ if command.data_path_direction in iso_link.data_paths:
1874
+ return struct.pack(
1875
+ '<BH',
1876
+ HCI_COMMAND_DISALLOWED_ERROR,
1877
+ command.connection_handle,
1878
+ )
1879
+ iso_link.data_paths.add(command.data_path_direction)
1861
1880
  return struct.pack('<BH', HCI_SUCCESS, command.connection_handle)
1862
1881
 
1863
- def on_hci_le_remove_iso_data_path_command(self, command):
1882
+ def on_hci_le_remove_iso_data_path_command(
1883
+ self, command: hci.HCI_LE_Remove_ISO_Data_Path_Command
1884
+ ) -> bytes:
1864
1885
  '''
1865
1886
  See Bluetooth spec Vol 4, Part E - 7.8.110 LE Remove ISO Data Path Command
1866
1887
  '''
1888
+ if not (iso_link := self.find_iso_link_by_handle(command.connection_handle)):
1889
+ return struct.pack(
1890
+ '<BH',
1891
+ HCI_UNKNOWN_CONNECTION_IDENTIFIER_ERROR,
1892
+ command.connection_handle,
1893
+ )
1894
+ data_paths: set[int] = set(
1895
+ direction
1896
+ for direction in hci.HCI_LE_Setup_ISO_Data_Path_Command.Direction
1897
+ if (1 << direction) & command.data_path_direction
1898
+ )
1899
+ if not data_paths.issubset(iso_link.data_paths):
1900
+ return struct.pack(
1901
+ '<BH',
1902
+ HCI_COMMAND_DISALLOWED_ERROR,
1903
+ command.connection_handle,
1904
+ )
1905
+ iso_link.data_paths.difference_update(data_paths)
1867
1906
  return struct.pack('<BH', HCI_SUCCESS, command.connection_handle)
1868
1907
 
1869
1908
  def on_hci_le_set_host_feature_command(