Handle Icom format data transmissions as well as the data bit in my

system.
This commit is contained in:
Jonathan Naylor 2018-05-17 20:32:00 +01:00
parent d60bdc3d6d
commit 56bf6a9aff
6 changed files with 61 additions and 9 deletions

View File

@ -62,9 +62,15 @@ bool CIcomNetwork::write(const unsigned char* data, unsigned int length, const i
buffer[6U] = 0x08U;
buffer[7U] = 0xE0U;
buffer[37U] = 0x23U;
buffer[38U] = (data[0U] == 0x81U || data[0U] == 0x83U) ? 0x1CU : 0x10U;
buffer[39U] = 0x21U;
if ((data[0U] & 0xF0U) == 0x90U) {
buffer[37U] = 0x23U;
buffer[38U] = 0x02U;
buffer[39U] = 0x18U;
} else {
buffer[37U] = 0x23U;
buffer[38U] = (data[0U] == 0x81U || data[0U] == 0x83U) ? 0x1CU : 0x10U;
buffer[39U] = 0x21U;
}
::memcpy(buffer + 40U, data, length);

View File

@ -270,7 +270,7 @@ void CNXDNGateway::run()
// From the MMDVM to the reflector or control data
len = localNetwork.read(buffer, address, port);
if (len > 0U) {
// Only process the beginning and ending blocks here
// Only process the beginning and ending voice blocks here
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && (buffer[5U] == 0x01U || buffer[5U] == 0x08U)) {
grp = (buffer[7U] & 0x20U) == 0x20U;
@ -328,8 +328,8 @@ void CNXDNGateway::run()
}
}
// If it's the end of the transmission, start the voice
if (buffer[5U] == 0x08U) {
// If it's the end of the voice transmission, start the voice prompt
if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x08U) {
if (voice != NULL)
voice->eof();
}

View File

@ -67,8 +67,17 @@ bool CNXDNNetwork::writeData(const unsigned char* data, unsigned int length, uns
buffer[9U] |= grp ? 0x01U : 0x00U;
if (data[0U] == 0x81U || data[0U] == 0x83U) {
// This is a voice header or trailer.
buffer[9U] |= data[5U] == 0x01U ? 0x04U : 0x00U;
buffer[9U] |= data[5U] == 0x08U ? 0x08U : 0x00U;
} else if ((data[0U] & 0xF0U) == 0x90U) {
// This if data.
buffer[9U] |= 0x02U;
if (data[0U] == 0x90U || data[0U] == 0x92U || data[0U] == 0x9CU || data[0U] == 0x9EU) {
// This is data header or trailer.
buffer[9U] |= data[2U] == 0x09U ? 0x04U : 0x00U;
buffer[9U] |= data[2U] == 0x08U ? 0x08U : 0x00U;
}
}
::memcpy(buffer + 10U, data, 33U);

View File

@ -68,9 +68,15 @@ bool CNXCoreNetwork::write(const unsigned char* data, unsigned int len)
buffer[6U] = 0x08U;
buffer[7U] = 0xE0U;
buffer[37U] = 0x23U;
buffer[38U] = (data[9U] & 0x0CU) != 0x00U ? 0x1CU : 0x10U;
buffer[39U] = 0x21U;
if ((data[9U] & 0x02U) == 0x02U) {
buffer[37U] = 0x23U;
buffer[38U] = 0x02U;
buffer[39U] = 0x18U;
} else {
buffer[37U] = 0x23U;
buffer[38U] = (data[9U] & 0x0CU) != 0x00U ? 0x1CU : 0x10U;
buffer[39U] = 0x21U;
}
::memcpy(buffer + 40U, data + 10U, 33U);

View File

@ -77,8 +77,17 @@ bool CNXDNNetwork::write(const unsigned char* data, unsigned int length, unsigne
buffer[9U] |= grp ? 0x01U : 0x00U;
if (data[0U] == 0x81U || data[0U] == 0x83U) {
// This is a voice header or trailer.
buffer[9U] |= data[5U] == 0x01U ? 0x04U : 0x00U;
buffer[9U] |= data[5U] == 0x08U ? 0x08U : 0x00U;
} else if ((data[0U] & 0xF0U) == 0x90U) {
// This if data.
buffer[9U] |= 0x02U;
if (data[0U] == 0x90U || data[0U] == 0x92U || data[0U] == 0x9CU || data[0U] == 0x9EU) {
// This is data header or trailer.
buffer[9U] |= data[2U] == 0x09U ? 0x04U : 0x00U;
buffer[9U] |= data[2U] == 0x08U ? 0x08U : 0x00U;
}
}
::memcpy(buffer + 10U, data, 33U);

View File

@ -326,6 +326,23 @@ void CNXDNReflector::run()
std::string callsign = lookup->find(srcId);
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
nxCoreActive = true;
}
}
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x09U) {
bool tempGrp = (buffer[4U] & 0x20U) == 0x20U;
unsigned short tempSrcId = (buffer[5U] << 8) | buffer[6U];
unsigned short tempDstId = (buffer[7U] << 8) | buffer[8U];
if (tempGrp && tempDstId == tg) {
// Save the grp, src and dest for use in the NXDN Protocol messages
grp = tempGrp;
srcId = tempSrcId;
dstId = tempDstId;
std::string callsign = lookup->find(srcId);
LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId);
nxCoreActive = true;
}
}
@ -345,6 +362,11 @@ void CNXDNReflector::run()
nxCoreActive = false;
watchdogTimer.stop();
}
if ((buffer[0U] & 0xF0U) == 0x90U && buffer[2U] == 0x08U) {
LogMessage("Received end of transmission");
nxCoreActive = false;
watchdogTimer.stop();
}
}
}
}