From 3ab6ebce809ddbb9d8b571c17977a1421a221a7c Mon Sep 17 00:00:00 2001 From: Xlin123 Date: Thu, 2 May 2024 17:17:47 -0400 Subject: [PATCH] fix: fixed regex missing from heartbeat method --- at_client/atclient.py | 6 +++--- at_client/connections/atmonitorconnection.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/at_client/atclient.py b/at_client/atclient.py index d2c6b38..810f354 100644 --- a/at_client/atclient.py +++ b/at_client/atclient.py @@ -343,21 +343,21 @@ def __del__(self): if self.secondary_connection: self.secondary_connection.disconnect() - def start_monitor(self, regex=""): + def start_monitor(self, regex=".*"): if self.queue != None: global should_be_running_lock what = "" try: if self.monitor_connection == None: what = "construct an AtMonitorConnection" - self.monitor_connection = AtMonitorConnection(queue=self.queue, atsign=self.atsign, address=self.secondary_address, verbose=self.verbose) + self.monitor_connection = AtMonitorConnection(queue=self.queue, atsign=self.atsign, address=self.secondary_address, verbose=self.verbose, regex=regex) self.monitor_connection.connect() AuthUtil.authenticate_with_pkam(self.monitor_connection, self.atsign, self.keys) should_be_running_lock.acquire(blocking=1) if not self.monitor_connection.running: should_be_running_lock.release() what = "call monitor_connection.start_monitor()" - self.monitor_connection.start_monitor(regex) + self.monitor_connection.start_monitor() else: should_be_running_lock.release() except Exception as e: diff --git a/at_client/connections/atmonitorconnection.py b/at_client/connections/atmonitorconnection.py index 49385a5..4befdc9 100644 --- a/at_client/connections/atmonitorconnection.py +++ b/at_client/connections/atmonitorconnection.py @@ -19,9 +19,10 @@ class AtMonitorConnection(AtSecondaryConnection): running: bool = False should_be_running: bool = False - def __init__(self, queue:queue.Queue, atsign:AtSign, address: Address, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=True): + def __init__(self, queue:queue.Queue, atsign:AtSign, address: Address, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=True, regex=".*"): self.atsign = atsign self.queue = queue + self.regex = regex self._verbose = verbose super().__init__(address, context, verbose) self._last_heartbeat_sent_time = TimeUtil.current_time_millis() @@ -79,7 +80,7 @@ def _start_heart_beat(self): except Exception as ignore: pass - def start_monitor(self, regex): + def start_monitor(self): self._last_heartbeat_sent_time = self._last_heartbeat_ack_time = TimeUtil.current_time_millis() should_be_running_lock.acquire(blocking=1) @@ -100,7 +101,7 @@ def start_monitor(self, regex): self.running = False running_lock.release() return False - self._run(regex) + self._run() else: running_lock.release() return True @@ -113,11 +114,11 @@ def stop_monitor(self): self._last_heartbeat_sent_time = self._last_heartbeat_ack_time = TimeUtil.current_time_millis() self.disconnect() - def _run(self, regex): + def _run(self): what = "" first = True try: - monitor_cmd = "monitor:" + str(self.last_received_time) + " " + regex + monitor_cmd = "monitor:" + str(self.last_received_time) + " " + self.regex what = "send monitor command " + monitor_cmd self.execute_command(command=monitor_cmd, retry_on_exception=True, read_the_response=False) print("Monitor started on " + str(self.atsign.to_string()))