use UserDBentry from findWithName() to writeDMR(), add writeDMREx()
This commit is contained in:
parent
abf17e19fc
commit
4ff77c50d6
|
@ -80,28 +80,27 @@ void CDMRLookup::stop()
|
|||
wait();
|
||||
}
|
||||
|
||||
std::string CDMRLookup::findWithName(unsigned int id)
|
||||
void CDMRLookup::findWithName(unsigned int id, class CUserDBentry *entry)
|
||||
{
|
||||
std::string callsign;
|
||||
|
||||
if (id == 0xFFFFFFU)
|
||||
return std::string("ALL");
|
||||
|
||||
class CUserDBentry entry;
|
||||
if (m_table.lookup(id, &entry)) {
|
||||
// callsign is always available
|
||||
callsign = entry.get(keyCALLSIGN);
|
||||
if (!entry.get(keyFIRST_NAME).empty())
|
||||
callsign += " " + entry.get(keyFIRST_NAME);
|
||||
|
||||
LogDebug("FindWithName =%s",callsign.c_str());
|
||||
} else {
|
||||
char text[10U];
|
||||
::snprintf(text, sizeof(text), "%u", id);
|
||||
callsign = std::string(text);
|
||||
if (id == 0xFFFFFFU) {
|
||||
entry->clear();
|
||||
entry->set(keyCALLSIGN, "ALL");
|
||||
return;
|
||||
}
|
||||
|
||||
return callsign;
|
||||
if (m_table.lookup(id, entry)) {
|
||||
LogDebug("FindWithName =%s %s", entry->get(keyCALLSIGN).c_str(), entry->get(keyFIRST_NAME).c_str());
|
||||
} else {
|
||||
entry->clear();
|
||||
|
||||
char text[10U];
|
||||
::snprintf(text, sizeof(text), "%u", id);
|
||||
entry->set(keyCALLSIGN, text);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
std::string CDMRLookup::find(unsigned int id)
|
||||
{
|
||||
|
|
16
DMRLookup.h
16
DMRLookup.h
|
@ -20,10 +20,9 @@
|
|||
#define DMRLookup_H
|
||||
|
||||
#include "Thread.h"
|
||||
#include "Mutex.h"
|
||||
#include "UserDB.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class CDMRLookup : public CThread {
|
||||
public:
|
||||
|
@ -35,20 +34,17 @@ public:
|
|||
virtual void entry();
|
||||
|
||||
std::string find(unsigned int id);
|
||||
std::string findWithName(unsigned int id);
|
||||
void findWithName(unsigned int id, class CUserDBentry *entry);
|
||||
|
||||
bool exists(unsigned int id);
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
std::string m_filename;
|
||||
unsigned int m_reloadTime;
|
||||
std::unordered_map<unsigned int, std::string> m_table;
|
||||
CMutex m_mutex;
|
||||
bool m_stop;
|
||||
|
||||
bool load();
|
||||
std::string m_filename;
|
||||
unsigned int m_reloadTime;
|
||||
class CUserDB m_table;
|
||||
bool m_stop;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1108,7 +1108,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE);
|
||||
std::string src = m_lookup->find(srcId);
|
||||
std::string dst = m_lookup->find(dstId);
|
||||
std::string cn = m_lookup->findWithName(srcId);
|
||||
class CUserDBentry cn;
|
||||
m_lookup->findWithName(srcId, &cn);
|
||||
m_display->writeDMR(m_slotNo, cn, flco == FLCO_GROUP, dst, "N");
|
||||
|
||||
#if defined(DUMP_DMR)
|
||||
|
@ -1177,7 +1178,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
setShortLC(m_slotNo, dstId, m_netLC->getFLCO(), ACTIVITY_VOICE);
|
||||
std::string src = m_lookup->find(srcId);
|
||||
std::string dst = m_lookup->find(dstId);
|
||||
std::string cn = m_lookup->findWithName(srcId);
|
||||
class CUserDBentry cn;
|
||||
m_lookup->findWithName(srcId, &cn);
|
||||
|
||||
m_display->writeDMR(m_slotNo, cn, m_netLC->getFLCO() == FLCO_GROUP, dst, "N");
|
||||
|
||||
|
@ -1373,7 +1375,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
|
||||
std::string src = m_lookup->find(srcId);
|
||||
std::string dst = m_lookup->find(dstId);
|
||||
std::string cn = m_lookup->findWithName(srcId);
|
||||
class CUserDBentry cn;
|
||||
m_lookup->findWithName(srcId, &cn);
|
||||
|
||||
m_display->writeDMR(m_slotNo, cn, m_netLC->getFLCO() == FLCO_GROUP, dst, "N");
|
||||
|
||||
|
|
27
Display.cpp
27
Display.cpp
|
@ -151,6 +151,28 @@ void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group,
|
|||
writeDMRInt(slotNo, src, group, dst, type);
|
||||
}
|
||||
|
||||
void CDisplay::writeDMR(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type)
|
||||
{
|
||||
assert(type != NULL);
|
||||
|
||||
if (slotNo == 1U) {
|
||||
m_timer1.start();
|
||||
m_mode1 = MODE_IDLE;
|
||||
} else {
|
||||
m_timer2.start();
|
||||
m_mode2 = MODE_IDLE;
|
||||
}
|
||||
|
||||
if (writeDMRIntEx(slotNo, src, group, dst, type) < 0) {
|
||||
std::string src_str;
|
||||
|
||||
src_str = src.get(keyCALLSIGN);
|
||||
if (!src.get(keyFIRST_NAME).empty())
|
||||
src_str += " " + src.get(keyFIRST_NAME);
|
||||
writeDMRInt(slotNo, src_str, group, dst, type);
|
||||
}
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRRSSI(unsigned int slotNo, unsigned char rssi)
|
||||
{
|
||||
if (rssi != 0U)
|
||||
|
@ -386,6 +408,11 @@ void CDisplay::writeDStarBERInt(float ber)
|
|||
{
|
||||
}
|
||||
|
||||
int CDisplay::writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type)
|
||||
{
|
||||
return -1; // not supported
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define DISPLAY_H
|
||||
|
||||
#include "Timer.h"
|
||||
#include "UserDBentry.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -48,6 +49,7 @@ public:
|
|||
void clearDStar();
|
||||
|
||||
void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
|
||||
void writeDMR(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type);
|
||||
void writeDMRRSSI(unsigned int slotNo, unsigned char rssi);
|
||||
void writeDMRBER(unsigned int slotNo, float ber);
|
||||
void writeDMRTA(unsigned int slotNo, unsigned char* talkerAlias, const char* type);
|
||||
|
@ -91,6 +93,7 @@ protected:
|
|||
virtual void clearDStarInt() = 0;
|
||||
|
||||
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
|
||||
virtual int writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type);
|
||||
virtual void writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi);
|
||||
virtual void writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type);
|
||||
virtual void writeDMRBERInt(unsigned int slotNo, float ber);
|
||||
|
|
Loading…
Reference in New Issue