From 32e1aa7edb81d952527b4eb7c0bfdbd7ca759003 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 30 Nov 2023 08:44:18 +0100 Subject: [PATCH] Improve frame handler event broadcast --- modem/event_manager.py | 3 +++ modem/frame_handler.py | 1 + modem/frame_handler_ping.py | 5 ----- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modem/event_manager.py b/modem/event_manager.py index 606c0db1..0d70ce19 100644 --- a/modem/event_manager.py +++ b/modem/event_manager.py @@ -1,11 +1,14 @@ import json +import structlog class EventManager: def __init__(self, queues): self.queues = queues + self.log = structlog.get_logger('Event Manager') def broadcast(self, data): + self.log.debug(f"Broadcasting event: {data}") for q in self.queues: q.put(data) diff --git a/modem/frame_handler.py b/modem/frame_handler.py index f676af47..6198d7e1 100644 --- a/modem/frame_handler.py +++ b/modem/frame_handler.py @@ -44,6 +44,7 @@ class FrameHandler(): def make_event(self): event = { "freedata": "modem-message", + "received": self.details['frame']['frame_type'], "uuid": str(uuid.uuid4()), "timestamp": int(time.time()), "mycallsign": self.config['STATION']['mycall'], diff --git a/modem/frame_handler_ping.py b/modem/frame_handler_ping.py index d9a98290..16a555c3 100644 --- a/modem/frame_handler_ping.py +++ b/modem/frame_handler_ping.py @@ -4,11 +4,6 @@ import data_frame_factory class PingFrameHandler(frame_handler.FrameHandler): - def make_event(self): - event = super().make_event() - event['ping'] = "received" - return event - def follow_protocol(self): deconstructed_frame = self.details['frame'] origin = deconstructed_frame["origin"]