bumble 0.0.195__py3-none-any.whl → 0.0.198__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 (50) hide show
  1. bumble/_version.py +2 -2
  2. bumble/apps/auracast.py +351 -66
  3. bumble/apps/console.py +5 -20
  4. bumble/apps/device_info.py +230 -0
  5. bumble/apps/gatt_dump.py +4 -0
  6. bumble/apps/lea_unicast/app.py +16 -17
  7. bumble/at.py +12 -6
  8. bumble/avc.py +8 -5
  9. bumble/avctp.py +3 -2
  10. bumble/avdtp.py +5 -1
  11. bumble/avrcp.py +2 -1
  12. bumble/codecs.py +17 -13
  13. bumble/colors.py +6 -2
  14. bumble/core.py +37 -7
  15. bumble/device.py +382 -111
  16. bumble/drivers/rtk.py +13 -8
  17. bumble/gatt.py +6 -1
  18. bumble/gatt_client.py +10 -4
  19. bumble/hci.py +50 -25
  20. bumble/hid.py +24 -28
  21. bumble/host.py +4 -0
  22. bumble/l2cap.py +24 -17
  23. bumble/link.py +8 -3
  24. bumble/profiles/ascs.py +739 -0
  25. bumble/profiles/bap.py +1 -874
  26. bumble/profiles/bass.py +440 -0
  27. bumble/profiles/csip.py +4 -4
  28. bumble/profiles/gap.py +110 -0
  29. bumble/profiles/heart_rate_service.py +4 -3
  30. bumble/profiles/le_audio.py +43 -9
  31. bumble/profiles/mcp.py +448 -0
  32. bumble/profiles/pacs.py +210 -0
  33. bumble/profiles/tmap.py +89 -0
  34. bumble/rfcomm.py +4 -2
  35. bumble/sdp.py +13 -11
  36. bumble/smp.py +20 -8
  37. bumble/snoop.py +5 -4
  38. bumble/transport/__init__.py +8 -2
  39. bumble/transport/android_emulator.py +9 -3
  40. bumble/transport/android_netsim.py +9 -7
  41. bumble/transport/common.py +46 -18
  42. bumble/transport/pyusb.py +2 -2
  43. bumble/transport/unix.py +56 -0
  44. bumble/transport/usb.py +57 -46
  45. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/METADATA +41 -41
  46. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/RECORD +50 -42
  47. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/WHEEL +1 -1
  48. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/LICENSE +0 -0
  49. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/entry_points.txt +0 -0
  50. {bumble-0.0.195.dist-info → bumble-0.0.198.dist-info}/top_level.txt +0 -0
bumble/colors.py CHANGED
@@ -16,6 +16,10 @@ from functools import partial
16
16
  from typing import List, Optional, Union
17
17
 
18
18
 
19
+ class ColorError(ValueError):
20
+ """Error raised when a color spec is invalid."""
21
+
22
+
19
23
  # ANSI color names. There is also a "default"
20
24
  COLORS = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
21
25
 
@@ -52,7 +56,7 @@ def _color_code(spec: ColorSpec, base: int) -> str:
52
56
  elif isinstance(spec, int) and 0 <= spec <= 255:
53
57
  return _join(base + 8, 5, spec)
54
58
  else:
55
- raise ValueError('Invalid color spec "%s"' % spec)
59
+ raise ColorError('Invalid color spec "%s"' % spec)
56
60
 
57
61
 
58
62
  def color(
@@ -72,7 +76,7 @@ def color(
72
76
  if style_part in STYLES:
73
77
  codes.append(STYLES.index(style_part))
74
78
  else:
75
- raise ValueError('Invalid style "%s"' % style_part)
79
+ raise ColorError('Invalid style "%s"' % style_part)
76
80
 
77
81
  if codes:
78
82
  return '\x1b[{0}m{1}\x1b[0m'.format(_join(*codes), s)
bumble/core.py CHANGED
@@ -79,7 +79,13 @@ def get_dict_key_by_value(dictionary, value):
79
79
  # -----------------------------------------------------------------------------
80
80
  # Exceptions
81
81
  # -----------------------------------------------------------------------------
82
- class BaseError(Exception):
82
+
83
+
84
+ class BaseBumbleError(Exception):
85
+ """Base Error raised by Bumble."""
86
+
87
+
88
+ class BaseError(BaseBumbleError):
83
89
  """Base class for errors with an error code, error name and namespace"""
84
90
 
85
91
  def __init__(
@@ -118,18 +124,42 @@ class ProtocolError(BaseError):
118
124
  """Protocol Error"""
119
125
 
120
126
 
121
- class TimeoutError(Exception): # pylint: disable=redefined-builtin
127
+ class TimeoutError(BaseBumbleError): # pylint: disable=redefined-builtin
122
128
  """Timeout Error"""
123
129
 
124
130
 
125
- class CommandTimeoutError(Exception):
131
+ class CommandTimeoutError(BaseBumbleError):
126
132
  """Command Timeout Error"""
127
133
 
128
134
 
129
- class InvalidStateError(Exception):
135
+ class InvalidStateError(BaseBumbleError):
130
136
  """Invalid State Error"""
131
137
 
132
138
 
139
+ class InvalidArgumentError(BaseBumbleError, ValueError):
140
+ """Invalid Argument Error"""
141
+
142
+
143
+ class InvalidPacketError(BaseBumbleError, ValueError):
144
+ """Invalid Packet Error"""
145
+
146
+
147
+ class InvalidOperationError(BaseBumbleError, RuntimeError):
148
+ """Invalid Operation Error"""
149
+
150
+
151
+ class NotSupportedError(BaseBumbleError, RuntimeError):
152
+ """Not Supported"""
153
+
154
+
155
+ class OutOfResourcesError(BaseBumbleError, RuntimeError):
156
+ """Out of Resources Error"""
157
+
158
+
159
+ class UnreachableError(BaseBumbleError):
160
+ """The code path raising this error should be unreachable."""
161
+
162
+
133
163
  class ConnectionError(BaseError): # pylint: disable=redefined-builtin
134
164
  """Connection Error"""
135
165
 
@@ -188,12 +218,12 @@ class UUID:
188
218
  or uuid_str_or_int[18] != '-'
189
219
  or uuid_str_or_int[23] != '-'
190
220
  ):
191
- raise ValueError('invalid UUID format')
221
+ raise InvalidArgumentError('invalid UUID format')
192
222
  uuid_str = uuid_str_or_int.replace('-', '')
193
223
  else:
194
224
  uuid_str = uuid_str_or_int
195
225
  if len(uuid_str) != 32 and len(uuid_str) != 8 and len(uuid_str) != 4:
196
- raise ValueError(f"invalid UUID format: {uuid_str}")
226
+ raise InvalidArgumentError(f"invalid UUID format: {uuid_str}")
197
227
  self.uuid_bytes = bytes(reversed(bytes.fromhex(uuid_str)))
198
228
  self.name = name
199
229
 
@@ -218,7 +248,7 @@ class UUID:
218
248
 
219
249
  return self.register()
220
250
 
221
- raise ValueError('only 2, 4 and 16 bytes are allowed')
251
+ raise InvalidArgumentError('only 2, 4 and 16 bytes are allowed')
222
252
 
223
253
  @classmethod
224
254
  def from_16_bits(cls, uuid_16: int, name: Optional[str] = None) -> UUID: