mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
enable error_only logging
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "1.9.16"
|
version = "1.9.17"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class MeshCore:
|
|||||||
"""
|
"""
|
||||||
Interface to a MeshCore device
|
Interface to a MeshCore device
|
||||||
"""
|
"""
|
||||||
def __init__(self, cx, debug=False, default_timeout=None, auto_reconnect=False, max_reconnect_attempts=3):
|
def __init__(self, cx, debug=False, only_error=False, default_timeout=None, auto_reconnect=False, max_reconnect_attempts=3):
|
||||||
# Wrap connection with ConnectionManager
|
# Wrap connection with ConnectionManager
|
||||||
self.dispatcher = EventDispatcher()
|
self.dispatcher = EventDispatcher()
|
||||||
self.connection_manager = ConnectionManager(
|
self.connection_manager = ConnectionManager(
|
||||||
@@ -31,6 +31,8 @@ class MeshCore:
|
|||||||
# Set up logger
|
# Set up logger
|
||||||
if debug:
|
if debug:
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
elif only_error:
|
||||||
|
logger.setLevel(logging.ERROR)
|
||||||
else:
|
else:
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
@@ -59,29 +61,29 @@ class MeshCore:
|
|||||||
cx.set_disconnect_callback(self.connection_manager.handle_disconnect)
|
cx.set_disconnect_callback(self.connection_manager.handle_disconnect)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def create_tcp(cls, host: str, port: int, debug: bool = False, default_timeout=None,
|
async def create_tcp(cls, host: str, port: int, debug: bool = False, only_error:bool = False, default_timeout=None,
|
||||||
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
|
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
|
||||||
"""Create and connect a MeshCore instance using TCP connection"""
|
"""Create and connect a MeshCore instance using TCP connection"""
|
||||||
connection = TCPConnection(host, port)
|
connection = TCPConnection(host, port)
|
||||||
|
|
||||||
mc = cls(connection, debug=debug, default_timeout=default_timeout,
|
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
|
||||||
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
||||||
await mc.connect()
|
await mc.connect()
|
||||||
return mc
|
return mc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def create_serial(cls, port: str, baudrate: int = 115200, debug: bool = False, default_timeout=None,
|
async def create_serial(cls, port: str, baudrate: int = 115200, debug: bool = False, only_error:bool=False, default_timeout=None,
|
||||||
auto_reconnect: bool = False, max_reconnect_attempts: int = 3, cx_dly:float = 0.1) -> 'MeshCore':
|
auto_reconnect: bool = False, max_reconnect_attempts: int = 3, cx_dly:float = 0.1) -> 'MeshCore':
|
||||||
"""Create and connect a MeshCore instance using serial connection"""
|
"""Create and connect a MeshCore instance using serial connection"""
|
||||||
connection = SerialConnection(port, baudrate, cx_dly=cx_dly)
|
connection = SerialConnection(port, baudrate, cx_dly=cx_dly)
|
||||||
|
|
||||||
mc = cls(connection, debug=debug, default_timeout=default_timeout,
|
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
|
||||||
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
||||||
await mc.connect()
|
await mc.connect()
|
||||||
return mc
|
return mc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def create_ble(cls, address: Optional[str] = None, debug: bool = False, default_timeout=None,
|
async def create_ble(cls, address: Optional[str] = None, debug: bool = False, only_error:bool=False, default_timeout=None,
|
||||||
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
|
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
|
||||||
"""Create and connect a MeshCore instance using BLE connection
|
"""Create and connect a MeshCore instance using BLE connection
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ class MeshCore:
|
|||||||
|
|
||||||
connection = BLEConnection(address)
|
connection = BLEConnection(address)
|
||||||
|
|
||||||
mc = cls(connection, debug=debug, default_timeout=default_timeout,
|
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
|
||||||
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
|
||||||
await mc.connect()
|
await mc.connect()
|
||||||
return mc
|
return mc
|
||||||
|
|||||||
Reference in New Issue
Block a user