Skip to content

Commit

Permalink
Fix Ptt crash on mac #77
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed May 31, 2024
1 parent e7a1d99 commit 00ffcf4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions backend/include/RemoteData.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <Poco/Timer.h>
#include <absl/strings/match.h>
#include <absl/strings/str_split.h>
Expand Down
6 changes: 2 additions & 4 deletions backend/include/sdkWebsocketMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ class Station {

// Example of kTxBegin message:
// @type the type of the message
// @value the frequencies which are being transmitted on
// JSON: {"type": "kTxBegin", "value": {"pFrequenciesHz": [123000000, 118000000]}}
// JSON: {"type": "kTxBegin", "value": {}}

// Example of kTxEnd message:
// @type the type of the message
// @value the frequencies which were being transmitted on
// JSON: {"type": "kTxEnd", "value": {"pFrequenciesHz": [123000000, 118000000]}}
// JSON: {"type": "kTxEnd", "value": {}}
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"types": "types/index.d.ts",
"scripts": {
"build": "cmake-js compile -B Release && node custom_build.mjs && npm pack",
"build": "cmake-js compile -B Release -p 8 && node custom_build.mjs && npm pack",
"format": "clang-format -i include/**.hpp && clang-format -i include/**.h && clang-format -i src/**.cpp"
},
"cmake-js": {
Expand Down
1 change: 1 addition & 0 deletions backend/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ void SetPtt(const Napi::CallbackInfo& info)
}

bool state = info[0].As<Napi::Boolean>().Value();

mClient->SetPtt(state);
}

Expand Down
36 changes: 19 additions & 17 deletions backend/src/sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,33 @@ void SDK::handleAFVEventForWebsocket(sdk::types::Event event,
}

if (event == sdk::types::Event::kTxBegin) {
auto allRadios = mClient->getRadioState();
std::vector<unsigned int> allTxRadioFreqs;
for (const auto& [freq, state] : allRadios) {
if (state.tx) {
allTxRadioFreqs.push_back(freq);
}
}
// auto allRadios = mClient->getRadioState();
// std::vector<unsigned int> allTxRadioFreqs;
// for (const auto& [freq, state] : allRadios) {
// if (state.tx) {
// allTxRadioFreqs.push_back(freq);
// }
// }

nlohmann::json jsonMessage = WebsocketMessage::buildMessage(WebsocketMessageType::kTxBegin);
jsonMessage["value"]["pFrequenciesHz"] = allTxRadioFreqs;
// jsonMessage["value"]["pFrequenciesHz"] = allTxRadioFreqs;
this->broadcastOnWebsocket(jsonMessage.dump());
return;
}

if (event == sdk::types::Event::kTxEnd) {
auto allRadios = mClient->getRadioState();
std::vector<unsigned int> allTxRadioFreqs;
for (const auto& [freq, state] : allRadios) {
if (state.tx) {
allTxRadioFreqs.push_back(freq);
}
}
// auto allRadios = mClient->getRadioState();
// std::vector<unsigned int> allTxRadioFreqs;
// for (const auto& [freq, state] : allRadios) {
// if (state.tx) {
// allTxRadioFreqs.push_back(freq);
// }
// }

nlohmann::json jsonMessage = WebsocketMessage::buildMessage(WebsocketMessageType::kTxEnd);
jsonMessage["value"]["pFrequenciesHz"] = allTxRadioFreqs;
// jsonMessage["value"]["pFrequenciesHz"] = allTxRadioFreqs;
this->broadcastOnWebsocket(jsonMessage.dump());
return;
}

if (event == sdk::types::Event::kFrequencyStateUpdate) {
Expand Down Expand Up @@ -158,7 +160,7 @@ std::unique_ptr<restinio::router::express_router_t<>> SDK::buildRouter()
.connection_close()
.done();
};

router->add_handler(
restinio::router::none_of_methods(restinio::http_method_get()), "/", methodNotAllowed);

Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

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

0 comments on commit 00ffcf4

Please sign in to comment.