bumble 0.0.208__py3-none-any.whl → 0.0.210__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 +2 -2
- bumble/a2dp.py +7 -7
- bumble/apps/auracast.py +37 -29
- bumble/apps/bench.py +9 -7
- bumble/apps/console.py +1 -1
- bumble/apps/lea_unicast/app.py +6 -2
- bumble/apps/pair.py +4 -3
- bumble/apps/player/player.py +3 -3
- bumble/apps/rfcomm_bridge.py +1 -1
- bumble/apps/speaker/speaker.py +4 -2
- bumble/att.py +12 -5
- bumble/avc.py +5 -5
- bumble/avdtp.py +9 -10
- bumble/avrcp.py +18 -19
- bumble/bridge.py +2 -2
- bumble/controller.py +13 -15
- bumble/core.py +61 -60
- bumble/device.py +193 -162
- bumble/drivers/__init__.py +2 -2
- bumble/gap.py +1 -1
- bumble/gatt.py +16 -0
- bumble/gatt_adapters.py +3 -3
- bumble/gatt_client.py +27 -21
- bumble/gatt_server.py +9 -10
- bumble/hci.py +109 -90
- bumble/hfp.py +3 -3
- bumble/hid.py +4 -3
- bumble/host.py +30 -19
- bumble/keys.py +3 -3
- bumble/l2cap.py +21 -19
- bumble/link.py +5 -6
- bumble/pairing.py +3 -3
- bumble/pandora/__init__.py +5 -5
- bumble/pandora/host.py +30 -23
- bumble/pandora/l2cap.py +2 -2
- bumble/pandora/security.py +17 -19
- bumble/pandora/utils.py +2 -2
- bumble/profiles/aics.py +6 -6
- bumble/profiles/ancs.py +513 -0
- bumble/profiles/ascs.py +17 -10
- bumble/profiles/asha.py +5 -5
- bumble/profiles/bass.py +1 -1
- bumble/profiles/csip.py +10 -10
- bumble/profiles/gatt_service.py +12 -12
- bumble/profiles/hap.py +16 -16
- bumble/profiles/mcp.py +26 -24
- bumble/profiles/pacs.py +6 -6
- bumble/profiles/pbp.py +1 -1
- bumble/profiles/vcs.py +6 -4
- bumble/profiles/vocs.py +3 -3
- bumble/rfcomm.py +8 -8
- bumble/sdp.py +1 -1
- bumble/smp.py +39 -33
- bumble/transport/__init__.py +24 -19
- bumble/transport/android_emulator.py +8 -4
- bumble/transport/android_netsim.py +8 -5
- bumble/transport/common.py +5 -1
- bumble/transport/file.py +1 -1
- bumble/transport/hci_socket.py +1 -1
- bumble/transport/pty.py +1 -1
- bumble/transport/pyusb.py +3 -3
- bumble/transport/serial.py +1 -1
- bumble/transport/tcp_client.py +1 -1
- bumble/transport/tcp_server.py +1 -1
- bumble/transport/udp.py +1 -1
- bumble/transport/unix.py +1 -1
- bumble/transport/usb.py +1 -3
- bumble/transport/vhci.py +2 -2
- bumble/transport/ws_client.py +6 -1
- bumble/transport/ws_server.py +1 -1
- bumble/utils.py +89 -76
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info}/METADATA +3 -2
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info}/RECORD +77 -76
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info}/WHEEL +1 -1
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info}/entry_points.txt +0 -0
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info/licenses}/LICENSE +0 -0
- {bumble-0.0.208.dist-info → bumble-0.0.210.dist-info}/top_level.txt +0 -0
bumble/transport/__init__.py
CHANGED
|
@@ -20,8 +20,13 @@ import logging
|
|
|
20
20
|
import os
|
|
21
21
|
from typing import Optional
|
|
22
22
|
|
|
23
|
-
from .common import
|
|
24
|
-
|
|
23
|
+
from bumble.transport.common import (
|
|
24
|
+
Transport,
|
|
25
|
+
AsyncPipeSink,
|
|
26
|
+
SnoopingTransport,
|
|
27
|
+
TransportSpecError,
|
|
28
|
+
)
|
|
29
|
+
from bumble.snoop import create_snooper
|
|
25
30
|
|
|
26
31
|
# -----------------------------------------------------------------------------
|
|
27
32
|
# Logging
|
|
@@ -108,80 +113,80 @@ async def _open_transport(scheme: str, spec: Optional[str]) -> Transport:
|
|
|
108
113
|
# pylint: disable=too-many-return-statements
|
|
109
114
|
|
|
110
115
|
if scheme == 'serial' and spec:
|
|
111
|
-
from .serial import open_serial_transport
|
|
116
|
+
from bumble.transport.serial import open_serial_transport
|
|
112
117
|
|
|
113
118
|
return await open_serial_transport(spec)
|
|
114
119
|
|
|
115
120
|
if scheme == 'udp' and spec:
|
|
116
|
-
from .udp import open_udp_transport
|
|
121
|
+
from bumble.transport.udp import open_udp_transport
|
|
117
122
|
|
|
118
123
|
return await open_udp_transport(spec)
|
|
119
124
|
|
|
120
125
|
if scheme == 'tcp-client' and spec:
|
|
121
|
-
from .tcp_client import open_tcp_client_transport
|
|
126
|
+
from bumble.transport.tcp_client import open_tcp_client_transport
|
|
122
127
|
|
|
123
128
|
return await open_tcp_client_transport(spec)
|
|
124
129
|
|
|
125
130
|
if scheme == 'tcp-server' and spec:
|
|
126
|
-
from .tcp_server import open_tcp_server_transport
|
|
131
|
+
from bumble.transport.tcp_server import open_tcp_server_transport
|
|
127
132
|
|
|
128
133
|
return await open_tcp_server_transport(spec)
|
|
129
134
|
|
|
130
135
|
if scheme == 'ws-client' and spec:
|
|
131
|
-
from .ws_client import open_ws_client_transport
|
|
136
|
+
from bumble.transport.ws_client import open_ws_client_transport
|
|
132
137
|
|
|
133
138
|
return await open_ws_client_transport(spec)
|
|
134
139
|
|
|
135
140
|
if scheme == 'ws-server' and spec:
|
|
136
|
-
from .ws_server import open_ws_server_transport
|
|
141
|
+
from bumble.transport.ws_server import open_ws_server_transport
|
|
137
142
|
|
|
138
143
|
return await open_ws_server_transport(spec)
|
|
139
144
|
|
|
140
145
|
if scheme == 'pty':
|
|
141
|
-
from .pty import open_pty_transport
|
|
146
|
+
from bumble.transport.pty import open_pty_transport
|
|
142
147
|
|
|
143
148
|
return await open_pty_transport(spec)
|
|
144
149
|
|
|
145
150
|
if scheme == 'file':
|
|
146
|
-
from .file import open_file_transport
|
|
151
|
+
from bumble.transport.file import open_file_transport
|
|
147
152
|
|
|
148
153
|
assert spec is not None
|
|
149
154
|
return await open_file_transport(spec)
|
|
150
155
|
|
|
151
156
|
if scheme == 'vhci':
|
|
152
|
-
from .vhci import open_vhci_transport
|
|
157
|
+
from bumble.transport.vhci import open_vhci_transport
|
|
153
158
|
|
|
154
159
|
return await open_vhci_transport(spec)
|
|
155
160
|
|
|
156
161
|
if scheme == 'hci-socket':
|
|
157
|
-
from .hci_socket import open_hci_socket_transport
|
|
162
|
+
from bumble.transport.hci_socket import open_hci_socket_transport
|
|
158
163
|
|
|
159
164
|
return await open_hci_socket_transport(spec)
|
|
160
165
|
|
|
161
166
|
if scheme == 'usb':
|
|
162
|
-
from .usb import open_usb_transport
|
|
167
|
+
from bumble.transport.usb import open_usb_transport
|
|
163
168
|
|
|
164
169
|
assert spec
|
|
165
170
|
return await open_usb_transport(spec)
|
|
166
171
|
|
|
167
172
|
if scheme == 'pyusb':
|
|
168
|
-
from .pyusb import open_pyusb_transport
|
|
173
|
+
from bumble.transport.pyusb import open_pyusb_transport
|
|
169
174
|
|
|
170
175
|
assert spec
|
|
171
176
|
return await open_pyusb_transport(spec)
|
|
172
177
|
|
|
173
178
|
if scheme == 'android-emulator':
|
|
174
|
-
from .android_emulator import open_android_emulator_transport
|
|
179
|
+
from bumble.transport.android_emulator import open_android_emulator_transport
|
|
175
180
|
|
|
176
181
|
return await open_android_emulator_transport(spec)
|
|
177
182
|
|
|
178
183
|
if scheme == 'android-netsim':
|
|
179
|
-
from .android_netsim import open_android_netsim_transport
|
|
184
|
+
from bumble.transport.android_netsim import open_android_netsim_transport
|
|
180
185
|
|
|
181
186
|
return await open_android_netsim_transport(spec)
|
|
182
187
|
|
|
183
188
|
if scheme == 'unix':
|
|
184
|
-
from .unix import open_unix_client_transport
|
|
189
|
+
from bumble.transport.unix import open_unix_client_transport
|
|
185
190
|
|
|
186
191
|
assert spec
|
|
187
192
|
return await open_unix_client_transport(spec)
|
|
@@ -204,8 +209,8 @@ async def open_transport_or_link(name: str) -> Transport:
|
|
|
204
209
|
"""
|
|
205
210
|
if name.startswith('link-relay:'):
|
|
206
211
|
logger.warning('Link Relay has been deprecated.')
|
|
207
|
-
from
|
|
208
|
-
from
|
|
212
|
+
from bumble.controller import Controller
|
|
213
|
+
from bumble.link import RemoteLink # lazy import
|
|
209
214
|
|
|
210
215
|
link = RemoteLink(name[11:])
|
|
211
216
|
await link.wait_until_connected()
|
|
@@ -20,7 +20,7 @@ import grpc.aio
|
|
|
20
20
|
|
|
21
21
|
from typing import Optional, Union
|
|
22
22
|
|
|
23
|
-
from .common import (
|
|
23
|
+
from bumble.transport.common import (
|
|
24
24
|
PumpedTransport,
|
|
25
25
|
PumpedPacketSource,
|
|
26
26
|
PumpedPacketSink,
|
|
@@ -29,9 +29,13 @@ from .common import (
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
# pylint: disable=no-name-in-module
|
|
32
|
-
from .grpc_protobuf.emulated_bluetooth_pb2_grpc import
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
from bumble.transport.grpc_protobuf.emulated_bluetooth_pb2_grpc import (
|
|
33
|
+
EmulatedBluetoothServiceStub,
|
|
34
|
+
)
|
|
35
|
+
from bumble.transport.grpc_protobuf.emulated_bluetooth_packets_pb2 import HCIPacket
|
|
36
|
+
from bumble.transport.grpc_protobuf.emulated_bluetooth_vhci_pb2_grpc import (
|
|
37
|
+
VhciForwardingServiceStub,
|
|
38
|
+
)
|
|
35
39
|
|
|
36
40
|
|
|
37
41
|
# -----------------------------------------------------------------------------
|
|
@@ -38,15 +38,18 @@ from bumble.transport.common import (
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
# pylint: disable=no-name-in-module
|
|
41
|
-
from .grpc_protobuf.netsim.packet_streamer_pb2_grpc import (
|
|
41
|
+
from bumble.transport.grpc_protobuf.netsim.packet_streamer_pb2_grpc import (
|
|
42
42
|
PacketStreamerStub,
|
|
43
43
|
PacketStreamerServicer,
|
|
44
44
|
add_PacketStreamerServicer_to_server,
|
|
45
45
|
)
|
|
46
|
-
from .grpc_protobuf.netsim.packet_streamer_pb2 import
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
from bumble.transport.grpc_protobuf.netsim.packet_streamer_pb2 import (
|
|
47
|
+
PacketRequest,
|
|
48
|
+
PacketResponse,
|
|
49
|
+
)
|
|
50
|
+
from bumble.transport.grpc_protobuf.netsim.hci_packet_pb2 import HCIPacket
|
|
51
|
+
from bumble.transport.grpc_protobuf.netsim.startup_pb2 import Chip, ChipInfo, DeviceInfo
|
|
52
|
+
from bumble.transport.grpc_protobuf.netsim.common_pb2 import ChipKind
|
|
50
53
|
|
|
51
54
|
|
|
52
55
|
# -----------------------------------------------------------------------------
|
bumble/transport/common.py
CHANGED
|
@@ -139,6 +139,7 @@ class PacketParser:
|
|
|
139
139
|
packet_type
|
|
140
140
|
) or self.extended_packet_info.get(packet_type)
|
|
141
141
|
if self.packet_info is None:
|
|
142
|
+
self.reset()
|
|
142
143
|
raise core.InvalidPacketError(
|
|
143
144
|
f'invalid packet type {packet_type}'
|
|
144
145
|
)
|
|
@@ -302,7 +303,10 @@ class ParserSource(BaseSource):
|
|
|
302
303
|
# -----------------------------------------------------------------------------
|
|
303
304
|
class StreamPacketSource(asyncio.Protocol, ParserSource):
|
|
304
305
|
def data_received(self, data: bytes) -> None:
|
|
305
|
-
|
|
306
|
+
try:
|
|
307
|
+
self.parser.feed_data(data)
|
|
308
|
+
except core.InvalidPacketError:
|
|
309
|
+
logger.warning("invalid packet, ignoring data")
|
|
306
310
|
|
|
307
311
|
|
|
308
312
|
# -----------------------------------------------------------------------------
|
bumble/transport/file.py
CHANGED
|
@@ -19,7 +19,7 @@ import asyncio
|
|
|
19
19
|
import io
|
|
20
20
|
import logging
|
|
21
21
|
|
|
22
|
-
from .common import Transport, StreamPacketSource, StreamPacketSink
|
|
22
|
+
from bumble.transport.common import Transport, StreamPacketSource, StreamPacketSink
|
|
23
23
|
|
|
24
24
|
# -----------------------------------------------------------------------------
|
|
25
25
|
# Logging
|
bumble/transport/hci_socket.py
CHANGED
bumble/transport/pty.py
CHANGED
|
@@ -25,7 +25,7 @@ import logging
|
|
|
25
25
|
|
|
26
26
|
from typing import Optional
|
|
27
27
|
|
|
28
|
-
from .common import Transport, StreamPacketSource, StreamPacketSink
|
|
28
|
+
from bumble.transport.common import Transport, StreamPacketSource, StreamPacketSink
|
|
29
29
|
|
|
30
30
|
# -----------------------------------------------------------------------------
|
|
31
31
|
# Logging
|
bumble/transport/pyusb.py
CHANGED
|
@@ -29,9 +29,9 @@ from usb.core import USBError
|
|
|
29
29
|
from usb.util import CTRL_TYPE_CLASS, CTRL_RECIPIENT_OTHER
|
|
30
30
|
from usb.legacy import REQ_SET_FEATURE, REQ_CLEAR_FEATURE, CLASS_HUB
|
|
31
31
|
|
|
32
|
-
from .common import Transport, ParserSource, TransportInitError
|
|
33
|
-
from
|
|
34
|
-
from
|
|
32
|
+
from bumble.transport.common import Transport, ParserSource, TransportInitError
|
|
33
|
+
from bumble import hci
|
|
34
|
+
from bumble.colors import color
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
# -----------------------------------------------------------------------------
|
bumble/transport/serial.py
CHANGED
|
@@ -19,7 +19,7 @@ import asyncio
|
|
|
19
19
|
import logging
|
|
20
20
|
import serial_asyncio
|
|
21
21
|
|
|
22
|
-
from .common import Transport, StreamPacketSource, StreamPacketSink
|
|
22
|
+
from bumble.transport.common import Transport, StreamPacketSource, StreamPacketSink
|
|
23
23
|
|
|
24
24
|
# -----------------------------------------------------------------------------
|
|
25
25
|
# Logging
|
bumble/transport/tcp_client.py
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import asyncio
|
|
19
19
|
import logging
|
|
20
20
|
|
|
21
|
-
from .common import Transport, StreamPacketSource, StreamPacketSink
|
|
21
|
+
from bumble.transport.common import Transport, StreamPacketSource, StreamPacketSink
|
|
22
22
|
|
|
23
23
|
# -----------------------------------------------------------------------------
|
|
24
24
|
# Logging
|
bumble/transport/tcp_server.py
CHANGED
|
@@ -20,7 +20,7 @@ import asyncio
|
|
|
20
20
|
import logging
|
|
21
21
|
import socket
|
|
22
22
|
|
|
23
|
-
from .common import Transport, StreamPacketSource
|
|
23
|
+
from bumble.transport.common import Transport, StreamPacketSource
|
|
24
24
|
|
|
25
25
|
# -----------------------------------------------------------------------------
|
|
26
26
|
# Logging
|
bumble/transport/udp.py
CHANGED
bumble/transport/unix.py
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import asyncio
|
|
19
19
|
import logging
|
|
20
20
|
|
|
21
|
-
from .common import Transport, StreamPacketSource, StreamPacketSink
|
|
21
|
+
from bumble.transport.common import Transport, StreamPacketSource, StreamPacketSink
|
|
22
22
|
|
|
23
23
|
# -----------------------------------------------------------------------------
|
|
24
24
|
# Logging
|
bumble/transport/usb.py
CHANGED
|
@@ -115,9 +115,7 @@ async def open_usb_transport(spec: str) -> Transport:
|
|
|
115
115
|
self.acl_out = acl_out
|
|
116
116
|
self.acl_out_transfer = device.getTransfer()
|
|
117
117
|
self.acl_out_transfer_ready = asyncio.Semaphore(1)
|
|
118
|
-
self.packets
|
|
119
|
-
asyncio.Queue()
|
|
120
|
-
) # Queue of packets waiting to be sent
|
|
118
|
+
self.packets = asyncio.Queue[bytes]() # Queue of packets waiting to be sent
|
|
121
119
|
self.loop = asyncio.get_running_loop()
|
|
122
120
|
self.queue_task = None
|
|
123
121
|
self.cancel_done = self.loop.create_future()
|
bumble/transport/vhci.py
CHANGED
|
@@ -19,8 +19,8 @@ import logging
|
|
|
19
19
|
|
|
20
20
|
from typing import Optional
|
|
21
21
|
|
|
22
|
-
from .common import Transport
|
|
23
|
-
from .file import open_file_transport
|
|
22
|
+
from bumble.transport.common import Transport
|
|
23
|
+
from bumble.transport.file import open_file_transport
|
|
24
24
|
|
|
25
25
|
# -----------------------------------------------------------------------------
|
|
26
26
|
# Logging
|
bumble/transport/ws_client.py
CHANGED
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
import logging
|
|
19
19
|
import websockets.client
|
|
20
20
|
|
|
21
|
-
from .common import
|
|
21
|
+
from bumble.transport.common import (
|
|
22
|
+
PumpedPacketSource,
|
|
23
|
+
PumpedPacketSink,
|
|
24
|
+
PumpedTransport,
|
|
25
|
+
Transport,
|
|
26
|
+
)
|
|
22
27
|
|
|
23
28
|
# -----------------------------------------------------------------------------
|
|
24
29
|
# Logging
|
bumble/transport/ws_server.py
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import logging
|
|
19
19
|
import websockets
|
|
20
20
|
|
|
21
|
-
from .common import Transport, ParserSource, PumpedPacketSink
|
|
21
|
+
from bumble.transport.common import Transport, ParserSource, PumpedPacketSink
|
|
22
22
|
|
|
23
23
|
# -----------------------------------------------------------------------------
|
|
24
24
|
# Logging
|
bumble/utils.py
CHANGED
|
@@ -38,9 +38,10 @@ from typing import (
|
|
|
38
38
|
)
|
|
39
39
|
from typing_extensions import Self
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
import pyee
|
|
42
|
+
import pyee.asyncio
|
|
42
43
|
|
|
43
|
-
from .colors import color
|
|
44
|
+
from bumble.colors import color
|
|
44
45
|
|
|
45
46
|
# -----------------------------------------------------------------------------
|
|
46
47
|
# Logging
|
|
@@ -56,6 +57,48 @@ def setup_event_forwarding(emitter, forwarder, event_name):
|
|
|
56
57
|
emitter.on(event_name, emit)
|
|
57
58
|
|
|
58
59
|
|
|
60
|
+
# -----------------------------------------------------------------------------
|
|
61
|
+
def wrap_async(function):
|
|
62
|
+
"""
|
|
63
|
+
Wraps the provided function in an async function.
|
|
64
|
+
"""
|
|
65
|
+
return functools.partial(async_call, function)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# -----------------------------------------------------------------------------
|
|
69
|
+
def deprecated(msg: str):
|
|
70
|
+
"""
|
|
71
|
+
Throw deprecation warning before execution.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def wrapper(function):
|
|
75
|
+
@functools.wraps(function)
|
|
76
|
+
def inner(*args, **kwargs):
|
|
77
|
+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
|
78
|
+
return function(*args, **kwargs)
|
|
79
|
+
|
|
80
|
+
return inner
|
|
81
|
+
|
|
82
|
+
return wrapper
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# -----------------------------------------------------------------------------
|
|
86
|
+
def experimental(msg: str):
|
|
87
|
+
"""
|
|
88
|
+
Throws a future warning before execution.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
def wrapper(function):
|
|
92
|
+
@functools.wraps(function)
|
|
93
|
+
def inner(*args, **kwargs):
|
|
94
|
+
warnings.warn(msg, FutureWarning, stacklevel=2)
|
|
95
|
+
return function(*args, **kwargs)
|
|
96
|
+
|
|
97
|
+
return inner
|
|
98
|
+
|
|
99
|
+
return wrapper
|
|
100
|
+
|
|
101
|
+
|
|
59
102
|
# -----------------------------------------------------------------------------
|
|
60
103
|
def composite_listener(cls):
|
|
61
104
|
"""
|
|
@@ -113,21 +156,23 @@ class EventWatcher:
|
|
|
113
156
|
```
|
|
114
157
|
'''
|
|
115
158
|
|
|
116
|
-
handlers: List[Tuple[EventEmitter, str, Callable[..., Any]]]
|
|
159
|
+
handlers: List[Tuple[pyee.EventEmitter, str, Callable[..., Any]]]
|
|
117
160
|
|
|
118
161
|
def __init__(self) -> None:
|
|
119
162
|
self.handlers = []
|
|
120
163
|
|
|
121
164
|
@overload
|
|
122
165
|
def on(
|
|
123
|
-
self, emitter: EventEmitter, event: str
|
|
166
|
+
self, emitter: pyee.EventEmitter, event: str
|
|
124
167
|
) -> Callable[[_Handler], _Handler]: ...
|
|
125
168
|
|
|
126
169
|
@overload
|
|
127
|
-
def on(
|
|
170
|
+
def on(
|
|
171
|
+
self, emitter: pyee.EventEmitter, event: str, handler: _Handler
|
|
172
|
+
) -> _Handler: ...
|
|
128
173
|
|
|
129
174
|
def on(
|
|
130
|
-
self, emitter: EventEmitter, event: str, handler: Optional[_Handler] = None
|
|
175
|
+
self, emitter: pyee.EventEmitter, event: str, handler: Optional[_Handler] = None
|
|
131
176
|
) -> Union[_Handler, Callable[[_Handler], _Handler]]:
|
|
132
177
|
'''Watch an event until the context is closed.
|
|
133
178
|
|
|
@@ -147,16 +192,16 @@ class EventWatcher:
|
|
|
147
192
|
|
|
148
193
|
@overload
|
|
149
194
|
def once(
|
|
150
|
-
self, emitter: EventEmitter, event: str
|
|
195
|
+
self, emitter: pyee.EventEmitter, event: str
|
|
151
196
|
) -> Callable[[_Handler], _Handler]: ...
|
|
152
197
|
|
|
153
198
|
@overload
|
|
154
199
|
def once(
|
|
155
|
-
self, emitter: EventEmitter, event: str, handler: _Handler
|
|
200
|
+
self, emitter: pyee.EventEmitter, event: str, handler: _Handler
|
|
156
201
|
) -> _Handler: ...
|
|
157
202
|
|
|
158
203
|
def once(
|
|
159
|
-
self, emitter: EventEmitter, event: str, handler: Optional[_Handler] = None
|
|
204
|
+
self, emitter: pyee.EventEmitter, event: str, handler: Optional[_Handler] = None
|
|
160
205
|
) -> Union[_Handler, Callable[[_Handler], _Handler]]:
|
|
161
206
|
'''Watch an event for once.
|
|
162
207
|
|
|
@@ -184,38 +229,48 @@ class EventWatcher:
|
|
|
184
229
|
_T = TypeVar('_T')
|
|
185
230
|
|
|
186
231
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
232
|
+
def cancel_on_event(
|
|
233
|
+
emitter: pyee.EventEmitter, event: str, awaitable: Awaitable[_T]
|
|
234
|
+
) -> Awaitable[_T]:
|
|
235
|
+
"""Set a coroutine or future to cancel when an event occur."""
|
|
236
|
+
future = asyncio.ensure_future(awaitable)
|
|
237
|
+
if future.done():
|
|
238
|
+
return future
|
|
239
|
+
|
|
240
|
+
def on_event(*args, **kwargs) -> None:
|
|
241
|
+
del args, kwargs
|
|
193
242
|
if future.done():
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if isinstance(future, asyncio.Task):
|
|
201
|
-
# python < 3.9 does not support passing a message on `Task.cancel`
|
|
202
|
-
if sys.version_info < (3, 9, 0):
|
|
203
|
-
future.cancel()
|
|
204
|
-
else:
|
|
205
|
-
future.cancel(msg)
|
|
243
|
+
return
|
|
244
|
+
msg = f'abort: {event} event occurred.'
|
|
245
|
+
if isinstance(future, asyncio.Task):
|
|
246
|
+
# python < 3.9 does not support passing a message on `Task.cancel`
|
|
247
|
+
if sys.version_info < (3, 9, 0):
|
|
248
|
+
future.cancel()
|
|
206
249
|
else:
|
|
207
|
-
future.
|
|
250
|
+
future.cancel(msg)
|
|
251
|
+
else:
|
|
252
|
+
future.set_exception(asyncio.CancelledError(msg))
|
|
208
253
|
|
|
209
|
-
|
|
210
|
-
|
|
254
|
+
def on_done(_):
|
|
255
|
+
emitter.remove_listener(event, on_event)
|
|
211
256
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
257
|
+
emitter.on(event, on_event)
|
|
258
|
+
future.add_done_callback(on_done)
|
|
259
|
+
return future
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
# -----------------------------------------------------------------------------
|
|
263
|
+
class EventEmitter(pyee.asyncio.AsyncIOEventEmitter):
|
|
264
|
+
"""A Base EventEmitter for Bumble."""
|
|
265
|
+
|
|
266
|
+
@deprecated("Use `cancel_on_event` instead.")
|
|
267
|
+
def abort_on(self, event: str, awaitable: Awaitable[_T]) -> Awaitable[_T]:
|
|
268
|
+
"""Set a coroutine or future to abort when an event occur."""
|
|
269
|
+
return cancel_on_event(self, event, awaitable)
|
|
215
270
|
|
|
216
271
|
|
|
217
272
|
# -----------------------------------------------------------------------------
|
|
218
|
-
class CompositeEventEmitter(
|
|
273
|
+
class CompositeEventEmitter(EventEmitter):
|
|
219
274
|
def __init__(self):
|
|
220
275
|
super().__init__()
|
|
221
276
|
self._listener = None
|
|
@@ -430,48 +485,6 @@ async def async_call(function, *args, **kwargs):
|
|
|
430
485
|
return function(*args, **kwargs)
|
|
431
486
|
|
|
432
487
|
|
|
433
|
-
# -----------------------------------------------------------------------------
|
|
434
|
-
def wrap_async(function):
|
|
435
|
-
"""
|
|
436
|
-
Wraps the provided function in an async function.
|
|
437
|
-
"""
|
|
438
|
-
return functools.partial(async_call, function)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
# -----------------------------------------------------------------------------
|
|
442
|
-
def deprecated(msg: str):
|
|
443
|
-
"""
|
|
444
|
-
Throw deprecation warning before execution.
|
|
445
|
-
"""
|
|
446
|
-
|
|
447
|
-
def wrapper(function):
|
|
448
|
-
@functools.wraps(function)
|
|
449
|
-
def inner(*args, **kwargs):
|
|
450
|
-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
|
451
|
-
return function(*args, **kwargs)
|
|
452
|
-
|
|
453
|
-
return inner
|
|
454
|
-
|
|
455
|
-
return wrapper
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
# -----------------------------------------------------------------------------
|
|
459
|
-
def experimental(msg: str):
|
|
460
|
-
"""
|
|
461
|
-
Throws a future warning before execution.
|
|
462
|
-
"""
|
|
463
|
-
|
|
464
|
-
def wrapper(function):
|
|
465
|
-
@functools.wraps(function)
|
|
466
|
-
def inner(*args, **kwargs):
|
|
467
|
-
warnings.warn(msg, FutureWarning, stacklevel=2)
|
|
468
|
-
return function(*args, **kwargs)
|
|
469
|
-
|
|
470
|
-
return inner
|
|
471
|
-
|
|
472
|
-
return wrapper
|
|
473
|
-
|
|
474
|
-
|
|
475
488
|
# -----------------------------------------------------------------------------
|
|
476
489
|
class OpenIntEnum(enum.IntEnum):
|
|
477
490
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: bumble
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.210
|
|
4
4
|
Summary: Bluetooth Stack for Apps, Emulation, Test and Experimentation
|
|
5
5
|
Author-email: Google <bumble-dev@google.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/google/bumble
|
|
@@ -57,6 +57,7 @@ Requires-Dist: mkdocstrings[python]>=0.27.0; extra == "documentation"
|
|
|
57
57
|
Provides-Extra: auracast
|
|
58
58
|
Requires-Dist: lc3py>=1.1.3; (python_version >= "3.10" and ((platform_system == "Linux" and platform_machine == "x86_64") or (platform_system == "Darwin" and platform_machine == "arm64"))) and extra == "auracast"
|
|
59
59
|
Requires-Dist: sounddevice>=0.5.1; extra == "auracast"
|
|
60
|
+
Dynamic: license-file
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
_ _ _
|