1
0
Fork 0

Add Wires-X DX Request to any network.

ycs232-kbc
Jonathan Naylor 6 years ago
parent baed7d67e2
commit bee173f9e3

@ -429,11 +429,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(length > 0U);
// If we don't explicitly pass a network, use the default one.
if (network == NULL)
network = m_network;
unsigned char bt = 0U;
if (length > 260U) {
@ -475,7 +479,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
buffer[34U] = seqNo;
seqNo += 2U;
m_network->write(buffer);
network->write(buffer);
fich.setFI(YSF_FI_COMMUNICATIONS);
@ -522,7 +526,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
buffer[34U] = seqNo;
seqNo += 2U;
m_network->write(buffer);
network->write(buffer);
fn++;
if (fn >= 8U) {
@ -542,7 +546,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length)
buffer[34U] = seqNo | 0x01U;
m_network->write(buffer);
network->write(buffer);
}
unsigned char CWiresX::calculateFT(unsigned int length, unsigned int offset) const
@ -637,6 +641,27 @@ void CWiresX::sendDXReply()
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()
{
assert(m_reflector != NULL);

@ -64,6 +64,8 @@ public:
void processConnect(CYSFReflector* reflector);
void processDisconnect(const unsigned char* source = NULL);
void sendConnect(CYSFNetwork* network);
void clock(unsigned int ms);
private:
@ -102,7 +104,7 @@ private:
void sendSearchNotFoundReply();
void sendCategoryReply();
void createReply(const unsigned char* data, unsigned int length);
void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = NULL);
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
};

Loading…
Cancel
Save