Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Removed search API from self station auto add
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Mar 7, 2022
1 parent 9128438 commit a3fb4ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
10 changes: 10 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,14 @@ namespace afv_unix::util {
return "Schmid ED-137B";
}
}

inline static std::string ReplaceString(std::string subject, const std::string& search,
const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
return subject;
}
}
20 changes: 17 additions & 3 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,24 @@ namespace afv_unix::application {
}

if (mClient->IsAPIConnected() && shared::FetchedStations.size() == 0 && !shared::bootUpVccs) {
// We pre-fetch the user station and get ready to populate the VCCS
// We force add the current user frequency
shared::bootUpVccs = true;
std::string strippedCallsign = shared::datafile::callsign.substr(0, shared::datafile::callsign.find("_"));
mClient->SearchStation(strippedCallsign, shared::datafile::frequency);
std::string cleanCallsign = afv_unix::util::ReplaceString(shared::datafile::callsign, "__", "_");

shared::StationElement el = shared::StationElement::build(cleanCallsign, shared::datafile::frequency);
if(!_frequencyExists(el.freq))
shared::FetchedStations.push_back(el);

this->mClient->AddFrequency(shared::datafile::frequency, cleanCallsign);
this->mClient->UseTransceiversFromStation(cleanCallsign, shared::datafile::frequency);
this->mClient->SetRx(shared::datafile::frequency, true);
if (shared::datafile::facility > 0) {
this->mClient->SetTx(shared::datafile::frequency, true);
this->mClient->SetXc(shared::datafile::frequency, true);
}
this->mClient->FetchStationVccs(cleanCallsign);
//std::string strippedCallsign = shared::datafile::callsign.substr(0, shared::datafile::callsign.find("_"));
//mClient->SearchStation(strippedCallsign, shared::datafile::frequency);
}
}

Expand Down

0 comments on commit a3fb4ec

Please sign in to comment.