mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2025-06-25 04:55:22 -04:00
Fix the NXCore to NXDN network transfer.
This commit is contained in:
parent
788cc74c5f
commit
d0eb3802bc
@ -53,6 +53,42 @@ bool CNXDNNetwork::write(const unsigned char* data, unsigned int length, const i
|
|||||||
return m_socket.write(data, length, address, port);
|
return m_socket.write(data, length, address, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CNXDNNetwork::write(const unsigned char* data, unsigned int length, unsigned short srcId, unsigned short dstId, bool grp, const in_addr& address, unsigned int port)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(length > 0U);
|
||||||
|
assert(port > 0U);
|
||||||
|
|
||||||
|
unsigned char buffer[50U];
|
||||||
|
|
||||||
|
buffer[0U] = 'N';
|
||||||
|
buffer[1U] = 'X';
|
||||||
|
buffer[2U] = 'D';
|
||||||
|
buffer[3U] = 'N';
|
||||||
|
buffer[4U] = 'D';
|
||||||
|
|
||||||
|
buffer[5U] = (srcId >> 8) & 0xFFU;
|
||||||
|
buffer[6U] = (srcId >> 0) & 0xFFU;
|
||||||
|
|
||||||
|
buffer[7U] = (dstId >> 8) & 0xFFU;
|
||||||
|
buffer[8U] = (dstId >> 0) & 0xFFU;
|
||||||
|
|
||||||
|
buffer[9U] = 0x00U;
|
||||||
|
buffer[9U] |= grp ? 0x01U : 0x00U;
|
||||||
|
|
||||||
|
if (data[0U] == 0x81U || data[0U] == 0x83U) {
|
||||||
|
buffer[9U] |= data[5U] == 0x01U ? 0x04U : 0x00U;
|
||||||
|
buffer[9U] |= data[5U] == 0x08U ? 0x08U : 0x00U;
|
||||||
|
}
|
||||||
|
|
||||||
|
::memcpy(buffer + 10U, data, 33U);
|
||||||
|
|
||||||
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "NXDN Network Data Sent", buffer, 43U);
|
||||||
|
|
||||||
|
return m_socket.write(buffer, 43U, address, port);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CNXDNNetwork::read(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port)
|
unsigned int CNXDNNetwork::read(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port)
|
||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
bool open();
|
bool open();
|
||||||
|
|
||||||
bool write(const unsigned char* data, unsigned int length, const in_addr& address, unsigned int port);
|
bool write(const unsigned char* data, unsigned int length, const in_addr& address, unsigned int port);
|
||||||
|
bool write(const unsigned char* data, unsigned int length, unsigned short srcId, unsigned short dstId, bool grp, const in_addr& address, unsigned int port);
|
||||||
|
|
||||||
unsigned int read(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port);
|
unsigned int read(unsigned char* data, unsigned int length, in_addr& address, unsigned int& port);
|
||||||
|
|
||||||
|
@ -194,6 +194,10 @@ void CNXDNReflector::run()
|
|||||||
CNXDNRepeater* current = NULL;
|
CNXDNRepeater* current = NULL;
|
||||||
bool nxCore = false;
|
bool nxCore = false;
|
||||||
|
|
||||||
|
unsigned short srcId = 0U;
|
||||||
|
unsigned short dstId = 0U;
|
||||||
|
bool grp = false;
|
||||||
|
|
||||||
CTimer watchdogTimer(1000U, 0U, 1500U);
|
CTimer watchdogTimer(1000U, 0U, 1500U);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -282,9 +286,10 @@ void CNXDNReflector::run()
|
|||||||
if (current == NULL) {
|
if (current == NULL) {
|
||||||
if (!nxCore) {
|
if (!nxCore) {
|
||||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x01U) {
|
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x01U) {
|
||||||
bool grp = (buffer[7U] & 0x20U) == 0x20U;
|
// Save the grp, src and dest for use in the NXDN Protocol messages
|
||||||
unsigned short srcId = (buffer[8U] << 8) | buffer[9U];
|
grp = (buffer[7U] & 0x20U) == 0x20U;
|
||||||
unsigned short dstId = (buffer[10U] << 8) | buffer[11U];
|
srcId = (buffer[8U] << 8) | buffer[9U];
|
||||||
|
dstId = (buffer[10U] << 8) | buffer[11U];
|
||||||
|
|
||||||
std::string callsign = lookup->find(srcId);
|
std::string callsign = lookup->find(srcId);
|
||||||
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
|
||||||
@ -299,7 +304,7 @@ void CNXDNReflector::run()
|
|||||||
for (std::vector<CNXDNRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
for (std::vector<CNXDNRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||||
in_addr addr = (*it)->m_address;
|
in_addr addr = (*it)->m_address;
|
||||||
unsigned int prt = (*it)->m_port;
|
unsigned int prt = (*it)->m_port;
|
||||||
nxdnNetwork.write(buffer, len, addr, prt);
|
nxdnNetwork.write(buffer, len, srcId, dstId, grp, addr, prt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x08U) {
|
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x08U) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user