Use the node callsign for most Wires-X exchanges.
This commit is contained in:
parent
0b7280cd81
commit
e2ee965375
4 changed files with 27 additions and 33 deletions
|
@ -33,9 +33,10 @@ const unsigned int CALLSIGN_LENGTH = 8U;
|
|||
|
||||
const unsigned int APRS_TIMEOUT = 10U;
|
||||
|
||||
CAPRSWriterThread::CAPRSWriterThread(const std::string& callsign, const std::string& address, const std::string& hostname, unsigned int port) :
|
||||
CAPRSWriterThread::CAPRSWriterThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port) :
|
||||
CThread(),
|
||||
m_username(callsign),
|
||||
m_password(password),
|
||||
m_ssid(callsign),
|
||||
m_socket(hostname, port, address),
|
||||
m_queue(20U, "APRS Queue"),
|
||||
|
@ -46,6 +47,7 @@ m_filter(),
|
|||
m_clientName("YSFGateway")
|
||||
{
|
||||
assert(!callsign.empty());
|
||||
assert(!password.empty());
|
||||
assert(!hostname.empty());
|
||||
assert(port > 0U);
|
||||
|
||||
|
@ -56,9 +58,10 @@ m_clientName("YSFGateway")
|
|||
m_ssid = m_ssid.substr(CALLSIGN_LENGTH - 1U, 1);
|
||||
}
|
||||
|
||||
CAPRSWriterThread::CAPRSWriterThread(const std::string& callsign, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter, const std::string& clientName) :
|
||||
CAPRSWriterThread::CAPRSWriterThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter, const std::string& clientName) :
|
||||
CThread(),
|
||||
m_username(callsign),
|
||||
m_password(password),
|
||||
m_ssid(callsign),
|
||||
m_socket(hostname, port, address),
|
||||
m_queue(20U, "APRS Queue"),
|
||||
|
@ -69,6 +72,7 @@ m_filter(filter),
|
|||
m_clientName(clientName)
|
||||
{
|
||||
assert(!callsign.empty());
|
||||
assert(!password.empty());
|
||||
assert(!hostname.empty());
|
||||
assert(port > 0U);
|
||||
|
||||
|
@ -200,8 +204,6 @@ void CAPRSWriterThread::stop()
|
|||
|
||||
bool CAPRSWriterThread::connect()
|
||||
{
|
||||
unsigned int password = getAPRSPassword(m_username);
|
||||
|
||||
bool ret = m_socket.open();
|
||||
if (!ret)
|
||||
return false;
|
||||
|
@ -223,7 +225,7 @@ bool CAPRSWriterThread::connect()
|
|||
filter.insert(0U, " filter ");
|
||||
|
||||
char connectString[200U];
|
||||
::sprintf(connectString, "user %s-%s pass %u vers %s%s\n", m_username.c_str(), m_ssid.c_str(), password, (m_clientName.length() ? m_clientName : "YSFGateway").c_str(), filter.c_str());
|
||||
::sprintf(connectString, "user %s-%s pass %s vers %s%s\n", m_username.c_str(), m_ssid.c_str(), m_password.c_str(), (m_clientName.length() ? m_clientName : "YSFGateway").c_str(), filter.c_str());
|
||||
|
||||
ret = m_socket.writeLine(std::string(connectString));
|
||||
if (!ret) {
|
||||
|
@ -250,18 +252,3 @@ bool CAPRSWriterThread::connect()
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int CAPRSWriterThread::getAPRSPassword(std::string callsign) const
|
||||
{
|
||||
unsigned int len = callsign.length();
|
||||
|
||||
uint16_t hash = 0x73E2U;
|
||||
|
||||
for (unsigned int i = 0U; i < len; i += 2U) {
|
||||
hash ^= (char)callsign.at(i) << 8;
|
||||
if (i + 1 < len)
|
||||
hash ^= (char)callsign.at(i + 1);
|
||||
}
|
||||
|
||||
return hash & 0x7FFFU;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ typedef void (*ReadAPRSFrameCallback)(const std::string&);
|
|||
|
||||
class CAPRSWriterThread : public CThread {
|
||||
public:
|
||||
CAPRSWriterThread(const std::string& callsign, const std::string& address, const std::string& hostname, unsigned int port);
|
||||
CAPRSWriterThread(const std::string& callsign, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter, const std::string& clientName);
|
||||
CAPRSWriterThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port);
|
||||
CAPRSWriterThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter, const std::string& clientName);
|
||||
virtual ~CAPRSWriterThread();
|
||||
|
||||
virtual bool start();
|
||||
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string m_username;
|
||||
std::string m_password;
|
||||
std::string m_ssid;
|
||||
CTCPSocket m_socket;
|
||||
CRingBuffer<char*> m_queue;
|
||||
|
@ -57,7 +58,6 @@ private:
|
|||
std::string m_clientName;
|
||||
|
||||
bool connect();
|
||||
unsigned int getAPRSPassword(std::string username) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@ const unsigned char NET_HEADER[] = "YSFDGATEWAY ALL ";
|
|||
|
||||
CWiresX::CWiresX(const std::string& callsign, CNetwork* network, const std::string& hostsFile, unsigned int statusPort) :
|
||||
m_callsign(callsign),
|
||||
m_node(),
|
||||
m_network(network),
|
||||
m_reflectors(hostsFile, statusPort),
|
||||
m_reflector(NULL),
|
||||
|
@ -65,6 +66,10 @@ m_search()
|
|||
assert(network != NULL);
|
||||
assert(statusPort > 0U);
|
||||
|
||||
m_node = callsign;
|
||||
m_node.append("-ND");
|
||||
m_node.resize(YSF_CALLSIGN_LENGTH, ' ');
|
||||
|
||||
m_callsign.resize(YSF_CALLSIGN_LENGTH, ' ');
|
||||
|
||||
m_header = new unsigned char[34U];
|
||||
|
@ -118,10 +123,11 @@ void CWiresX::setInfo(const std::string& name, unsigned int txFrequency, unsigne
|
|||
::memset(m_csd2, ' ', 20U);
|
||||
::memset(m_csd3, ' ', 20U);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++) {
|
||||
m_csd1[i + 10U] = m_callsign.at(i);
|
||||
m_csd2[i + 0U] = m_callsign.at(i);
|
||||
}
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
m_csd1[i + 10U] = m_node.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
m_csd2[i + 0U] = m_callsign.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++) {
|
||||
m_csd3[i + 0U] = m_id.at(i);
|
||||
|
@ -132,7 +138,7 @@ void CWiresX::setInfo(const std::string& name, unsigned int txFrequency, unsigne
|
|||
m_header[i] = NET_HEADER[i];
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
m_header[i + 14U] = m_callsign.at(i);
|
||||
m_header[i + 14U] = m_node.at(i);
|
||||
}
|
||||
|
||||
bool CWiresX::start()
|
||||
|
@ -409,7 +415,7 @@ void CWiresX::sendDXReply()
|
|||
data[i + 5U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 10U] = m_callsign.at(i);
|
||||
data[i + 10U] = m_node.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + 20U] = m_name.at(i);
|
||||
|
@ -464,7 +470,7 @@ void CWiresX::sendConnectReply()
|
|||
data[i + 5U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 10U] = m_callsign.at(i);
|
||||
data[i + 10U] = m_node.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + 20U] = m_name.at(i);
|
||||
|
@ -515,7 +521,7 @@ void CWiresX::sendDisconnectReply()
|
|||
data[i + 5U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 10U] = m_callsign.at(i);
|
||||
data[i + 10U] = m_node.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + 20U] = m_name.at(i);
|
||||
|
@ -556,7 +562,7 @@ void CWiresX::sendAllReply()
|
|||
data[i + 7U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 12U] = m_callsign.at(i);
|
||||
data[i + 12U] = m_node.at(i);
|
||||
|
||||
unsigned int total = curr.size();
|
||||
if (total > 999U) total = 999U;
|
||||
|
@ -625,7 +631,7 @@ void CWiresX::sendSearchReply()
|
|||
data[i + 7U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 12U] = m_callsign.at(i);
|
||||
data[i + 12U] = m_node.at(i);
|
||||
|
||||
unsigned int total = curr.size();
|
||||
if (total > 999U) total = 999U;
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string m_callsign;
|
||||
std::string m_node;
|
||||
CNetwork* m_network;
|
||||
CReflectors m_reflectors;
|
||||
CYSFReflector* m_reflector;
|
||||
|
|
Loading…
Reference in a new issue