99from typing import Optional
1010
1111from bleak import BleakClient , BleakScanner , BLEDevice
12- from print_color import print
12+ import print_color
1313
1414from meshtastic .mesh_interface import MeshInterface
15- from meshtastic .util import our_exit
1615
1716SERVICE_UUID = "6ba1b218-15a8-461f-9fa8-5dcae273eafd"
1817TORADIO_UUID = "f75c76d2-129e-4dad-a1dd-7866124401e7"
@@ -27,8 +26,6 @@ class BLEInterface(MeshInterface):
2726 class BLEError (Exception ):
2827 """An exception class for BLE errors."""
2928
30- pass
31-
3229 def __init__ (
3330 self ,
3431 address : Optional [str ],
@@ -85,15 +82,15 @@ def from_num_handler(self, _, b): # pylint: disable=C0116
8582 async def log_radio_handler (self , _ , b ): # pylint: disable=C0116
8683 log_radio = b .decode ("utf-8" ).replace ("\n " , "" )
8784 if log_radio .startswith ("DEBUG" ):
88- print (log_radio , color = "cyan" , end = None )
85+ print_color . print (log_radio , color = "cyan" , end = None )
8986 elif log_radio .startswith ("INFO" ):
90- print (log_radio , color = "white" , end = None )
87+ print_color . print (log_radio , color = "white" , end = None )
9188 elif log_radio .startswith ("WARN" ):
92- print (log_radio , color = "yellow" , end = None )
89+ print_color . print (log_radio , color = "yellow" , end = None )
9390 elif log_radio .startswith ("ERROR" ):
94- print (log_radio , color = "red" , end = None )
91+ print_color . print (log_radio , color = "red" , end = None )
9592 else :
96- print (log_radio , end = None )
93+ print_color . print (log_radio , end = None )
9794
9895 @staticmethod
9996 def scan () -> list [BLEDevice ]:
@@ -122,7 +119,7 @@ def find_device(self, address: Optional[str]) -> BLEDevice:
122119 if address :
123120 addressed_devices = list (
124121 filter (
125- lambda x : address == x .name or address == x .address ,
122+ lambda x : address in ( x .name , x .address ) ,
126123 addressed_devices ,
127124 )
128125 )
0 commit comments