Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/freedata_gui/deve…
Browse files Browse the repository at this point in the history
…lop/eslint-9.10.0
  • Loading branch information
DJ2LS authored Nov 11, 2024
2 parents ea13b4e + cf65632 commit 90be0e4
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 723 deletions.
21 changes: 11 additions & 10 deletions freedata_gui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
sizes="16x16"
href="<%= BASE_URL %>favicon-16x16.png"
/>
<link rel="icon" type="image/png" sizes="192x192" href="<%= BASE_URL %>android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="<%= BASE_URL %>android-chrome-512x512.png" />

<!-- Apple touch icon -->
<link rel="apple-touch-icon" href="<%= BASE_URL %>apple-touch-icon.png" />
Expand All @@ -36,16 +38,15 @@

<!-- Add custom JavaScript to set the viewport height -->
<script>
function setAppHeight() {
const appHeight = window.innerHeight;
document.documentElement.style.setProperty(
"--app-height",
`${appHeight}px`,
);
}
window.addEventListener("resize", setAppHeight);
window.addEventListener("orientationchange", setAppHeight); // Handle orientation changes
document.addEventListener("DOMContentLoaded", setAppHeight); // Set height on initial load
function setAppHeight() {
const appHeight =
window.visualViewport?.height || window.innerHeight;
document.documentElement.style.setProperty("--app-height", `${appHeight}px`);
}
window.addEventListener("resize", setAppHeight);
window.addEventListener("orientationchange", setAppHeight);
document.addEventListener("DOMContentLoaded", setAppHeight);

</script>

