From 9d6bcb7ec880d8b8a97e4b9383724e57f31948fb Mon Sep 17 00:00:00 2001 From: KD4Z Date: Tue, 10 Apr 2018 18:08:48 -0400 Subject: [PATCH] Fix dashboard conflict, add IP address to D-Star screen Tag: Version "v20180328.3z" --- DMRLookup.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++----- DMRLookup.h | 1 + DMRSlot.cpp | 6 +++--- OLED.cpp | 17 ++++++++++------- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/DMRLookup.cpp b/DMRLookup.cpp index d41df5d..8842a60 100644 --- a/DMRLookup.cpp +++ b/DMRLookup.cpp @@ -81,7 +81,7 @@ void CDMRLookup::stop() wait(); } -std::string CDMRLookup::find(unsigned int id) +std::string CDMRLookup::findwithname(unsigned int id) { std::string callsign; @@ -92,6 +92,40 @@ std::string CDMRLookup::find(unsigned int id) try { callsign = m_table.at(id); + LogDebug("Findwithname Found =%s",callsign.c_str()); + + } catch (...) { + char text[10U]; + ::sprintf(text, "%u", id); + callsign = std::string(text); + } + + m_mutex.unlock(); + + return callsign; +} +std::string CDMRLookup::find(unsigned int id) +{ + std::string callsign; + std::string b; + + + if (id == 0xFFFFFFU) + return std::string("ALL"); + + m_mutex.lock(); + + try { + b = m_table.at(id); + size_t n = b.find(" "); + if (n > 0) { + callsign = b.substr(0,n); + + } else { + LogDebug("b=%s",b.c_str()); + callsign = b; + } + } catch (...) { char text[10U]; ::sprintf(text, "%u", id); @@ -133,13 +167,19 @@ bool CDMRLookup::load() continue; char* p1 = ::strtok(buffer, " \t\r\n"); - char* p2 = ::strtok(NULL, " \t\r\n"); + char* p2 = ::strtok(NULL, " \r\n"); // tokenize to eol to capture name as well if (p1 != NULL && p2 != NULL) { unsigned int id = (unsigned int)::atoi(p1); - for (char* p = p2; *p != 0x00U; p++) - *p = ::toupper(*p); - + for (char* p = p2; *p != 0x00U; p++) { + + if(*p == 0x09U) + *p = 0x20U; + + else + *p = ::toupper(*p); + + } m_table[id] = std::string(p2); } } diff --git a/DMRLookup.h b/DMRLookup.h index ed09ac2..54b78e7 100644 --- a/DMRLookup.h +++ b/DMRLookup.h @@ -35,6 +35,7 @@ public: virtual void entry(); std::string find(unsigned int id); + std::string findwithname(unsigned int id); bool exists(unsigned int id); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 001c6f4..913a97f 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -1067,16 +1067,16 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) m_netState = RS_NET_AUDIO; setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE); - std::string src = m_lookup->find(srcId); std::string dst = m_lookup->find(dstId); - - m_display->writeDMR(m_slotNo, src, flco == FLCO_GROUP, dst, "N"); + std::string cn = m_lookup->findwithname(srcId); + m_display->writeDMR(m_slotNo, cn, flco == FLCO_GROUP, dst, "N"); #if defined(DUMP_DMR) openFile(); writeFile(data); #endif + LogMessage("DMR Slot %u, received network voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); } else if (dataType == DT_VOICE_PI_HEADER) { if (m_netState != RS_NET_AUDIO) { diff --git a/OLED.cpp b/OLED.cpp index 047f2e3..eeef003 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -180,7 +180,7 @@ void COLED::setIdleInt() networkInfoInitialized = false; if (! networkInfoInitialized) { - LogMessage("Initialize CNetworkInfo"); + //LogMessage("Initialize CNetworkInfo"); info[0]=0; m_network = new CNetworkInfo; m_network->getNetworkInterface(info); @@ -228,14 +228,17 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co display.clearDisplay(); display.fillRect(0,OLED_LINE3,display.width(),display.height(),BLACK); //clear everything beneath logo - display.setCursor(0,OLED_LINE4); + display.setCursor(0,OLED_LINE3); display.printf("%s %.8s/%4.4s",type,my1,my2); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE4); display.printf("-> %.8s",your); - display.setCursor(0,OLED_LINE6); + display.setCursor(0,OLED_LINE5); display.printf("via %.8s",reflector); + + display.setCursor(0,OLED_LINE6); + display.printf("%s",m_ipaddress.c_str()); OLED_statusbar(); display.display(); @@ -271,7 +274,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE2); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE3); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } else { @@ -279,7 +282,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE4); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE5); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } } @@ -289,7 +292,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE3); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE4); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } display.fillRect(0,OLED_LINE6,display.width(),20,BLACK);