mirror of
https://github.com/google/bumble.git
synced 2026-06-01 07:37:02 +00:00
classic: update ConnectionError to take transport and peer address
This commit is contained in:
@@ -100,6 +100,11 @@ class ConnectionError(BaseError):
|
||||
FAILURE = 0x01
|
||||
CONNECTION_REFUSED = 0x02
|
||||
|
||||
def __init__(self, error_code, transport, peer_address, error_namespace='', error_name='', details=''):
|
||||
self.transport = transport
|
||||
self.peer_address = peer_address
|
||||
super().__init__(error_code, error_namespace, error_name, details)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# UUID
|
||||
|
||||
+4
-3
@@ -1728,12 +1728,11 @@ class Device(CompositeEventEmitter):
|
||||
# Notify listeners
|
||||
error = ConnectionError(
|
||||
error_code,
|
||||
transport,
|
||||
peer_address,
|
||||
'hci',
|
||||
HCI_Constant.error_name(error_code)
|
||||
)
|
||||
error.transport = transport
|
||||
error.connection_handle = connection_handle # FIXME: Connection handle sounds to be a dummy value here
|
||||
error.peer_address = peer_address
|
||||
self.emit('connection_failure', error)
|
||||
|
||||
@host_event_handler
|
||||
@@ -1762,6 +1761,8 @@ class Device(CompositeEventEmitter):
|
||||
logger.debug(f'*** Disconnection failed: {error_code}')
|
||||
error = ConnectionError(
|
||||
error_code,
|
||||
connection.transport,
|
||||
connection.peer_address,
|
||||
'hci',
|
||||
HCI_Constant.error_name(error_code)
|
||||
)
|
||||
|
||||
+2
-2
@@ -383,7 +383,7 @@ class Host(EventEmitter):
|
||||
logger.debug(f'### CONNECTION FAILED: {event.status}')
|
||||
|
||||
# Notify the listeners
|
||||
self.emit('connection_failure', BT_LE_TRANSPORT, event.connection_handle, event.peer_address, event.status)
|
||||
self.emit('connection_failure', BT_LE_TRANSPORT, event.peer_address, event.status)
|
||||
|
||||
def on_hci_le_enhanced_connection_complete_event(self, event):
|
||||
# Just use the same implementation as for the non-enhanced event for now
|
||||
@@ -413,7 +413,7 @@ class Host(EventEmitter):
|
||||
logger.debug(f'### BR/EDR CONNECTION FAILED: {event.status}')
|
||||
|
||||
# Notify the client
|
||||
self.emit('connection_failure', BT_BR_EDR_TRANSPORT, event.connection_handle, event.bd_addr, event.status)
|
||||
self.emit('connection_failure', BT_BR_EDR_TRANSPORT, event.bd_addr, event.status)
|
||||
|
||||
def on_hci_disconnection_complete_event(self, event):
|
||||
# Find the connection
|
||||
|
||||
+7
-2
@@ -21,7 +21,7 @@ import asyncio
|
||||
from colors import color
|
||||
from pyee import EventEmitter
|
||||
|
||||
from .core import InvalidStateError, ProtocolError, ConnectionError
|
||||
from .core import BT_BR_EDR_TRANSPORT, InvalidStateError, ProtocolError, ConnectionError
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Logging
|
||||
@@ -634,7 +634,12 @@ class Multiplexer(EventEmitter):
|
||||
if self.state == Multiplexer.OPENING:
|
||||
self.change_state(Multiplexer.CONNECTED)
|
||||
if self.open_result:
|
||||
self.open_result.set_exception(ConnectionError(ConnectionError.CONNECTION_REFUSED))
|
||||
self.open_result.set_exception(ConnectionError(
|
||||
ConnectionError.CONNECTION_REFUSED,
|
||||
self.l2cap_channel.connection.peer_address,
|
||||
BT_BR_EDR_TRANSPORT,
|
||||
'rfcomm'
|
||||
))
|
||||
else:
|
||||
logger.warn(f'unexpected state for DM: {self}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user