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:
Abel Lucas
2022-10-19 17:25:05 +00:00
parent b961affd3d
commit e9e14f5183
2 changed files with 9 additions and 9 deletions

View File

@@ -311,7 +311,7 @@ class ConsoleApp:
rssi = '' if self.connection_rssi is None else rssi_bar(self.connection_rssi)
if self.device:
if self.device.is_connecting:
if self.device.is_le_connecting:
connection_state = 'CONNECTING'
elif self.connected_peer:
connection = self.connected_peer.connection
@@ -574,7 +574,7 @@ class ConsoleApp:
self.show_error('connection timed out')
async def do_disconnect(self, params):
if self.device.connecting:
if self.device.is_le_connecting:
await self.device.cancel_connection()
else:
if not self.connected_peer:

View File

@@ -674,7 +674,7 @@ class Device(CompositeEventEmitter):
self.scanning = False
self.scanning_is_passive = False
self.discovering = False
self.connecting = False
self.le_connecting = False
self.disconnecting = False
self.connections = {} # Connections, by connection handle
self.classic_enabled = False
@@ -1160,7 +1160,7 @@ class Device(CompositeEventEmitter):
transport = BT_LE_TRANSPORT
# 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')
if type(peer_address) is str:
@@ -1277,7 +1277,7 @@ class Device(CompositeEventEmitter):
# Wait for the connection process to complete
if transport == BT_LE_TRANSPORT:
self.connecting = True
self.le_connecting = True
if timeout is None:
return await pending_connection
else:
@@ -1297,7 +1297,7 @@ class Device(CompositeEventEmitter):
self.remove_listener('connection', on_connection)
self.remove_listener('connection_failure', on_connection_failure)
if transport == BT_LE_TRANSPORT:
self.connecting = False
self.le_connecting = False
@asynccontextmanager
async def connect_as_gatt(self, peer_address):
@@ -1308,15 +1308,15 @@ class Device(CompositeEventEmitter):
yield peer
@property
def is_connecting(self):
return self.connecting
def is_le_connecting(self):
return self.le_connecting
@property
def is_disconnecting(self):
return self.disconnecting
async def cancel_connection(self):
if not self.is_connecting:
if not self.is_le_connecting:
return
await self.send_command(HCI_LE_Create_Connection_Cancel_Command(), check_result=True)