continue progressively typing things (SerialInterface/BLEInterface initializations)

This commit is contained in:
Ian McEwen
2024-05-11 22:27:31 -07:00
parent fef0e1b77f
commit ba2d6c9d93
3 changed files with 10 additions and 6 deletions

View File

@@ -7,6 +7,8 @@ import asyncio
from threading import Thread, Event
from bleak import BleakScanner, BleakClient
from typing import Optional
from meshtastic.mesh_interface import MeshInterface
from meshtastic.util import our_exit
@@ -30,7 +32,7 @@ class BLEInterface(MeshInterface):
MESH = False
def __init__(self, address, noProto = False, debugOut = None):
def __init__(self, address: Optional[str], noProto: bool = False, debugOut = None):
self.state = BLEInterface.BLEState()
if not address:

View File

@@ -6,6 +6,8 @@ import time
import serial # type: ignore[import-untyped]
from typing import Optional
import meshtastic.util
from meshtastic.stream_interface import StreamInterface
@@ -16,7 +18,7 @@ if platform.system() != "Windows":
class SerialInterface(StreamInterface):
"""Interface class for meshtastic devices over a serial link"""
def __init__(self, devPath=None, debugOut=None, noProto=False, connectNow=True):
def __init__(self, devPath: Optional[str]=None, debugOut=None, noProto=False, connectNow=True):
"""Constructor, opens a connection to a specified serial port, or if unspecified try to
find one Meshtastic device by probing
@@ -26,7 +28,7 @@ class SerialInterface(StreamInterface):
"""
self.noProto = noProto
self.devPath = devPath
self.devPath: Optional[str] = devPath
if self.devPath is None:
ports = meshtastic.util.findPorts(True)

View File

@@ -11,7 +11,7 @@ import threading
import time
import traceback
from queue import Queue
from typing import Union
from typing import List, NoReturn, Union
from google.protobuf.json_format import MessageToJson
@@ -122,7 +122,7 @@ def catchAndIgnore(reason, closure):
logging.error(f"Exception thrown in {reason}: {ex}")
def findPorts(eliminate_duplicates=False):
def findPorts(eliminate_duplicates: bool=False) -> List[str]:
"""Find all ports that might have meshtastic devices
eliminate_duplicates will run the eliminate_duplicate_port() on the collection
@@ -263,7 +263,7 @@ class DeferredExecution:
print(traceback.format_exc())
def our_exit(message, return_value=1):
def our_exit(message, return_value=1) -> NoReturn:
"""Print the message and return a value.
return_value defaults to 1 (non-successful)
"""