From bed741069a3a2031df8f2d5b8c02f2ac796aa371 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Tue, 16 Apr 2024 08:28:37 +0200 Subject: [PATCH] fixed beacon away from key --- modem/command_beacon.py | 3 ++- modem/data_frame_factory.py | 5 ++--- modem/frame_handler.py | 3 ++- modem/frame_handler_beacon.py | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modem/command_beacon.py b/modem/command_beacon.py index d8afc749..8e972ca3 100644 --- a/modem/command_beacon.py +++ b/modem/command_beacon.py @@ -3,7 +3,8 @@ from command import TxCommand class BeaconCommand(TxCommand): def build_frame(self): - return self.frame_factory.build_beacon() + beacon_state = self.state_manager.is_away_from_key + return self.frame_factory.build_beacon(beacon_state) #def transmit(self, modem): diff --git a/modem/data_frame_factory.py b/modem/data_frame_factory.py index ba3a6d0c..f55dc3d4 100644 --- a/modem/data_frame_factory.py +++ b/modem/data_frame_factory.py @@ -284,7 +284,6 @@ class DataFrameFactory: data = int.from_bytes(data, "big") extracted_data[key] = {} - # check for frametype for selecting the correspinding flag dictionary if frametype in [FR_TYPE.ARQ_SESSION_OPEN_ACK.value, FR_TYPE.ARQ_SESSION_INFO_ACK.value, FR_TYPE.ARQ_BURST_ACK.value]: flag_dict = self.ARQ_FLAGS @@ -293,7 +292,7 @@ class DataFrameFactory: # get_flag returns True or False based on the bit value at the flag's position extracted_data[key][flag] = helpers.get_flag(data, flag, flag_dict) - if frametype in [FR_TYPE.BEACON]: + if frametype in [FR_TYPE.BEACON.value]: flag_dict = self.BEACON_FLAGS for flag in flag_dict: # Update extracted_data with the status of each flag @@ -354,7 +353,7 @@ class DataFrameFactory: } return self.construct(FR_TYPE.QRV, payload) - def build_beacon(self, flag_away_from_key = False): + def build_beacon(self, flag_away_from_key=False): flag = 0b00000000 if flag_away_from_key: flag = helpers.set_flag(flag, 'AWAY_FROM_KEY', True, self.BEACON_FLAGS) diff --git a/modem/frame_handler.py b/modem/frame_handler.py index c6654eb2..c4ad87b2 100644 --- a/modem/frame_handler.py +++ b/modem/frame_handler.py @@ -127,7 +127,8 @@ class FrameHandler(): self.states.radio_frequency, self.states.heard_stations, distance_km=distance_km, # Pass the kilometer distance - distance_miles=distance_miles # Pass the miles distance + distance_miles=distance_miles, # Pass the miles distance + away_from_key=self.details['frame']["flag"]["AWAY_FROM_KEY"] ) def make_event(self): diff --git a/modem/frame_handler_beacon.py b/modem/frame_handler_beacon.py index 6c6fff43..10b79822 100644 --- a/modem/frame_handler_beacon.py +++ b/modem/frame_handler_beacon.py @@ -14,8 +14,7 @@ class BeaconFrameHandler(frame_handler.FrameHandler): DatabaseManagerBeacon(self.event_manager).add_beacon(datetime.datetime.now(), self.details['frame']["origin"], self.details["snr"], - self.details['frame']["gridsquare"], - self.details['frame']["flag"]["away_from_key"] + self.details['frame']["gridsquare"] ) if self.config["MESSAGES"]["enable_auto_repeat"]: