Revert "Simplify the logic by removing the ring buffer."
This reverts commit baef6c962e
.
This commit is contained in:
parent
baef6c962e
commit
d4d26fc05f
|
@ -51,6 +51,7 @@ m_timeoutTimer(1000U, 60U),
|
||||||
m_buffer(NULL),
|
m_buffer(NULL),
|
||||||
m_salt(NULL),
|
m_salt(NULL),
|
||||||
m_streamId(NULL),
|
m_streamId(NULL),
|
||||||
|
m_rxData(1000U, "DMR Network"),
|
||||||
m_options(),
|
m_options(),
|
||||||
m_callsign(),
|
m_callsign(),
|
||||||
m_rxFrequency(0U),
|
m_rxFrequency(0U),
|
||||||
|
@ -147,6 +148,35 @@ bool CDMRNetwork::read(CDMRData& data)
|
||||||
if (m_status != RUNNING)
|
if (m_status != RUNNING)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!m_rxData.isEmpty()) {
|
||||||
|
unsigned char length = 0U;
|
||||||
|
|
||||||
|
m_rxData.getData(&length, 1U);
|
||||||
|
m_rxData.getData(m_buffer, length);
|
||||||
|
|
||||||
|
// Is this a data packet?
|
||||||
|
if (::memcmp(m_buffer, "DMRD", 4U) == 0) {
|
||||||
|
unsigned int slotNo = (m_buffer[15U] & 0x80U) == 0x80U ? 2U : 1U;
|
||||||
|
|
||||||
|
bool wanted = true;
|
||||||
|
|
||||||
|
// DMO mode slot disabling
|
||||||
|
if (slotNo == 1U && !m_duplex)
|
||||||
|
wanted = false;
|
||||||
|
|
||||||
|
// Individual slot disabling
|
||||||
|
if (slotNo == 1U && !m_slot1)
|
||||||
|
wanted = false;
|
||||||
|
if (slotNo == 2U && !m_slot2)
|
||||||
|
wanted = false;
|
||||||
|
|
||||||
|
if (wanted) {
|
||||||
|
unsigned char seqNo = m_buffer[4U];
|
||||||
|
m_jitterBuffers[slotNo]->addData(m_buffer, length, seqNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned int slotNo = 1U; slotNo <= 2U; slotNo++) {
|
for (unsigned int slotNo = 1U; slotNo <= 2U; slotNo++) {
|
||||||
unsigned int length = 0U;
|
unsigned int length = 0U;
|
||||||
JB_STATUS status = m_jitterBuffers[slotNo]->getData(m_buffer, length);
|
JB_STATUS status = m_jitterBuffers[slotNo]->getData(m_buffer, length);
|
||||||
|
@ -373,7 +403,10 @@ void CDMRNetwork::clock(unsigned int ms)
|
||||||
if (m_enabled) {
|
if (m_enabled) {
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
CUtils::dump(1U, "Network Received", m_buffer, length);
|
CUtils::dump(1U, "Network Received", m_buffer, length);
|
||||||
receiveData(m_buffer, length);
|
|
||||||
|
unsigned char len = length;
|
||||||
|
m_rxData.addData(&len, 1U);
|
||||||
|
m_rxData.addData(m_buffer, len);
|
||||||
}
|
}
|
||||||
} else if (::memcmp(m_buffer, "MSTNAK", 6U) == 0) {
|
} else if (::memcmp(m_buffer, "MSTNAK", 6U) == 0) {
|
||||||
if (m_status == RUNNING) {
|
if (m_status == RUNNING) {
|
||||||
|
@ -481,25 +514,6 @@ void CDMRNetwork::reset(unsigned int slotNo)
|
||||||
m_jitterBuffers[slotNo]->reset();
|
m_jitterBuffers[slotNo]->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDMRNetwork::receiveData(const unsigned char* data, unsigned int length)
|
|
||||||
{
|
|
||||||
unsigned int slotNo = (m_buffer[15U] & 0x80U) == 0x80U ? 2U : 1U;
|
|
||||||
|
|
||||||
// DMO mode slot disabling
|
|
||||||
if (slotNo == 1U && !m_duplex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Individual slot disabling
|
|
||||||
if (slotNo == 1U && !m_slot1)
|
|
||||||
return;
|
|
||||||
if (slotNo == 2U && !m_slot2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
unsigned char seqNo = m_buffer[4U];
|
|
||||||
|
|
||||||
m_jitterBuffers[slotNo]->addData(m_buffer, length, seqNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CDMRNetwork::writeLogin()
|
bool CDMRNetwork::writeLogin()
|
||||||
{
|
{
|
||||||
unsigned char buffer[8U];
|
unsigned char buffer[8U];
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "JitterBuffer.h"
|
#include "JitterBuffer.h"
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
#include "RingBuffer.h"
|
||||||
#include "DMRData.h"
|
#include "DMRData.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
|
|
||||||
|
@ -89,6 +90,8 @@ private:
|
||||||
unsigned char* m_salt;
|
unsigned char* m_salt;
|
||||||
uint32_t* m_streamId;
|
uint32_t* m_streamId;
|
||||||
|
|
||||||
|
CRingBuffer<unsigned char> m_rxData;
|
||||||
|
|
||||||
std::string m_options;
|
std::string m_options;
|
||||||
|
|
||||||
std::string m_callsign;
|
std::string m_callsign;
|
||||||
|
@ -112,8 +115,6 @@ private:
|
||||||
bool writePing();
|
bool writePing();
|
||||||
|
|
||||||
bool write(const unsigned char* data, unsigned int length);
|
bool write(const unsigned char* data, unsigned int length);
|
||||||
|
|
||||||
void receiveData(const unsigned char* data, unsigned int length);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue