bumble 0.0.186__py3-none-any.whl → 0.0.188__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.
bumble/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.186'
16
- __version_tuple__ = version_tuple = (0, 0, 186)
15
+ __version__ = version = '0.0.188'
16
+ __version_tuple__ = version_tuple = (0, 0, 188)
bumble/drivers/intel.py CHANGED
@@ -29,6 +29,17 @@ from bumble.hci import (
29
29
  # -----------------------------------------------------------------------------
30
30
  logger = logging.getLogger(__name__)
31
31
 
32
+ # -----------------------------------------------------------------------------
33
+ # Constant
34
+ # -----------------------------------------------------------------------------
35
+
36
+ INTEL_USB_PRODUCTS = {
37
+ # Intel AX210
38
+ (0x8087, 0x0032),
39
+ # Intel BE200
40
+ (0x8087, 0x0036),
41
+ }
42
+
32
43
  # -----------------------------------------------------------------------------
33
44
  # HCI Commands
34
45
  # -----------------------------------------------------------------------------
@@ -52,13 +63,34 @@ class Driver(common.Driver):
52
63
  def __init__(self, host):
53
64
  self.host = host
54
65
 
66
+ @staticmethod
67
+ def check(host):
68
+ driver = host.hci_metadata.get("driver")
69
+ if driver == "intel":
70
+ return True
71
+
72
+ vendor_id = host.hci_metadata.get("vendor_id")
73
+ product_id = host.hci_metadata.get("product_id")
74
+
75
+ if vendor_id is None or product_id is None:
76
+ logger.debug("USB metadata not sufficient")
77
+ return False
78
+
79
+ if (vendor_id, product_id) not in INTEL_USB_PRODUCTS:
80
+ logger.debug(
81
+ f"USB device ({vendor_id:04X}, {product_id:04X}) " "not in known list"
82
+ )
83
+ return False
84
+
85
+ return True
86
+
55
87
  @classmethod
56
- async def for_host(cls, host): # type: ignore
88
+ async def for_host(cls, host, force=False): # type: ignore
57
89
  # Only instantiate this driver if explicitly selected
58
- if host.hci_metadata.get("driver") == "intel":
59
- return cls(host)
90
+ if not force and not cls.check(host):
91
+ return None
60
92
 
61
- return None
93
+ return cls(host)
62
94
 
63
95
  async def init_controller(self):
64
96
  self.host.ready = True
bumble/pandora/host.py CHANGED
@@ -54,6 +54,8 @@ from pandora import host_pb2
54
54
  from pandora.host_pb2 import (
55
55
  NOT_CONNECTABLE,
56
56
  NOT_DISCOVERABLE,
57
+ DISCOVERABLE_LIMITED,
58
+ DISCOVERABLE_GENERAL,
57
59
  PRIMARY_1M,
58
60
  PRIMARY_CODED,
59
61
  SECONDARY_1M,
@@ -69,6 +71,7 @@ from pandora.host_pb2 import (
69
71
  ConnectResponse,
70
72
  DataTypes,
71
73
  DisconnectRequest,
74
+ DiscoverabilityMode,
72
75
  InquiryResponse,
73
76
  PrimaryPhy,
74
77
  ReadLocalAddressResponse,
@@ -483,14 +486,10 @@ class HostService(HostServicer):
483
486
  target_bytes = bytes(reversed(request.target))
484
487
  if request.target_variant() == "public":
485
488
  target = Address(target_bytes, Address.PUBLIC_DEVICE_ADDRESS)
486
- advertising_type = (
487
- AdvertisingType.DIRECTED_CONNECTABLE_HIGH_DUTY
488
- ) # FIXME: HIGH_DUTY ?
489
+ advertising_type = AdvertisingType.DIRECTED_CONNECTABLE_LOW_DUTY
489
490
  else:
490
491
  target = Address(target_bytes, Address.RANDOM_DEVICE_ADDRESS)
491
- advertising_type = (
492
- AdvertisingType.DIRECTED_CONNECTABLE_HIGH_DUTY
493
- ) # FIXME: HIGH_DUTY ?
492
+ advertising_type = AdvertisingType.DIRECTED_CONNECTABLE_LOW_DUTY
494
493
 
495
494
  if request.connectable:
496
495
 
@@ -867,6 +866,16 @@ class HostService(HostServicer):
867
866
  )
868
867
  )
869
868
 
869
+ flag_map = {
870
+ NOT_DISCOVERABLE: 0x00,
871
+ DISCOVERABLE_LIMITED: AdvertisingData.LE_LIMITED_DISCOVERABLE_MODE_FLAG,
872
+ DISCOVERABLE_GENERAL: AdvertisingData.LE_GENERAL_DISCOVERABLE_MODE_FLAG,
873
+ }
874
+
875
+ if dt.le_discoverability_mode:
876
+ flags = flag_map[dt.le_discoverability_mode]
877
+ ad_structures.append((AdvertisingData.FLAGS, flags.to_bytes(1, 'big')))
878
+
870
879
  return AdvertisingData(ad_structures)
871
880
 
872
881
  def pack_data_types(self, ad: AdvertisingData) -> DataTypes:
bumble/transport/pyusb.py CHANGED
@@ -113,9 +113,10 @@ async def open_pyusb_transport(spec: str) -> Transport:
113
113
  self.loop.call_soon_threadsafe(self.stop_event.set)
114
114
 
115
115
  class UsbPacketSource(asyncio.Protocol, ParserSource):
116
- def __init__(self, device, sco_enabled):
116
+ def __init__(self, device, metadata, sco_enabled):
117
117
  super().__init__()
118
118
  self.device = device
119
+ self.metadata = metadata
119
120
  self.loop = asyncio.get_running_loop()
120
121
  self.queue = asyncio.Queue()
121
122
  self.dequeue_task = None
@@ -216,6 +217,15 @@ async def open_pyusb_transport(spec: str) -> Transport:
216
217
  if ':' in spec:
217
218
  vendor_id, product_id = spec.split(':')
218
219
  device = usb_find(idVendor=int(vendor_id, 16), idProduct=int(product_id, 16))
220
+ elif '-' in spec:
221
+
222
+ def device_path(device):
223
+ if device.port_numbers:
224
+ return f'{device.bus}-{".".join(map(str, device.port_numbers))}'
225
+ else:
226
+ return str(device.bus)
227
+
228
+ device = usb_find(custom_match=lambda device: device_path(device) == spec)
219
229
  else:
220
230
  device_index = int(spec)
221
231
  devices = list(
@@ -235,6 +245,9 @@ async def open_pyusb_transport(spec: str) -> Transport:
235
245
  raise ValueError('device not found')
236
246
  logger.debug(f'USB Device: {device}')
237
247
 
248
+ # Collect the metadata
249
+ device_metadata = {'vendor_id': device.idVendor, 'product_id': device.idProduct}
250
+
238
251
  # Detach the kernel driver if needed
239
252
  if device.is_kernel_driver_active(0):
240
253
  logger.debug("detaching kernel driver")
@@ -289,7 +302,7 @@ async def open_pyusb_transport(spec: str) -> Transport:
289
302
  # except usb.USBError:
290
303
  # logger.warning('failed to set alternate setting')
291
304
 
292
- packet_source = UsbPacketSource(device, sco_enabled)
305
+ packet_source = UsbPacketSource(device, device_metadata, sco_enabled)
293
306
  packet_sink = UsbPacketSink(device)
294
307
  packet_source.start()
295
308
  packet_sink.start()
bumble/transport/usb.py CHANGED
@@ -396,6 +396,16 @@ async def open_usb_transport(spec: str) -> Transport:
396
396
  break
397
397
  device_index -= 1
398
398
  device.close()
399
+ elif '-' in spec:
400
+
401
+ def device_path(device):
402
+ return f'{device.getBusNumber()}-{".".join(map(str, device.getPortNumberList()))}'
403
+
404
+ for device in context.getDeviceIterator(skip_on_error=True):
405
+ if device_path(device) == spec:
406
+ found = device
407
+ break
408
+ device.close()
399
409
  else:
400
410
  # Look for a compatible device by index
401
411
  def device_is_bluetooth_hci(device):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bumble
3
- Version: 0.0.186
3
+ Version: 0.0.188
4
4
  Summary: Bluetooth Stack for Apps, Emulation, Test and Experimentation
5
5
  Home-page: https://github.com/google/bumble
6
6
  Author: Google
@@ -28,8 +28,8 @@ Requires-Dist: pyusb >=1.2 ; platform_system != "Emscripten"
28
28
  Requires-Dist: websockets >=12.0 ; platform_system != "Emscripten"
29
29
  Requires-Dist: cryptography >=39.0 ; platform_system == "Emscripten"
30
30
  Provides-Extra: avatar
31
- Requires-Dist: pandora-avatar ==0.0.5 ; extra == 'avatar'
32
- Requires-Dist: rootcanal ==1.7.0 ; (python_version >= "3.10") and extra == 'avatar'
31
+ Requires-Dist: pandora-avatar ==0.0.8 ; extra == 'avatar'
32
+ Requires-Dist: rootcanal ==1.9.0 ; (python_version >= "3.10") and extra == 'avatar'
33
33
  Provides-Extra: build
34
34
  Requires-Dist: build >=0.7 ; extra == 'build'
35
35
  Provides-Extra: development
@@ -1,5 +1,5 @@
1
1
  bumble/__init__.py,sha256=Q8jkz6rgl95IMAeInQVt_2GLoJl3DcEP2cxtrQ-ho5c,110
2
- bumble/_version.py,sha256=XNxvkhUHy6l1KWfU9FzdA2KtCSsV11v_RZAxe0jgpDY,415
2
+ bumble/_version.py,sha256=iguq_-ZmjRMEQMcKKQS8AXaSB60gif-XTbXbRKVaIUk,415
3
3
  bumble/a2dp.py,sha256=n8_JTJwngPh7ONfAgN9MxvfeYg1Ui5CIveIwlE4B_aE,22585
4
4
  bumble/at.py,sha256=kdrcsx2C8Rg61EWESD2QHwpZntkXkRBJLrPn9auv9K8,2961
5
5
  bumble/att.py,sha256=_HrhlCl4CXZM9mmBLTCPq5v2OW9eZ0-H6cSu5_jG_5o,32365
@@ -64,12 +64,12 @@ bumble/apps/speaker/speaker.js,sha256=DrT831yg3oBXKZ5usnfZjRU9X6Nw3zjIWSkz6sIgVt
64
64
  bumble/apps/speaker/speaker.py,sha256=lV4N-M8V95UwioTMfcfsVImvQ-jmMehU6jJhA_16A24,24196
65
65
  bumble/drivers/__init__.py,sha256=lxqJTghh21rQFThRTurwLysZm385TUcn8ZdpHQSWD88,3196
66
66
  bumble/drivers/common.py,sha256=pS783hudolLZAzF8IUWp7g6TXyQsUCEzqCsd1VGeYfQ,1507
67
- bumble/drivers/intel.py,sha256=1XwRe3nKbd-19agPoS3aubT61XDc3VZH5yJalax1sbs,2323
67
+ bumble/drivers/intel.py,sha256=-YcJI4ZC_fhHHxWyE8b4eB8V7suOFH1n9uayckGE9Uw,3231
68
68
  bumble/drivers/rtk.py,sha256=MMxmUo85VkRhFuhbc9SJEZVL9dnRjmsU9k8djmbUGcA,21369
69
69
  bumble/pandora/__init__.py,sha256=5NBVmndeTulANawift0jPT9ISp562wyIHTZ-4uP34Mg,3283
70
70
  bumble/pandora/config.py,sha256=KD85n3oRbuvD65sRah2H0gpxEW4YbD7HbYbsxdcpDDA,2388
71
71
  bumble/pandora/device.py,sha256=LFqCWrgYkQWrFUSKArsAABXkge8sB2DhvaQoEsC4Jn0,5344
72
- bumble/pandora/host.py,sha256=Km4LQvEEo0na4MyBZh02oFF0D6Qi7wBRQcYcyelRSMA,38685
72
+ bumble/pandora/host.py,sha256=JPXAoCSONUCf7xpxmurNRqgK0wtwmPk9W4a5My0zWus,39055
73
73
  bumble/pandora/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  bumble/pandora/security.py,sha256=-YJvEGKAQfx6gAUOfiuaj6x80UqNSaG3kMZVuZJNY5E,21944
75
75
  bumble/pandora/utils.py,sha256=Fq4glL0T5cJ2FODoDotmDNdYFOkTOR7DyyL8vkcxp20,3949
@@ -95,12 +95,12 @@ bumble/transport/file.py,sha256=eVM2V6Nk2nDAFdE7Rt01ZI3JdTovsH9OEU1gKYPJjpE,2010
95
95
  bumble/transport/hci_socket.py,sha256=EdgWi3-O5yvYcH4R4BkPtG79pnUo7GQtXWawuUHDoDQ,6331
96
96
  bumble/transport/pty.py,sha256=grTl-yvjMWHflNwuME4ccVqDbk6NIEgQMgH6Y9lf1fU,2732
97
97
  bumble/transport/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
98
- bumble/transport/pyusb.py,sha256=cE6VPDNE6a79AYR1D4H55WDLkFOM4sLPNDSYiX4worc,11496
98
+ bumble/transport/pyusb.py,sha256=RV42LSRlMhLx1LOdaF8TY4qePPGlONFaPqta7I5mYTw,11987
99
99
  bumble/transport/serial.py,sha256=loQxkeG7uE09enXWg2uGbxi6CeG70wn3kzPbEwULKw4,2446
100
100
  bumble/transport/tcp_client.py,sha256=deyUJYpj04QE00Mw_PTU5PHPA6mr1Nui3f5-QCy2zOw,1854
101
101
  bumble/transport/tcp_server.py,sha256=hixsSzB-fmzR1yuiHDWd1WhqAia3UA4Cog1Wu6DCLeg,3211
102
102
  bumble/transport/udp.py,sha256=di8I6HHACgBx3un-dzAahz9lTIUrh4LdeuYpeoifQEM,2239
103
- bumble/transport/usb.py,sha256=Q7C3iTnNkTHDFmaT96go9r8rLo0PfqSzlmSPCXEcpZs,21024
103
+ bumble/transport/usb.py,sha256=tP5vV0ts8xh3EDnfgejCBWpqh53aximLJ4Hn0nDYncg,21401
104
104
  bumble/transport/vhci.py,sha256=iI2WpighnvIP5zeyJUFSbjEdmCo24CWMdICamIcyJck,2250
105
105
  bumble/transport/ws_client.py,sha256=9gqm5jlVT_H6LfwsQwPpky07CINhgOK96ef53SMAxms,1757
106
106
  bumble/transport/ws_server.py,sha256=goe4xx7OnZiJy1a00Bg0CXM8uJhsGXbsijMYq2n62bI,3328
@@ -137,9 +137,9 @@ bumble/vendor/android/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
137
137
  bumble/vendor/android/hci.py,sha256=GZrkhaWmcMt1JpnRhv0NoySGkf2H4lNUV2f_omRZW0I,10741
138
138
  bumble/vendor/zephyr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
139
  bumble/vendor/zephyr/hci.py,sha256=d83bC0TvT947eN4roFjLkQefWtHOoNsr4xib2ctSkvA,3195
140
- bumble-0.0.186.dist-info/LICENSE,sha256=FvaYh4NRWIGgS_OwoBs5gFgkCmAghZ-DYnIGBZPuw-s,12142
141
- bumble-0.0.186.dist-info/METADATA,sha256=DtyODy8Q74zUyvZG3E1qrXDJL7DYTpVmKNEdnGTWuj8,5684
142
- bumble-0.0.186.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
143
- bumble-0.0.186.dist-info/entry_points.txt,sha256=UkNj1KMZDhzOb7O4OU7Jn4YI5KaxJZgQF2GF64BwOlQ,883
144
- bumble-0.0.186.dist-info/top_level.txt,sha256=tV6JJKaHPYMFiJYiBYFW24PCcfLxTJZdlu6BmH3Cb00,7
145
- bumble-0.0.186.dist-info/RECORD,,
140
+ bumble-0.0.188.dist-info/LICENSE,sha256=FvaYh4NRWIGgS_OwoBs5gFgkCmAghZ-DYnIGBZPuw-s,12142
141
+ bumble-0.0.188.dist-info/METADATA,sha256=PEkVrU3sS9sge_Kh9Z4rMt78J5ukWiET5IEcj7dImOI,5684
142
+ bumble-0.0.188.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
143
+ bumble-0.0.188.dist-info/entry_points.txt,sha256=UkNj1KMZDhzOb7O4OU7Jn4YI5KaxJZgQF2GF64BwOlQ,883
144
+ bumble-0.0.188.dist-info/top_level.txt,sha256=tV6JJKaHPYMFiJYiBYFW24PCcfLxTJZdlu6BmH3Cb00,7
145
+ bumble-0.0.188.dist-info/RECORD,,