<!-- Custom styles to use the dynamic height -->
Expand Down
2 changes: 2 additions & 0 deletions freedata_gui/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "FreeDATA",
"short_name": "FreeDATA",
"description": "FreeDATA is a communication platform for transferring data over radio.",
"categories": ["utilities", "communication", "productivity"],
"start_url": ".",
"display": "standalone",
"background_color": "#ffffff",
Expand Down
2 changes: 1 addition & 1 deletion freedata_gui/src/components/grid/grid_CQ.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function handleCQCall() {
// Wait for 6 seconds (cooldown period)
setTimeout(() => {
isCQButtonDisabled.value = false;
}, 6000);
}, 10000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function handleSendCQ() {
// Wait for 6 seconds (cooldown period)
setTimeout(() => {
isCQButtonDisabled.value = false;
}, 6000);
}, 10000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function handleSendCQ() {
// Wait for 6 seconds (cooldown period)
setTimeout(() => {
isCQButtonDisabled.value = false;
}, 6000);
}, 10000);
}
// Listen for the stationSelected event and update dxcallPing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function getDateTime(timestampRaw) {
navigator.language,
{
hourCycle: 'h23',
year: '2-digit',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
Expand Down Expand Up @@ -107,7 +106,8 @@ function transmitPing(callsign) {
@click="pushToPing(item.origin)"
>
<td>
<small>{{ getDateTime(item.timestamp) }}</small>
<span class="badge text-bg-secondary">{{ getDateTime(item.timestamp) }}</span>

</td>
<td><small>{{ item.frequency / 1000 }} kHz</small></td>
<td>
Expand All @@ -118,7 +118,7 @@ function transmitPing(callsign) {
@click="getStationInfoByCallsign(item.origin)"
disabled
>
<h6 class="p-0 m-0"><span class="badge text-bg-primary">{{ item.origin }}</span></h6>
<span class="badge text-bg-primary">{{ item.origin }}</span>
</button>

<button
Expand Down
8 changes: 5 additions & 3 deletions freedata_gui/src/components/grid/grid_activities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ function getDateTime(timestampRaw) {
<div class="card-body overflow-auto m-0 p-0" style="align-items: start">
<div v-for="item in state.activities" :key="item[0]">
<h6 style="text-align: start" class="mb-0">
<span class="badge text-bg-primary">
{{ item[1].origin }}</span> -
<span class="badge text-bg-secondary">{{ getDateTime(item[1].timestamp) }}</span>
<span class="badge text-bg-primary">{{ item[1].origin }}</span>
-
<span class="badge text-bg-secondary">{{getDateTime(item[1].timestamp) }}</span>


</h6>

<p class="mb-2" style="text-align: start; font-size: smaller">
Expand Down
289 changes: 285 additions & 4 deletions freedata_gui/src/components/settings_hamlib.vue

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion freedata_server/frame_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def process_data(self, bytes_out, freedv, bytes_per_frame: int, snr, frequency_o
# get frame as dictionary
deconstructed_frame = self.frame_factory.deconstruct(bytes_out, mode_name=mode_name)
frametype = deconstructed_frame["frame_type_int"]

if frametype not in self.FRAME_HANDLER:
self.log.warning(
"[DISPATCHER] ARQ - other frame type", frametype=FR_TYPE(frametype).name)
Expand Down
49 changes: 36 additions & 13 deletions freedata_server/frame_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,7 @@ def add_to_heard_stations(self):
return

dxgrid = frame.get('gridsquare', "------")
#try to find station info in database
try:
station = DatabaseManagerStations(self.event_manager).get_station(frame['origin'])
if station and "gridsquare" in station["location"]:
dxgrid = station["location"]["gridsquare"]

except Exception:
pass

# Initialize distance values
distance_km = None
Expand Down Expand Up @@ -178,18 +171,22 @@ def make_event(self):

if 'gridsquare' in self.details['frame']:
event['gridsquare'] = self.details['frame']['gridsquare']
if event['gridsquare'] != "------":
distance = maidenhead.distance_between_locators(self.config['STATION']['mygrid'], self.details['frame']['gridsquare'])
event['distance_kilometers'] = distance['kilometers']
event['distance_miles'] = distance['miles']
else:
event['distance_kilometers'] = 0
event['distance_miles'] = 0

distance = maidenhead.distance_between_locators(self.config['STATION']['mygrid'], self.details['frame']['gridsquare'])
event['distance_kilometers'] = distance['kilometers']
event['distance_miles'] = distance['miles']

if "flag" in self.details['frame'] and "AWAY_FROM_KEY" in self.details['frame']["flag"]:
event['away_from_key'] = self.details['frame']["flag"]["AWAY_FROM_KEY"]

return event

def emit_event(self):
event_data = self.make_event()
print(event_data)
self.event_manager.broadcast(event_data)

def get_tx_mode(self):
Expand All @@ -214,17 +211,43 @@ def handle(self, frame, snr, frequency_offset, freedv_inst, bytes_per_frame):
self.details['freedv_inst'] = freedv_inst
self.details['bytes_per_frame'] = bytes_per_frame

print(self.details)

if 'origin' not in self.details['frame'] and 'session_id' in self.details['frame']:
dxcall = self.states.get_dxcall_by_session_id(self.details['frame']['session_id'])
if dxcall:
self.details['frame']['origin'] = dxcall

# look in database for a full callsign if only crc is present
if 'origin' not in frame and 'origin_crc' in frame:
if 'origin' not in self.details['frame'] and 'origin_crc' in self.details['frame']:
self.details['frame']['origin'] = DatabaseManager(self.event_manager).get_callsign_by_checksum(frame['origin_crc'])

if "location" in self.details['frame'] and "gridsquare" in self.details['frame']['location']:
DatabaseManagerStations(self.event_manager).update_station_location(self.details['frame']['origin'], frame['gridsquare'])


if 'origin' in self.details['frame']:
# try to find station info in database
try:
station = DatabaseManagerStations(self.event_manager).get_station(self.details['frame']['origin'])
if station and station["location"] and "gridsquare" in station["location"]:
dxgrid = station["location"]["gridsquare"]
else:
dxgrid = "------"

# overwrite gridsquare only if not provided by frame
if "gridsquare" not in self.details['frame']:
self.details['frame']['gridsquare'] = dxgrid

except Exception as e:
self.logger.info(f"[Frame Handler] Error getting gridsquare from callsign info: {e}")

# check if callsign is blacklisted
if self.config["STATION"]["enable_callsign_blacklist"]:
if self.is_origin_on_blacklist():
self.logger.info(f"[Frame Handler] Callsign blocked: {self.details['frame']['origin']}")
return False


self.log()
self.add_to_heard_stations()
self.add_to_activity_list()
Expand Down
1 change: 0 additions & 1 deletion freedata_server/frame_handler_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class PingFrameHandler(frame_handler.FrameHandler):
def follow_protocol(self):
if not bool(self.is_frame_for_me() and not self.states.getARQ()):
return

self.logger.debug(
f"[Modem] Responding to request from [{self.details['frame']['origin']}]",
snr=self.details['snr'],
Expand Down
50 changes: 47 additions & 3 deletions freedata_server/message_system_db_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ def get_station(self, callsign):
"""
Retrieves a station by its callsign.
"""

session = self.get_thread_scoped_session()
try:
station = session.query(Station).filter_by(callsign=callsign).first()
return station.to_dict() if station else None

if station:
return station.to_dict()
else:
self.log(f"No data found: {callsign}")
return None
except Exception as e:
self.log(f"error fetching database station with error: {e}", isWarning=True)
self.log(f"---> please delete or update existing database", isWarning=True)
Expand Down Expand Up @@ -56,3 +58,45 @@ def update_station_info(self, callsign, new_info):
return False
finally:
session.remove()


def update_station_location(self, callsign, gridsquare):
"""
Updates the location information of a station identified by its callsign.
Args:
callsign (str): The callsign of the station to update.
gridsquare (str): The new gridsquare to store in the 'location' column.
Returns:
bool: True if the update was successful, False otherwise.
"""
session = self.get_thread_scoped_session()
try:
# Ensure the station exists or create it, and get the station object
station = self.get_or_create_station(callsign, session)

if station:
# Initialize location as an empty dict if None
if not station.location:
station.location = {}

# Update the station's location with gridsquare if it has changed
if station.location.get('gridsquare') != gridsquare:
self.log(f"Updating location for {callsign}")
station.location['gridsquare'] = gridsquare # Update directly without re-serialization
session.flush()
else:
self.log(f"No changes needed for {callsign}'s location")

session.commit()
return True
else:
self.log(f"No station found with callsign {callsign}", isWarning=True)
return False
except SQLAlchemyError as e:
session.rollback()
self.log(f"Failed to update location for station {callsign} with error: {e}", isError=True)
return False
finally:
session.remove()
28 changes: 27 additions & 1 deletion freedata_server/state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,30 @@ def register_p2p_connection_session(self, session):
def get_p2p_connection_session(self, id):
if id not in self.p2p_connection_sessions:
pass
return self.p2p_connection_sessions[id]
return self.p2p_connection_sessions[id]

def get_dxcall_by_session_id(self, session_id):
"""
Retrieves the dxcall associated with a given session ID by checking both ISS and IRS sessions.
Args:
session_id (str): The ID of the session.
Returns:
str: The dxcall associated with the session ID, or None if not found.
"""
try:
# Check ISS sessions
if session_id in self.arq_iss_sessions:
return self.arq_iss_sessions[session_id].dxcall

# Check IRS sessions
if session_id in self.arq_irs_sessions:
return self.arq_irs_sessions[session_id].dxcall

# If not found in either session dictionary
self.log(f"Session ID {session_id} not found in ISS or IRS sessions", isWarning=True)
return None
except KeyError:
self.log(f"Error retrieving session ID {session_id}", isError=True)
return None
1 change: 0 additions & 1 deletion tools/buffer-test/rx_data.py

This file was deleted.

1 change: 0 additions & 1 deletion tools/buffer-test/tx_data.py

This file was deleted.

3 changes: 0 additions & 3 deletions tools/cleanup.sh

This file was deleted.

61 changes: 0 additions & 61 deletions tools/create_hmac_tokes.py

This file was deleted.

Loading

0 comments on commit 90be0e4

Please sign in to comment.