1
0
Fork 0

Use the node callsign for most Wires-X exchanges.

ycs232-kbc
Jonathan Naylor 9 years ago
parent 0b7280cd81
commit e2ee965375

@ -33,9 +33,10 @@ const unsigned int CALLSIGN_LENGTH = 8U;
const unsigned int APRS_TIMEOUT = 10U; 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(), CThread(),
m_username(callsign), m_username(callsign),
m_password(password),
m_ssid(callsign), m_ssid(callsign),
m_socket(hostname, port, address), m_socket(hostname, port, address),
m_queue(20U, "APRS Queue"), m_queue(20U, "APRS Queue"),
@ -46,6 +47,7 @@ m_filter(),
m_clientName("YSFGateway") m_clientName("YSFGateway")
{ {
assert(!callsign.empty()); assert(!callsign.empty());
assert(!password.empty());
assert(!hostname.empty()); assert(!hostname.empty());
assert(port > 0U); assert(port > 0U);
@ -56,9 +58,10 @@ m_clientName("YSFGateway")
m_ssid = m_ssid.substr(CALLSIGN_LENGTH - 1U, 1); 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(), CThread(),
m_username(callsign), m_username(callsign),
m_password(password),
m_ssid(callsign), m_ssid(callsign),
m_socket(hostname, port, address), m_socket(hostname, port, address),
m_queue(20U, "APRS Queue"), m_queue(20U, "APRS Queue"),
@ -69,6 +72,7 @@ m_filter(filter),
m_clientName(clientName) m_clientName(clientName)
{ {
assert(!callsign.empty()); assert(!callsign.empty());
assert(!password.empty());
assert(!hostname.empty()); assert(!hostname.empty());
assert(port > 0U); assert(port > 0U);
@ -200,8 +204,6 @@ void CAPRSWriterThread::stop()
bool CAPRSWriterThread::connect() bool CAPRSWriterThread::connect()
{ {
unsigned int password = getAPRSPassword(m_username);
bool ret = m_socket.open(); bool ret = m_socket.open();
if (!ret) if (!ret)
return false; return false;
@ -223,7 +225,7 @@ bool CAPRSWriterThread::connect()
filter.insert(0U, " filter "); filter.insert(0U, " filter ");
char connectString[200U]; 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)); ret = m_socket.writeLine(std::string(connectString));
if (!ret) { if (!ret) {
@ -250,18 +252,3 @@ bool CAPRSWriterThread::connect()
return true; 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 { class CAPRSWriterThread : public CThread {
public: 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& password, 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, const std::string& filter, const std::string& clientName);
virtual ~CAPRSWriterThread(); virtual ~CAPRSWriterThread();
virtual bool start(); virtual bool start();
@ -47,6 +47,7 @@ public:
private: private:
std::string m_username; std::string m_username;
std::string m_password;
std::string m_ssid; std::string m_ssid;
CTCPSocket m_socket; CTCPSocket m_socket;
CRingBuffer<char*> m_queue; CRingBuffer<char*> m_queue;
@ -57,7 +58,6 @@ private:
std::string m_clientName; std::string m_clientName;
bool connect(); bool connect();
unsigned int getAPRSPassword(std::string username) const;
}; };
#endif #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) : CWiresX::CWiresX(const std::string& callsign, CNetwork* network, const std::string& hostsFile, unsigned int statusPort) :
m_callsign(callsign), m_callsign(callsign),
m_node(),
m_network(network), m_network(network),
m_reflectors(hostsFile, statusPort), m_reflectors(hostsFile, statusPort),
m_reflector(NULL), m_reflector(NULL),
@ -65,6 +66,10 @@ m_search()
assert(network != NULL); assert(network != NULL);
assert(statusPort > 0U); assert(statusPort > 0U);
m_node = callsign;
m_node.append("-ND");
m_node.resize(YSF_CALLSIGN_LENGTH, ' ');
m_callsign.resize(YSF_CALLSIGN_LENGTH, ' '); m_callsign.resize(YSF_CALLSIGN_LENGTH, ' ');
m_header = new unsigned char[34U]; 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_csd2, ' ', 20U);
::memset(m_csd3, ' ', 20U); ::memset(m_csd3, ' ', 20U);
for (unsigned int i = 0U; i < 10U; i++) { for (unsigned int i = 0U; i < 10U; i++)
m_csd1[i + 10U] = m_callsign.at(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); m_csd2[i + 0U] = m_callsign.at(i);
}
for (unsigned int i = 0U; i < 5U; i++) { for (unsigned int i = 0U; i < 5U; i++) {
m_csd3[i + 0U] = m_id.at(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]; m_header[i] = NET_HEADER[i];
for (unsigned int i = 0U; i < 10U; 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() bool CWiresX::start()
@ -409,7 +415,7 @@ void CWiresX::sendDXReply()
data[i + 5U] = m_id.at(i); data[i + 5U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; 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++) for (unsigned int i = 0U; i < 14U; i++)
data[i + 20U] = m_name.at(i); data[i + 20U] = m_name.at(i);
@ -464,7 +470,7 @@ void CWiresX::sendConnectReply()
data[i + 5U] = m_id.at(i); data[i + 5U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; 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++) for (unsigned int i = 0U; i < 14U; i++)
data[i + 20U] = m_name.at(i); data[i + 20U] = m_name.at(i);
@ -515,7 +521,7 @@ void CWiresX::sendDisconnectReply()
data[i + 5U] = m_id.at(i); data[i + 5U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; 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++) for (unsigned int i = 0U; i < 14U; i++)
data[i + 20U] = m_name.at(i); data[i + 20U] = m_name.at(i);
@ -556,7 +562,7 @@ void CWiresX::sendAllReply()
data[i + 7U] = m_id.at(i); data[i + 7U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; 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(); unsigned int total = curr.size();
if (total > 999U) total = 999U; if (total > 999U) total = 999U;
@ -625,7 +631,7 @@ void CWiresX::sendSearchReply()
data[i + 7U] = m_id.at(i); data[i + 7U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; 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(); unsigned int total = curr.size();
if (total > 999U) total = 999U; if (total > 999U) total = 999U;

@ -57,6 +57,7 @@ public:
private: private:
std::string m_callsign; std::string m_callsign;
std::string m_node;
CNetwork* m_network; CNetwork* m_network;
CReflectors m_reflectors; CReflectors m_reflectors;
CYSFReflector* m_reflector; CYSFReflector* m_reflector;

Loading…
Cancel
Save