Skip to content

Commit

Permalink
the scan must be restarted if the platform interface is in init state
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ committed Aug 27, 2023
1 parent f8ce3ec commit 957d58a
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions client/panduza/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,13 @@ def __store_scan_result(self, topic, payload):
# Process the payload
info = json.loads(payload.decode("utf-8"))
if info["info"]["type"] == "platform":
self.__scan_count_platform += info["info"]["interfaces"]
self.__scan_count_interfaces += 1

print(info)
if info["info"]["state"] == "init":
self.__scan_restart_cmd = True
else:
self.__scan_count_platform += info["info"]["interfaces"]
self.__scan_count_interfaces += 1
else:
self.__scan_count_interfaces += 1

Expand Down Expand Up @@ -303,6 +308,7 @@ def scan_interfaces(self, type_filter="*"):
self.__scan_count_platform = 0
self.__scan_count_interfaces = 0
self.__scan_type_filter = type_filter
self.__scan_restart_cmd = False

# Debug log
self.log.info("Start Interface Scanning...")
Expand All @@ -321,6 +327,21 @@ def scan_interfaces(self, type_filter="*"):
with self.__scan_mutex:
continue_scan = (self.__scan_count_platform == 0) or (self.__scan_count_platform != self.__scan_count_interfaces)

if self.__scan_restart_cmd:

print("restart")
continue_scan = True
self.__scan_restart_cmd = False
time.sleep(2)
start_scan_time = time.perf_counter()
self.__scan_count_platform = 0
self.__scan_count_interfaces = 0
self.__scan_results = {}
self.__scan_messages_logs = queue.Queue()
self.publish("pza", u"*", qos=0)
print("okkk")


# Debug logs from the mqtt client thread
while not self.__scan_messages_logs.empty():
msg = self.__scan_messages_logs.get()
Expand Down

0 comments on commit 957d58a

Please sign in to comment.