Skip to content

Commit

Permalink
#8 Move sending of id frames to own function
Browse files Browse the repository at this point in the history
  • Loading branch information
F4FXL committed Dec 31, 2021
1 parent aecbc44 commit cb5797d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions APRSWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,8 @@ void CAPRSWriter::clock(unsigned int ms)

if(m_idFrameProvider != nullptr) {
m_idFrameProvider->clock(ms);

if(m_idFrameProvider->wantsToSend() && m_thread->isConnected()) {
for(auto entry : m_array) {
std::vector<std::string> frames;
if(m_idFrameProvider->buildAPRSFrames(m_gateway, entry.second, frames)) {
for(auto frame : frames) {
m_thread->write(frame.c_str());
}
}
}
if(m_idFrameProvider->wantsToSend()) {
sendIdFrames();
}
}

Expand All @@ -182,6 +174,21 @@ void CAPRSWriter::clock(unsigned int ms)
}
}

void CAPRSWriter::sendIdFrames()
{
if(m_thread->isConnected())
{
for(auto entry : m_array) {
std::vector<std::string> frames;
if(m_idFrameProvider->buildAPRSFrames(m_gateway, entry.second, frames)) {
for(auto frame : frames) {
m_thread->write(frame.c_str());
}
}
}
}
}

bool CAPRSWriter::isConnected() const
{
return m_thread->isConnected();
Expand Down
2 changes: 1 addition & 1 deletion APRSWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CAPRSWriter {
std::unordered_map<std::string,CAPRSEntry *> m_array;
CAPRSIdFrameProvider * m_idFrameProvider;

void sendIdFramesMobile();
void sendIdFrames();
};

#endif
Expand Down

0 comments on commit cb5797d

Please sign in to comment.