mirror of
https://github.com/google/bumble.git
synced 2026-05-09 04:08:02 +00:00
le: make the device connecting state relative to LE only
We may need to add a distinct BR/EDR connecting state in the future.
This commit is contained in:
@@ -311,7 +311,7 @@ class ConsoleApp:
|
|||||||
rssi = '' if self.connection_rssi is None else rssi_bar(self.connection_rssi)
|
rssi = '' if self.connection_rssi is None else rssi_bar(self.connection_rssi)
|
||||||
|
|
||||||
if self.device:
|
if self.device:
|
||||||
if self.device.is_connecting:
|
if self.device.is_le_connecting:
|
||||||
connection_state = 'CONNECTING'
|
connection_state = 'CONNECTING'
|
||||||
elif self.connected_peer:
|
elif self.connected_peer:
|
||||||
connection = self.connected_peer.connection
|
connection = self.connected_peer.connection
|
||||||
@@ -574,7 +574,7 @@ class ConsoleApp:
|
|||||||
self.show_error('connection timed out')
|
self.show_error('connection timed out')
|
||||||
|
|
||||||
async def do_disconnect(self, params):
|
async def do_disconnect(self, params):
|
||||||
if self.device.connecting:
|
if self.device.is_le_connecting:
|
||||||
await self.device.cancel_connection()
|
await self.device.cancel_connection()
|
||||||
else:
|
else:
|
||||||
if not self.connected_peer:
|
if not self.connected_peer:
|
||||||
|
|||||||
@@ -674,7 +674,7 @@ class Device(CompositeEventEmitter):
|
|||||||
self.scanning = False
|
self.scanning = False
|
||||||
self.scanning_is_passive = False
|
self.scanning_is_passive = False
|
||||||
self.discovering = False
|
self.discovering = False
|
||||||
self.connecting = False
|
self.le_connecting = False
|
||||||
self.disconnecting = False
|
self.disconnecting = False
|
||||||
self.connections = {} # Connections, by connection handle
|
self.connections = {} # Connections, by connection handle
|
||||||
self.classic_enabled = False
|
self.classic_enabled = False
|
||||||
@@ -1160,7 +1160,7 @@ class Device(CompositeEventEmitter):
|
|||||||
transport = BT_LE_TRANSPORT
|
transport = BT_LE_TRANSPORT
|
||||||
|
|
||||||
# Check that there isn't already a pending connection
|
# Check that there isn't already a pending connection
|
||||||
if transport == BT_LE_TRANSPORT and self.is_connecting:
|
if transport == BT_LE_TRANSPORT and self.is_le_connecting:
|
||||||
raise InvalidStateError('connection already pending')
|
raise InvalidStateError('connection already pending')
|
||||||
|
|
||||||
if type(peer_address) is str:
|
if type(peer_address) is str:
|
||||||
@@ -1277,7 +1277,7 @@ class Device(CompositeEventEmitter):
|
|||||||
|
|
||||||
# Wait for the connection process to complete
|
# Wait for the connection process to complete
|
||||||
if transport == BT_LE_TRANSPORT:
|
if transport == BT_LE_TRANSPORT:
|
||||||
self.connecting = True
|
self.le_connecting = True
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
return await pending_connection
|
return await pending_connection
|
||||||
else:
|
else:
|
||||||
@@ -1297,7 +1297,7 @@ class Device(CompositeEventEmitter):
|
|||||||
self.remove_listener('connection', on_connection)
|
self.remove_listener('connection', on_connection)
|
||||||
self.remove_listener('connection_failure', on_connection_failure)
|
self.remove_listener('connection_failure', on_connection_failure)
|
||||||
if transport == BT_LE_TRANSPORT:
|
if transport == BT_LE_TRANSPORT:
|
||||||
self.connecting = False
|
self.le_connecting = False
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def connect_as_gatt(self, peer_address):
|
async def connect_as_gatt(self, peer_address):
|
||||||
@@ -1308,15 +1308,15 @@ class Device(CompositeEventEmitter):
|
|||||||
yield peer
|
yield peer
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connecting(self):
|
def is_le_connecting(self):
|
||||||
return self.connecting
|
return self.le_connecting
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_disconnecting(self):
|
def is_disconnecting(self):
|
||||||
return self.disconnecting
|
return self.disconnecting
|
||||||
|
|
||||||
async def cancel_connection(self):
|
async def cancel_connection(self):
|
||||||
if not self.is_connecting:
|
if not self.is_le_connecting:
|
||||||
return
|
return
|
||||||
await self.send_command(HCI_LE_Create_Connection_Cancel_Command(), check_result=True)
|
await self.send_command(HCI_LE_Create_Connection_Cancel_Command(), check_result=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user