bumble 0.0.203__py3-none-any.whl → 0.0.204__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.203'
16
- __version_tuple__ = version_tuple = (0, 0, 203)
15
+ __version__ = version = '0.0.204'
16
+ __version_tuple__ = version_tuple = (0, 0, 204)
bumble/apps/bench.py CHANGED
@@ -199,7 +199,7 @@ def log_stats(title, stats, precision=2):
199
199
  stats_min = min(stats)
200
200
  stats_max = max(stats)
201
201
  stats_avg = statistics.mean(stats)
202
- stats_stdev = statistics.stdev(stats)
202
+ stats_stdev = statistics.stdev(stats) if len(stats) >= 2 else 0
203
203
  logging.info(
204
204
  color(
205
205
  (
@@ -468,6 +468,7 @@ class Ping:
468
468
 
469
469
  for run in range(self.repeat + 1):
470
470
  self.done.clear()
471
+ self.ping_times = []
471
472
 
472
473
  if run > 0 and self.repeat and self.repeat_delay:
473
474
  logging.info(color(f'*** Repeat delay: {self.repeat_delay}', 'green'))
bumble/apps/pair.py CHANGED
@@ -373,7 +373,9 @@ async def pair(
373
373
  shared_data = (
374
374
  None
375
375
  if oob == '-'
376
- else OobData.from_ad(AdvertisingData.from_bytes(bytes.fromhex(oob)))
376
+ else OobData.from_ad(
377
+ AdvertisingData.from_bytes(bytes.fromhex(oob))
378
+ ).shared_data
377
379
  )
378
380
  legacy_context = OobLegacyContext()
379
381
  oob_contexts = PairingConfig.OobConfig(
@@ -381,16 +383,19 @@ async def pair(
381
383
  peer_data=shared_data,
382
384
  legacy_context=legacy_context,
383
385
  )
384
- oob_data = OobData(
385
- address=device.random_address,
386
- shared_data=shared_data,
387
- legacy_context=legacy_context,
388
- )
389
386
  print(color('@@@-----------------------------------', 'yellow'))
390
387
  print(color('@@@ OOB Data:', 'yellow'))
391
- print(color(f'@@@ {our_oob_context.share()}', 'yellow'))
388
+ if shared_data is None:
389
+ oob_data = OobData(
390
+ address=device.random_address, shared_data=our_oob_context.share()
391
+ )
392
+ print(
393
+ color(
394
+ f'@@@ SHARE: {bytes(oob_data.to_ad()).hex()}',
395
+ 'yellow',
396
+ )
397
+ )
392
398
  print(color(f'@@@ TK={legacy_context.tk.hex()}', 'yellow'))
393
- print(color(f'@@@ HEX: ({bytes(oob_data.to_ad()).hex()})', 'yellow'))
394
399
  print(color('@@@-----------------------------------', 'yellow'))
395
400
  else:
396
401
  oob_contexts = None
bumble/apps/show.py CHANGED
@@ -144,18 +144,18 @@ class Printer:
144
144
  help='Format of the input file',
145
145
  )
146
146
  @click.option(
147
- '--vendors',
147
+ '--vendor',
148
148
  type=click.Choice(['android', 'zephyr']),
149
149
  multiple=True,
150
150
  help='Support vendor-specific commands (list one or more)',
151
151
  )
152
152
  @click.argument('filename')
153
153
  # pylint: disable=redefined-builtin
154
- def main(format, vendors, filename):
155
- for vendor in vendors:
156
- if vendor == 'android':
154
+ def main(format, vendor, filename):
155
+ for vendor_name in vendor:
156
+ if vendor_name == 'android':
157
157
  import bumble.vendor.android.hci
158
- elif vendor == 'zephyr':
158
+ elif vendor_name == 'zephyr':
159
159
  import bumble.vendor.zephyr.hci
160
160
 
161
161
  input = open(filename, 'rb')
@@ -180,7 +180,7 @@ def main(format, vendors, filename):
180
180
  else:
181
181
  printer.print(color("[TRUNCATED]", "red"))
182
182
  except Exception as error:
183
- logger.exception()
183
+ logger.exception('')
184
184
  print(color(f'!!! {error}', 'red'))
185
185
 
186
186
 
bumble/att.py CHANGED
@@ -57,6 +57,7 @@ if TYPE_CHECKING:
57
57
  # pylint: disable=line-too-long
58
58
 
59
59
  ATT_CID = 0x04
60
+ ATT_PSM = 0x001F
60
61
 
61
62
  ATT_ERROR_RESPONSE = 0x01
62
63
  ATT_EXCHANGE_MTU_REQUEST = 0x02
@@ -756,13 +757,13 @@ class AttributeValue:
756
757
  def __init__(
757
758
  self,
758
759
  read: Union[
759
- Callable[[Optional[Connection]], bytes],
760
- Callable[[Optional[Connection]], Awaitable[bytes]],
760
+ Callable[[Optional[Connection]], Any],
761
+ Callable[[Optional[Connection]], Awaitable[Any]],
761
762
  None,
762
763
  ] = None,
763
764
  write: Union[
764
- Callable[[Optional[Connection], bytes], None],
765
- Callable[[Optional[Connection], bytes], Awaitable[None]],
765
+ Callable[[Optional[Connection], Any], None],
766
+ Callable[[Optional[Connection], Any], Awaitable[None]],
766
767
  None,
767
768
  ] = None,
768
769
  ):
@@ -821,13 +822,13 @@ class Attribute(EventEmitter):
821
822
  READ_REQUIRES_AUTHORIZATION = Permissions.READ_REQUIRES_AUTHORIZATION
822
823
  WRITE_REQUIRES_AUTHORIZATION = Permissions.WRITE_REQUIRES_AUTHORIZATION
823
824
 
824
- value: Union[bytes, AttributeValue]
825
+ value: Any
825
826
 
826
827
  def __init__(
827
828
  self,
828
829
  attribute_type: Union[str, bytes, UUID],
829
830
  permissions: Union[str, Attribute.Permissions],
830
- value: Union[str, bytes, AttributeValue] = b'',
831
+ value: Any = b'',
831
832
  ) -> None:
832
833
  EventEmitter.__init__(self)
833
834
  self.handle = 0
@@ -845,11 +846,7 @@ class Attribute(EventEmitter):
845
846
  else:
846
847
  self.type = attribute_type
847
848
 
848
- # Convert the value to a byte array
849
- if isinstance(value, str):
850
- self.value = bytes(value, 'utf-8')
851
- else:
852
- self.value = value
849
+ self.value = value
853
850
 
854
851
  def encode_value(self, value: Any) -> bytes:
855
852
  return value
@@ -892,6 +889,8 @@ class Attribute(EventEmitter):
892
889
  else:
893
890
  value = self.value
894
891
 
892
+ self.emit('read', connection, value)
893
+
895
894
  return self.encode_value(value)
896
895
 
897
896
  async def write_value(self, connection: Connection, value_bytes: bytes) -> None:
bumble/drivers/common.py CHANGED
@@ -20,6 +20,8 @@ Common types for drivers.
20
20
  # -----------------------------------------------------------------------------
21
21
  import abc
22
22
 
23
+ from bumble import core
24
+
23
25
 
24
26
  # -----------------------------------------------------------------------------
25
27
  # Classes