|
|
@ -31,6 +31,7 @@
|
|
|
|
const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU};
|
|
|
|
const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU};
|
|
|
|
const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU};
|
|
|
|
const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU};
|
|
|
|
const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU};
|
|
|
|
const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU};
|
|
|
|
|
|
|
|
const unsigned char DISC_REQ2[] = {0x5DU, 0x63U, 0x5FU};
|
|
|
|
const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU};
|
|
|
|
const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU};
|
|
|
|
const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU};
|
|
|
|
const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU};
|
|
|
|
|
|
|
|
|
|
|
@ -180,7 +181,7 @@ bool CWiresX::start()
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft)
|
|
|
|
WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(data != NULL);
|
|
|
|
assert(data != NULL);
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(source != NULL);
|
|
|
@ -227,6 +228,29 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
|
|
|
if (!valid)
|
|
|
|
if (!valid)
|
|
|
|
return WXS_NONE;
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we are using WiresX Passthrough (we already know we are on a YSF2xxx room from YSFGateway
|
|
|
|
|
|
|
|
if (wiresXCommandPassthrough) {
|
|
|
|
|
|
|
|
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) {
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) {
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
|
|
|
|
|
|
|
processDisconnect(source);
|
|
|
|
|
|
|
|
return WXS_DISCONNECT;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, DISC_REQ2, 3U) == 0) {
|
|
|
|
|
|
|
|
processDisconnect(source);
|
|
|
|
|
|
|
|
return WXS_DISCONNECT;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Origional Code Here
|
|
|
|
|
|
|
|
else {
|
|
|
|
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
|
|
|
|
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
|
|
|
|
processDX(source);
|
|
|
|
processDX(source);
|
|
|
|
return WXS_NONE;
|
|
|
|
return WXS_NONE;
|
|
|
@ -238,6 +262,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
|
|
|
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
|
|
|
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
|
|
|
processDisconnect(source);
|
|
|
|
processDisconnect(source);
|
|
|
|
return WXS_DISCONNECT;
|
|
|
|
return WXS_DISCONNECT;
|
|
|
|
|
|
|
|
} else if (::memcmp(m_command + 1U, DISC_REQ2, 3U) == 0) {
|
|
|
|
|
|
|
|
processDisconnect(source);
|
|
|
|
|
|
|
|
return WXS_DISCONNECT;
|
|
|
|
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
|
|
|
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
|
|
|
processCategory(source, m_command + 5U);
|
|
|
|
processCategory(source, m_command + 5U);
|
|
|
|
return WXS_NONE;
|
|
|
|
return WXS_NONE;
|
|
|
@ -246,6 +273,7 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
|
|
|
return WXS_NONE;
|
|
|
|
return WXS_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return WXS_NONE;
|
|
|
|
return WXS_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -408,11 +436,15 @@ void CWiresX::clock(unsigned int ms)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWiresX::createReply(const unsigned char* data, unsigned int length)
|
|
|
|
void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(data != NULL);
|
|
|
|
assert(data != NULL);
|
|
|
|
assert(length > 0U);
|
|
|
|
assert(length > 0U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we don't explicitly pass a network, use the default one.
|
|
|
|
|
|
|
|
if (network == NULL)
|
|
|
|
|
|
|
|
network = m_network;
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char bt = 0U;
|
|
|
|
unsigned char bt = 0U;
|
|
|
|
|
|
|
|
|
|
|
|
if (length > 260U) {
|
|
|
|
if (length > 260U) {
|
|
|
@ -454,7 +486,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
|
|
|
|
buffer[34U] = seqNo;
|
|
|
|
buffer[34U] = seqNo;
|
|
|
|
seqNo += 2U;
|
|
|
|
seqNo += 2U;
|
|
|
|
|
|
|
|
|
|
|
|
m_network->write(buffer);
|
|
|
|
network->write(buffer);
|
|
|
|
|
|
|
|
|
|
|
|
fich.setFI(YSF_FI_COMMUNICATIONS);
|
|
|
|
fich.setFI(YSF_FI_COMMUNICATIONS);
|
|
|
|
|
|
|
|
|
|
|
@ -501,7 +533,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
|
|
|
|
buffer[34U] = seqNo;
|
|
|
|
buffer[34U] = seqNo;
|
|
|
|
seqNo += 2U;
|
|
|
|
seqNo += 2U;
|
|
|
|
|
|
|
|
|
|
|
|
m_network->write(buffer);
|
|
|
|
network->write(buffer);
|
|
|
|
|
|
|
|
|
|
|
|
fn++;
|
|
|
|
fn++;
|
|
|
|
if (fn >= 8U) {
|
|
|
|
if (fn >= 8U) {
|
|
|
@ -521,7 +553,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
|
|
|
|
|
|
|
|
|
|
|
|
buffer[34U] = seqNo | 0x01U;
|
|
|
|
buffer[34U] = seqNo | 0x01U;
|
|
|
|
|
|
|
|
|
|
|
|
m_network->write(buffer);
|
|
|
|
network->write(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char CWiresX::calculateFT(unsigned int length, unsigned int offset) const
|
|
|
|
unsigned char CWiresX::calculateFT(unsigned int length, unsigned int offset) const
|
|
|
@ -616,6 +648,27 @@ void CWiresX::sendDXReply()
|
|
|
|
m_seqNo++;
|
|
|
|
m_seqNo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CWiresX::sendConnect(CYSFNetwork* network)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned char data[20U];
|
|
|
|
|
|
|
|
::memset(data, 0x00U, 20U);
|
|
|
|
|
|
|
|
::memset(data, ' ', 16U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[0U] = m_seqNo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0U; i < 3U; i++)
|
|
|
|
|
|
|
|
data[i + 1U] = DX_REQ[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[15U] = 0x03U; // End of data marker
|
|
|
|
|
|
|
|
data[16U] = CCRC::addCRC(data, 16U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CUtils::dump(1U, "CONNECT", data, 20U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createReply(data, 20U, network);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_seqNo++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWiresX::sendConnectReply()
|
|
|
|
void CWiresX::sendConnectReply()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(m_reflector != NULL);
|
|
|
|
assert(m_reflector != NULL);
|
|
|
|