1
0
Fork 0

Merge pull request #211 from oe1kbc/patch-10

Update YSFNetwork.cpp
ycs232-kbc
Jonathan Naylor 4 years ago committed by GitHub
commit fabcb14c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,7 @@ m_debug(debug),
m_address(),
m_port(0U),
m_poll(NULL),
m_options(NULL),
m_unlink(NULL),
m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U),
@ -45,12 +46,16 @@ m_linked(false)
m_unlink = new unsigned char[14U];
::memcpy(m_unlink + 0U, "YSFU", 4U);
m_options = new unsigned char[50U];
::memcpy(m_options + 0U, "YSFO", 4U);
std::string node = callsign;
node.resize(YSF_CALLSIGN_LENGTH, ' ');
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) {
m_poll[i + 4U] = node.at(i);
m_unlink[i + 4U] = node.at(i);
m_options[i + 4U] = node.at(i);
}
}
@ -60,6 +65,7 @@ m_debug(debug),
m_address(),
m_port(0U),
m_poll(NULL),
m_options(NULL),
m_unlink(NULL),
m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U)
@ -70,12 +76,16 @@ m_pollTimer(1000U, 5U)
m_unlink = new unsigned char[14U];
::memcpy(m_unlink + 0U, "YSFU", 4U);
m_options = new unsigned char[50U];
::memcpy(m_options + 0U, "YSFO", 4U);
std::string node = callsign;
node.resize(YSF_CALLSIGN_LENGTH, ' ');
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) {
m_poll[i + 4U] = node.at(i);
m_unlink[i + 4U] = node.at(i);
m_options[i + 4U] = node.at(i);
}
}
@ -130,6 +140,23 @@ void CYSFNetwork::writePoll(unsigned int count)
for (unsigned int i = 0U; i < count; i++)
m_socket.write(m_poll, 14U, m_address, m_port);
if (m_options != NULL)
m_socket.write(m_options, 50U, m_address, m_port);
}
void CYSFNetwork::setOptions(const std::string& options)
{
std::string opt = options;
if (opt.size() < 1)
return;
opt.resize(50, ' ');
for (unsigned int i = 0U; i < (50 - 4 - YSF_CALLSIGN_LENGTH); i++) {
m_options[i + 4U + YSF_CALLSIGN_LENGTH] = opt.at(i);
}
}
void CYSFNetwork::writeUnlink(unsigned int count)
@ -172,6 +199,9 @@ void CYSFNetwork::clock(unsigned int ms)
LogMessage("Linked to %s", m_name.c_str());
m_linked = true;
if (m_options != NULL)
m_socket.write(m_options, 50U, m_address, m_port);
}
if (m_debug)

Loading…
Cancel
Save