Skip to content

Commit

Permalink
Merge pull request #255 from pierr3/hf-alias
Browse files Browse the repository at this point in the history
Show paired frequencies (HF/VHF)
  • Loading branch information
GeorgeBarlow authored Jan 15, 2025
2 parents d843282 + 168748e commit 3f4c68d
Show file tree
Hide file tree
Showing 27 changed files with 716 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
git submodule update --init --remote backend/extern/afv-native
git submodule update --init --remote backend/extern/libuiohook
cd backend/extern/afv-native
git checkout modern-event-bus
git checkout develop-trackaudio
cd ../libuiohook
git checkout unregister-hook-when-debugging
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
git submodule update --init --remote backend/extern/afv-native
git submodule update --init --remote backend/extern/libuiohook
cd backend/extern/afv-native
git checkout modern-event-bus
git checkout develop-trackaudio
cd ../libuiohook
git checkout unregister-hook-when-debugging
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

build

# Runtime data
pids
*.pid
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"type": "lldb",
"request": "attach",
"name": "Debug Electron Renderer",
"name": "Debug NAPI Backend",
"pid": "${command:pickProcess}"
}
],
Expand Down
1 change: 1 addition & 0 deletions backend/include/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "RadioSimulation.h"
#include "Shared.hpp"

#include "afv-native/types.h"
#include <cmath>
#include <mutex>
#include <nlohmann/json.hpp>
Expand Down
28 changes: 22 additions & 6 deletions backend/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "LogFactory.h"
#include "afv-native/afv/dto/Station.h"
#include "afv-native/afv/dto/StationTransceiver.h"
#include "afv-native/atcClientWrapper.h"
#include "afv-native/event.h"
Expand Down Expand Up @@ -248,7 +249,7 @@ Napi::Boolean SetFrequencyState(const Napi::CallbackInfo& info)

// SetGuardAndUnicomTransceivers();

auto result = RadioHelper::SetRadioState(MainThreadShared::mApiServer, newState);
auto result = RadioHelper::SetRadioState(MainThreadShared::mApiServer, newState, "");
return Napi::Boolean::New(info.Env(), result);
}

Expand Down Expand Up @@ -518,6 +519,7 @@ void RequestPttKeyName(const Napi::CallbackInfo& info)

