mirror of
https://github.com/ShaYmez/MMDVM_CM.git
synced 2024-12-22 01:00:56 -05:00
Add Wires-X categories support
This commit is contained in:
parent
0dd5fee20f
commit
1a1a5f991e
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180729";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180730";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180729";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180729";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -38,6 +38,7 @@ const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU};
|
||||
const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU};
|
||||
const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU};
|
||||
const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU};
|
||||
const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU};
|
||||
|
||||
const unsigned char DX_RESP[] = {0x5DU, 0x51U, 0x5FU, 0x26U};
|
||||
const unsigned char CONN_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
||||
@ -66,7 +67,8 @@ m_csd2(NULL),
|
||||
m_csd3(NULL),
|
||||
m_status(WXSI_NONE),
|
||||
m_start(0U),
|
||||
m_search()
|
||||
m_search(),
|
||||
m_category()
|
||||
{
|
||||
assert(network != NULL);
|
||||
|
||||
@ -249,6 +251,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
||||
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
||||
processDisconnect(source);
|
||||
return WXS_DISCONNECT;
|
||||
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
||||
processCategory(source, m_command + 5U);
|
||||
return WXS_NONE;
|
||||
} else {
|
||||
//CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
|
||||
return WXS_FAIL;
|
||||
@ -298,6 +303,39 @@ void CWiresX::processDX(const unsigned char* source)
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processCategory(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
::LogDebug("Received CATEGORY request from %10.10s", source);
|
||||
|
||||
char buffer[6U];
|
||||
::memcpy(buffer, data + 5U, 2U);
|
||||
buffer[3U] = 0x00U;
|
||||
|
||||
unsigned int len = atoi(buffer);
|
||||
|
||||
if (len == 0U)
|
||||
return;
|
||||
|
||||
if (len > 20U)
|
||||
return;
|
||||
|
||||
m_category.clear();
|
||||
|
||||
for (unsigned int j = 0U; j < len; j++) {
|
||||
::memcpy(buffer, data + 7U + j * 5U, 5U);
|
||||
buffer[5U] = 0x00U;
|
||||
|
||||
unsigned int id = atoi(buffer);
|
||||
|
||||
CTGReg* refl = findById(id);
|
||||
if (refl)
|
||||
m_category.push_back(refl);
|
||||
}
|
||||
|
||||
m_status = WXSI_CATEGORY;
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processAll(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
if (data[0U] == '0' && data[1] == '1') {
|
||||
@ -377,6 +415,9 @@ void CWiresX::clock(unsigned int ms)
|
||||
break;
|
||||
case WXSI_DISCONNECT:
|
||||
break;
|
||||
case WXSI_CATEGORY:
|
||||
sendCategoryReply();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -889,6 +930,16 @@ static bool refComparison(const CTGReg* r1, const CTGReg* r2)
|
||||
return false;
|
||||
}
|
||||
|
||||
CTGReg* CWiresX::findById(unsigned int id)
|
||||
{
|
||||
for (std::vector<CTGReg*>::const_iterator it = m_currTGList.cbegin(); it != m_currTGList.cend(); ++it) {
|
||||
if (id == atoi((*it)->m_id.c_str()))
|
||||
return *it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<CTGReg*>& CWiresX::TGSearch(const std::string& name)
|
||||
{
|
||||
m_TGSearch.clear();
|
||||
@ -950,3 +1001,72 @@ void CWiresX::sendSearchNotFoundReply()
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
||||
void CWiresX::sendCategoryReply()
|
||||
{
|
||||
unsigned char data[1100U];
|
||||
::memset(data, 0x00U, 1100U);
|
||||
|
||||
data[0U] = m_seqNo;
|
||||
|
||||
for (unsigned int i = 0U; i < 4U; i++)
|
||||
data[i + 1U] = ALL_RESP[i];
|
||||
|
||||
data[5U] = '2';
|
||||
data[6U] = '1';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + 7U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 12U] = m_node.at(i);
|
||||
|
||||
unsigned int n = m_category.size();
|
||||
if (n > 20U)
|
||||
n = 20U;
|
||||
|
||||
::sprintf((char*)(data + 22U), "%03u%03u", n, n);
|
||||
|
||||
data[28U] = 0x0DU;
|
||||
|
||||
unsigned int offset = 29U;
|
||||
for (unsigned int j = 0U; j < n; j++, offset += 50U) {
|
||||
CTGReg* tgreg = m_category.at(j);
|
||||
|
||||
::memset(data + offset, ' ', 50U);
|
||||
|
||||
data[offset + 0U] = '5';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + offset + 1U] = tgreg->m_id.at(i + 2U);
|
||||
|
||||
for (unsigned int i = 0U; i < 16U; i++)
|
||||
data[i + offset + 6U] = tgreg->m_name.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 3U; i++)
|
||||
data[i + offset + 22U] = '0';
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + offset + 25U] = ' ';
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + offset + 35U] = tgreg->m_desc.at(i);
|
||||
|
||||
data[offset + 49U] = 0x0DU;
|
||||
}
|
||||
|
||||
unsigned int k = 1029U - offset;
|
||||
for(unsigned int i = 0U; i < k; i++)
|
||||
data[i + offset] = 0x20U;
|
||||
|
||||
offset += k;
|
||||
|
||||
data[offset + 0U] = 0x03U; // End of data marker
|
||||
data[offset + 1U] = CCRC::addCRC(data, offset + 1U);
|
||||
|
||||
//CUtils::dump(1U, "CATEGORY Reply", data, offset + 2U);
|
||||
|
||||
createReply(data, offset + 2U);
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ enum WXSI_STATUS {
|
||||
WXSI_CONNECT,
|
||||
WXSI_DISCONNECT,
|
||||
WXSI_ALL,
|
||||
WXSI_SEARCH
|
||||
WXSI_SEARCH,
|
||||
WXSI_CATEGORY
|
||||
};
|
||||
|
||||
class CTGReg {
|
||||
@ -76,6 +77,7 @@ public:
|
||||
unsigned int getOpt(unsigned int id);
|
||||
unsigned int getFullDstID();
|
||||
|
||||
CTGReg* findById(unsigned int id);
|
||||
std::vector<CTGReg*>& TGSearch(const std::string& name);
|
||||
|
||||
void processConnect(int reflector);
|
||||
@ -107,15 +109,19 @@ private:
|
||||
std::string m_search;
|
||||
std::vector<CTGReg*> m_currTGList;
|
||||
std::vector<CTGReg*> m_TGSearch;
|
||||
std::vector<CTGReg*> m_category;
|
||||
|
||||
WX_STATUS processConnect(const unsigned char* source, const unsigned char* data);
|
||||
void processDX(const unsigned char* source);
|
||||
void processAll(const unsigned char* source, const unsigned char* data);
|
||||
void processCategory(const unsigned char* source, const unsigned char* data);
|
||||
|
||||
void sendDXReply();
|
||||
void sendAllReply();
|
||||
void sendSearchReply();
|
||||
void sendSearchNotFoundReply();
|
||||
void sendCategoryReply();
|
||||
|
||||
void createReply(const unsigned char* data, unsigned int length);
|
||||
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
|
||||
};
|
||||
|
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180729";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -38,6 +38,7 @@ const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU};
|
||||
const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU};
|
||||
const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU};
|
||||
const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU};
|
||||
const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU};
|
||||
|
||||
const unsigned char DX_RESP[] = {0x5DU, 0x51U, 0x5FU, 0x26U};
|
||||
const unsigned char CONN_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
||||
@ -66,7 +67,8 @@ m_csd2(NULL),
|
||||
m_csd3(NULL),
|
||||
m_status(WXSI_NONE),
|
||||
m_start(0U),
|
||||
m_search()
|
||||
m_search(),
|
||||
m_category()
|
||||
{
|
||||
assert(network != NULL);
|
||||
|
||||
@ -247,6 +249,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
||||
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
||||
processDisconnect(source);
|
||||
return WXS_DISCONNECT;
|
||||
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
||||
processCategory(source, m_command + 5U);
|
||||
return WXS_NONE;
|
||||
} else {
|
||||
//CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
|
||||
return WXS_FAIL;
|
||||
@ -269,6 +274,39 @@ void CWiresX::processDX(const unsigned char* source)
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processCategory(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
::LogDebug("Received CATEGORY request from %10.10s", source);
|
||||
|
||||
char buffer[6U];
|
||||
::memcpy(buffer, data + 5U, 2U);
|
||||
buffer[3U] = 0x00U;
|
||||
|
||||
unsigned int len = atoi(buffer);
|
||||
|
||||
if (len == 0U)
|
||||
return;
|
||||
|
||||
if (len > 20U)
|
||||
return;
|
||||
|
||||
m_category.clear();
|
||||
|
||||
for (unsigned int j = 0U; j < len; j++) {
|
||||
::memcpy(buffer, data + 7U + j * 5U, 5U);
|
||||
buffer[5U] = 0x00U;
|
||||
|
||||
unsigned int id = atoi(buffer);
|
||||
|
||||
CTGReg* refl = findById(id);
|
||||
if (refl)
|
||||
m_category.push_back(refl);
|
||||
}
|
||||
|
||||
m_status = WXSI_CATEGORY;
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processAll(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
if (data[0U] == '0' && data[1] == '1') {
|
||||
@ -349,6 +387,9 @@ void CWiresX::clock(unsigned int ms)
|
||||
case WXSI_DISCONNECT:
|
||||
sendDisconnectReply();
|
||||
break;
|
||||
case WXSI_CATEGORY:
|
||||
sendCategoryReply();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -840,6 +881,16 @@ static bool refComparison(const CTGReg* r1, const CTGReg* r2)
|
||||
return false;
|
||||
}
|
||||
|
||||
CTGReg* CWiresX::findById(unsigned int id)
|
||||
{
|
||||
for (std::vector<CTGReg*>::const_iterator it = m_currTGList.cbegin(); it != m_currTGList.cend(); ++it) {
|
||||
if (id == atoi((*it)->m_id.c_str()))
|
||||
return *it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<CTGReg*>& CWiresX::TGSearch(const std::string& name)
|
||||
{
|
||||
m_TGSearch.clear();
|
||||
@ -901,3 +952,72 @@ void CWiresX::sendSearchNotFoundReply()
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
||||
void CWiresX::sendCategoryReply()
|
||||
{
|
||||
unsigned char data[1100U];
|
||||
::memset(data, 0x00U, 1100U);
|
||||
|
||||
data[0U] = m_seqNo;
|
||||
|
||||
for (unsigned int i = 0U; i < 4U; i++)
|
||||
data[i + 1U] = ALL_RESP[i];
|
||||
|
||||
data[5U] = '2';
|
||||
data[6U] = '1';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + 7U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 12U] = m_node.at(i);
|
||||
|
||||
unsigned int n = m_category.size();
|
||||
if (n > 20U)
|
||||
n = 20U;
|
||||
|
||||
::sprintf((char*)(data + 22U), "%03u%03u", n, n);
|
||||
|
||||
data[28U] = 0x0DU;
|
||||
|
||||
unsigned int offset = 29U;
|
||||
for (unsigned int j = 0U; j < n; j++, offset += 50U) {
|
||||
CTGReg* tgreg = m_category.at(j);
|
||||
|
||||
::memset(data + offset, ' ', 50U);
|
||||
|
||||
data[offset + 0U] = '5';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + offset + 1U] = tgreg->m_id.at(i + 2U);
|
||||
|
||||
for (unsigned int i = 0U; i < 16U; i++)
|
||||
data[i + offset + 6U] = tgreg->m_name.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 3U; i++)
|
||||
data[i + offset + 22U] = '0';
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + offset + 25U] = ' ';
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + offset + 35U] = tgreg->m_desc.at(i);
|
||||
|
||||
data[offset + 49U] = 0x0DU;
|
||||
}
|
||||
|
||||
unsigned int k = 1029U - offset;
|
||||
for(unsigned int i = 0U; i < k; i++)
|
||||
data[i + offset] = 0x20U;
|
||||
|
||||
offset += k;
|
||||
|
||||
data[offset + 0U] = 0x03U; // End of data marker
|
||||
data[offset + 1U] = CCRC::addCRC(data, offset + 1U);
|
||||
|
||||
//CUtils::dump(1U, "CATEGORY Reply", data, offset + 2U);
|
||||
|
||||
createReply(data, offset + 2U);
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ enum WXSI_STATUS {
|
||||
WXSI_CONNECT,
|
||||
WXSI_DISCONNECT,
|
||||
WXSI_ALL,
|
||||
WXSI_SEARCH
|
||||
WXSI_SEARCH,
|
||||
WXSI_CATEGORY
|
||||
};
|
||||
|
||||
class CTGReg {
|
||||
@ -71,6 +72,7 @@ public:
|
||||
|
||||
unsigned int getDstID();
|
||||
|
||||
CTGReg* findById(unsigned int id);
|
||||
std::vector<CTGReg*>& TGSearch(const std::string& name);
|
||||
|
||||
void processConnect(int reflector);
|
||||
@ -101,15 +103,19 @@ private:
|
||||
std::string m_search;
|
||||
std::vector<CTGReg*> m_currTGList;
|
||||
std::vector<CTGReg*> m_TGSearch;
|
||||
std::vector<CTGReg*> m_category;
|
||||
|
||||
WX_STATUS processConnect(const unsigned char* source, const unsigned char* data);
|
||||
void processDX(const unsigned char* source);
|
||||
void processAll(const unsigned char* source, const unsigned char* data);
|
||||
void processCategory(const unsigned char* source, const unsigned char* data);
|
||||
|
||||
void sendDXReply();
|
||||
void sendAllReply();
|
||||
void sendSearchReply();
|
||||
void sendSearchNotFoundReply();
|
||||
void sendCategoryReply();
|
||||
|
||||
void createReply(const unsigned char* data, unsigned int length);
|
||||
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
|
||||
};
|
||||
|
@ -20,6 +20,6 @@
|
||||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20180729";
|
||||
const char* VERSION = "20180805";
|
||||
|
||||
#endif
|
||||
|
@ -38,6 +38,7 @@ const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU};
|
||||
const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU};
|
||||
const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU};
|
||||
const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU};
|
||||
const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU};
|
||||
|
||||
const unsigned char DX_RESP[] = {0x5DU, 0x51U, 0x5FU, 0x26U};
|
||||
const unsigned char CONN_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
||||
@ -66,7 +67,8 @@ m_csd2(NULL),
|
||||
m_csd3(NULL),
|
||||
m_status(WXSI_NONE),
|
||||
m_start(0U),
|
||||
m_search()
|
||||
m_search(),
|
||||
m_category()
|
||||
{
|
||||
assert(network != NULL);
|
||||
|
||||
@ -247,6 +249,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
||||
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
|
||||
processDisconnect(source);
|
||||
return WXS_DISCONNECT;
|
||||
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
|
||||
processCategory(source, m_command + 5U);
|
||||
return WXS_NONE;
|
||||
} else {
|
||||
//CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
|
||||
return WXS_FAIL;
|
||||
@ -269,6 +274,39 @@ void CWiresX::processDX(const unsigned char* source)
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processCategory(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
::LogDebug("Received CATEGORY request from %10.10s", source);
|
||||
|
||||
char buffer[6U];
|
||||
::memcpy(buffer, data + 5U, 2U);
|
||||
buffer[3U] = 0x00U;
|
||||
|
||||
unsigned int len = atoi(buffer);
|
||||
|
||||
if (len == 0U)
|
||||
return;
|
||||
|
||||
if (len > 20U)
|
||||
return;
|
||||
|
||||
m_category.clear();
|
||||
|
||||
for (unsigned int j = 0U; j < len; j++) {
|
||||
::memcpy(buffer, data + 7U + j * 5U, 5U);
|
||||
buffer[5U] = 0x00U;
|
||||
|
||||
unsigned int id = atoi(buffer);
|
||||
|
||||
CTGReg* refl = findById(id);
|
||||
if (refl)
|
||||
m_category.push_back(refl);
|
||||
}
|
||||
|
||||
m_status = WXSI_CATEGORY;
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CWiresX::processAll(const unsigned char* source, const unsigned char* data)
|
||||
{
|
||||
if (data[0U] == '0' && data[1] == '1') {
|
||||
@ -349,6 +387,9 @@ void CWiresX::clock(unsigned int ms)
|
||||
case WXSI_DISCONNECT:
|
||||
sendDisconnectReply();
|
||||
break;
|
||||
case WXSI_CATEGORY:
|
||||
sendCategoryReply();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -840,6 +881,16 @@ static bool refComparison(const CTGReg* r1, const CTGReg* r2)
|
||||
return false;
|
||||
}
|
||||
|
||||
CTGReg* CWiresX::findById(unsigned int id)
|
||||
{
|
||||
for (std::vector<CTGReg*>::const_iterator it = m_currTGList.cbegin(); it != m_currTGList.cend(); ++it) {
|
||||
if (id == atoi((*it)->m_id.c_str()))
|
||||
return *it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<CTGReg*>& CWiresX::TGSearch(const std::string& name)
|
||||
{
|
||||
m_TGSearch.clear();
|
||||
@ -901,3 +952,72 @@ void CWiresX::sendSearchNotFoundReply()
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
||||
void CWiresX::sendCategoryReply()
|
||||
{
|
||||
unsigned char data[1100U];
|
||||
::memset(data, 0x00U, 1100U);
|
||||
|
||||
data[0U] = m_seqNo;
|
||||
|
||||
for (unsigned int i = 0U; i < 4U; i++)
|
||||
data[i + 1U] = ALL_RESP[i];
|
||||
|
||||
data[5U] = '2';
|
||||
data[6U] = '1';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + 7U] = m_id.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + 12U] = m_node.at(i);
|
||||
|
||||
unsigned int n = m_category.size();
|
||||
if (n > 20U)
|
||||
n = 20U;
|
||||
|
||||
::sprintf((char*)(data + 22U), "%03u%03u", n, n);
|
||||
|
||||
data[28U] = 0x0DU;
|
||||
|
||||
unsigned int offset = 29U;
|
||||
for (unsigned int j = 0U; j < n; j++, offset += 50U) {
|
||||
CTGReg* tgreg = m_category.at(j);
|
||||
|
||||
::memset(data + offset, ' ', 50U);
|
||||
|
||||
data[offset + 0U] = '5';
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++)
|
||||
data[i + offset + 1U] = tgreg->m_id.at(i + 2U);
|
||||
|
||||
for (unsigned int i = 0U; i < 16U; i++)
|
||||
data[i + offset + 6U] = tgreg->m_name.at(i);
|
||||
|
||||
for (unsigned int i = 0U; i < 3U; i++)
|
||||
data[i + offset + 22U] = '0';
|
||||
|
||||
for (unsigned int i = 0U; i < 10U; i++)
|
||||
data[i + offset + 25U] = ' ';
|
||||
|
||||
for (unsigned int i = 0U; i < 14U; i++)
|
||||
data[i + offset + 35U] = tgreg->m_desc.at(i);
|
||||
|
||||
data[offset + 49U] = 0x0DU;
|
||||
}
|
||||
|
||||
unsigned int k = 1029U - offset;
|
||||
for(unsigned int i = 0U; i < k; i++)
|
||||
data[i + offset] = 0x20U;
|
||||
|
||||
offset += k;
|
||||
|
||||
data[offset + 0U] = 0x03U; // End of data marker
|
||||
data[offset + 1U] = CCRC::addCRC(data, offset + 1U);
|
||||
|
||||
//CUtils::dump(1U, "CATEGORY Reply", data, offset + 2U);
|
||||
|
||||
createReply(data, offset + 2U);
|
||||
|
||||
m_seqNo++;
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ enum WXSI_STATUS {
|
||||
WXSI_CONNECT,
|
||||
WXSI_DISCONNECT,
|
||||
WXSI_ALL,
|
||||
WXSI_SEARCH
|
||||
WXSI_SEARCH,
|
||||
WXSI_CATEGORY
|
||||
};
|
||||
|
||||
class CTGReg {
|
||||
@ -71,6 +72,7 @@ public:
|
||||
|
||||
unsigned int getDstID();
|
||||
|
||||
CTGReg* findById(unsigned int id);
|
||||
std::vector<CTGReg*>& TGSearch(const std::string& name);
|
||||
|
||||
void processConnect(int reflector);
|
||||
@ -101,15 +103,19 @@ private:
|
||||
std::string m_search;
|
||||
std::vector<CTGReg*> m_currTGList;
|
||||
std::vector<CTGReg*> m_TGSearch;
|
||||
std::vector<CTGReg*> m_category;
|
||||
|
||||
WX_STATUS processConnect(const unsigned char* source, const unsigned char* data);
|
||||
void processDX(const unsigned char* source);
|
||||
void processAll(const unsigned char* source, const unsigned char* data);
|
||||
void processCategory(const unsigned char* source, const unsigned char* data);
|
||||
|
||||
void sendDXReply();
|
||||
void sendAllReply();
|
||||
void sendSearchReply();
|
||||
void sendSearchNotFoundReply();
|
||||
void sendCategoryReply();
|
||||
|
||||
void createReply(const unsigned char* data, unsigned int length);
|
||||
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user