void HandleAfvEvents()
{

afv_native::event::EventBus& event = afv_native::api::getEventBus();
event.AddHandler<afv_native::VoiceServerConnectedEvent>(
[&](const afv_native::VoiceServerConnectedEvent& event) {
Expand Down Expand Up @@ -554,15 +556,22 @@ void HandleAfvEvents()
return;
}

const auto& [callsign, frequency] = event.stationData.value();
const auto& [callsign, station] = event.stationData.value();
const auto frequency = station.frequency;

if (mClient->IsFrequencyActive(frequency)) {
PLOGW << "StationDataReceived: Frequency " << frequency
<< " already active, skipping";
return;
}

NapiHelpers::callElectron("StationDataReceived", callsign, std::to_string(frequency));
// Create a JSON object with the station data
nlohmann::json stationJson;
stationJson["name"] = station.name;
stationJson["frequency"] = station.frequency;
stationJson["frequencyAlias"] = station.frequencyAlias;

NapiHelpers::callElectron("StationDataReceived", callsign, stationJson.dump());
MainThreadShared::mApiServer->publishStationAdded(
callsign, static_cast<int>(frequency));
});
Expand All @@ -571,15 +580,22 @@ void HandleAfvEvents()
[&](const afv_native::VccsReceivedEvent& event) {
const auto& stations = event.vccsData;

for (const auto& [callsign, frequency] : stations) {
for (const auto& [callsign, station] : stations) {

const auto frequency = station.frequency;

if (mClient->IsFrequencyActive(frequency)) {
PLOGW << "VccsReceived: Frequency " << frequency << " already active, skipping";
continue;
}

NapiHelpers::callElectron(
"StationDataReceived", callsign, std::to_string(frequency));
// Create a JSON object with the station data
nlohmann::json stationJson;
stationJson["name"] = station.name;
stationJson["frequency"] = station.frequency;
stationJson["frequencyAlias"] = station.frequencyAlias;

NapiHelpers::callElectron("StationDataReceived", callsign, stationJson.dump());
MainThreadShared::mApiServer->publishStationAdded(
callsign, static_cast<int>(frequency));
}
Expand Down
24 changes: 10 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"electron-log": "^5.2.4",
"electron-store": "^8.2.0",
"electron-updater": "^6.3.9",
"lucide-react": "^0.469.0",
"react": "^18.3.1",
"react-bootstrap-icons": "^1.11.4",
"react-dom": "^18.3.1",
"react-responsive": "^10.0.0",
"scss": "^0.2.4",
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/src/components/MiniModeToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import useRadioState from '@renderer/store/radioStore';
import useSessionStore from '@renderer/store/sessionStore';
import { Maximize, Minimize } from 'lucide-react';
import React, { useCallback } from 'react';
import { Fullscreen, FullscreenExit } from 'react-bootstrap-icons';

interface MiniModeToggleButtonProps {
showRestoreButton: boolean;
Expand Down Expand Up @@ -29,15 +29,9 @@ const MiniModeToggleButton: React.FC<MiniModeToggleButtonProps> = ({
disabled={!isConnected && !alwaysEnabled}
>
{showRestoreButton ? (
<Fullscreen
title={'Switch to large mode'}
style={{ strokeWidth: '0.5px', stroke: 'white' }}
/>
<Maximize size={15} xlinkTitle="Switch to mini mode" />
) : (
<FullscreenExit
title={'Switch to mini mode'}
style={{ strokeWidth: '0.5px', stroke: 'white' }}
/>
<Minimize size={15} xlinkTitle="Switch to mini mode" />
)}
</button>
);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/components/delete-multiple-radios.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import useRadioState from '@renderer/store/radioStore';
import useSessionStore from '@renderer/store/sessionStore';
import useUtilStore from '@renderer/store/utilStore';
import { Trash2 } from 'lucide-react';
import React from 'react';
import { TrashFill } from 'react-bootstrap-icons';

const DeleteMultipleRadios: React.FC = () => {
const [isConnected] = useSessionStore((state) => [state.isConnected]);
Expand Down Expand Up @@ -67,7 +67,7 @@ const DeleteMultipleRadios: React.FC = () => {
handleDeleteRadios();
}}
>
<TrashFill />
<Trash2 size={15} />
</button>
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/src/components/focusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const FocusBar = () => {
state.connectTimestamp
]);
const [pendingRestart] = useUtilStore((state) => [state.pendingRestart]);
const isWideScreen = useMediaQuery({ minWidth: '800px' });
const isSmallScreen = useMediaQuery({ maxWidth: '490px' });
// const isWideScreen = useMediaQuery({ minWidth: '800px' });
// const isSmallScreen = useMediaQuery({ maxWidth: '490px' });
const isWideScreen = useMediaQuery({ minWidth: '755px' });
const isSmallScreen = useMediaQuery({ maxWidth: '615px' });

const restartApp = () => {
if (isConnected) {
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import Clock from './clock';
import MiniModeToggleButton from './MiniModeToggleButton';
import SettingsModal from './settings-modal/settings-modal';
import TitleBar from './titlebar/TitleBar';
import { GearFill, PencilSquare, PlusCircleFill } from 'react-bootstrap-icons';
import SessionStatus from './titlebar/session-status/SessionStatus';
import useUtilStore from '@renderer/store/utilStore';
import AddStationModal from './add-station-model/station-modal';
import DeleteMultipleRadios from './delete-multiple-radios';
import useRadioState from '@renderer/store/radioStore';
import RefreshMultipleRadios from './refresh-multiple-radios';
import { CirclePlus, Settings, SquarePen } from 'lucide-react';

const Navbar: React.FC = () => {
const [showSettingsModal, setShowSettingsModal] = useState(false);
Expand Down Expand Up @@ -63,7 +63,7 @@ const Navbar: React.FC = () => {
clearRadiosToBeDeleted();
}}
>
<PencilSquare />
<SquarePen size={15} />
</button>
</div>
</TitleBar.Element>
Expand All @@ -81,14 +81,14 @@ const Navbar: React.FC = () => {
<TitleBar.Element priority={2}>
<div className="d-flex h-100 align-items-center">
<button
className="btn btn-primary hide-settings-flex"
className="btn btn-primary hide-settings-flex "
disabled={!isConnected}
onClick={() => {
if (showSettingsModal || !isConnected) return;
setShowAddStationModal(true);
}}
>
<PlusCircleFill />
<CirclePlus size={15} />
</button>
</div>
</TitleBar.Element>
Expand All @@ -97,14 +97,14 @@ const Navbar: React.FC = () => {
<TitleBar.Element priority={3}>
<div className="d-flex h-100 align-items-center">
<button
className="btn btn-primary hide-settings-flex"
className="btn btn-primary hide-settings-flex "
disabled={isConnected || isConnecting}
onClick={() => {
if (showAddStationModal) return;
setShowSettingsModal(true);
}}
>
<GearFill />
<Settings size={15} />
</button>
</div>
</TitleBar.Element>
Expand Down
88 changes: 0 additions & 88 deletions src/renderer/src/components/radio/connection-steps.tsx

This file was deleted.

Loading

0 comments on commit 3f4c68d

Please sign in to comment.