commit
4430294fc5
37
DMRSlot.cpp
37
DMRSlot.cpp
|
@ -77,6 +77,7 @@ m_rfEmbeddedData(NULL),
|
|||
m_rfEmbeddedReadN(0U),
|
||||
m_rfEmbeddedWriteN(1U),
|
||||
m_rfTalkerId(TALKER_ID_NONE),
|
||||
m_rfTalkerAlias(NULL),
|
||||
m_netEmbeddedLC(),
|
||||
m_netEmbeddedData(NULL),
|
||||
m_netEmbeddedReadN(0U),
|
||||
|
@ -113,6 +114,7 @@ m_aveRSSI(0U),
|
|||
m_rssiCount(0U),
|
||||
m_fp(NULL)
|
||||
{
|
||||
m_rfTalkerAlias = new unsigned char[32]; //TA max length is 31 chars
|
||||
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];
|
||||
|
||||
m_rfEmbeddedData = new CDMREmbeddedData[2U];
|
||||
|
@ -331,7 +333,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
LogMessage("DMR Slot %u, received RF end of voice transmission, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
else
|
||||
LogMessage("DMR Slot %u, received RF end of voice transmission, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
|
||||
m_display->writeDMRTA(m_slotNo,NULL," ");
|
||||
if (m_rfTimeout) {
|
||||
writeEndRF();
|
||||
return false;
|
||||
|
@ -590,7 +592,6 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
bool ret = m_rfEmbeddedData[m_rfEmbeddedWriteN].addData(data + 2U, lcss);
|
||||
if (ret) {
|
||||
FLCO flco = m_rfEmbeddedData[m_rfEmbeddedWriteN].getFLCO();
|
||||
|
||||
unsigned char data[9U];
|
||||
m_rfEmbeddedData[m_rfEmbeddedWriteN].getRawData(data);
|
||||
|
||||
|
@ -616,6 +617,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 0U, data);
|
||||
|
||||
if (!(m_rfTalkerId & TALKER_ID_HEADER)) {
|
||||
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias, data, 6);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");
|
||||
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Header", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -630,6 +635,11 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 1U, data);
|
||||
|
||||
if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) {
|
||||
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
|
||||
::memcpy(m_rfTalkerAlias+6, data, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");
|
||||
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 1", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -644,12 +654,16 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 2U, data);
|
||||
|
||||
if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) {
|
||||
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
m_rfTalkerId |= TALKER_ID_BLOCK2;
|
||||
::memcpy(m_rfTalkerAlias+6+7, data, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");
|
||||
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 2", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
}
|
||||
|
||||
m_rfTalkerId |= TALKER_ID_BLOCK2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -658,6 +672,9 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
|||
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 3U, data);
|
||||
|
||||
if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) {
|
||||
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias+6+7+7, data, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 3", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -1170,7 +1187,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
// We've received the voice header and terminator haven't we?
|
||||
m_netFrames += 2U;
|
||||
LogMessage("DMR Slot %u, received network end of voice transmission, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
|
||||
|
||||
m_display->writeDMRTA(m_slotNo,NULL," ");
|
||||
writeEndNet();
|
||||
} else if (dataType == DT_DATA_HEADER) {
|
||||
if (m_netState == RS_NET_DATA)
|
||||
|
@ -1381,6 +1398,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
break;
|
||||
case FLCO_TALKER_ALIAS_HEADER:
|
||||
if (!(m_netTalkerId & TALKER_ID_HEADER)) {
|
||||
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias, data+2, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Header", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -1391,6 +1411,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
break;
|
||||
case FLCO_TALKER_ALIAS_BLOCK1:
|
||||
if (!(m_netTalkerId & TALKER_ID_BLOCK1)) {
|
||||
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias+7, data+2, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 1", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -1401,6 +1424,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
break;
|
||||
case FLCO_TALKER_ALIAS_BLOCK2:
|
||||
if (!(m_netTalkerId & TALKER_ID_BLOCK2)) {
|
||||
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias+7+7, data+2, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 2", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
@ -1411,6 +1437,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
|||
break;
|
||||
case FLCO_TALKER_ALIAS_BLOCK3:
|
||||
if (!(m_netTalkerId & TALKER_ID_BLOCK3)) {
|
||||
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
|
||||
::memcpy(m_rfTalkerAlias+7+7+7, data+2, 7);
|
||||
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
|
||||
if (m_dumpTAData) {
|
||||
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 3", m_slotNo);
|
||||
CUtils::dump(2U, text, data, 9U);
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
unsigned int m_rfEmbeddedReadN;
|
||||
unsigned int m_rfEmbeddedWriteN;
|
||||
unsigned char m_rfTalkerId;
|
||||
unsigned char* m_rfTalkerAlias;
|
||||
CDMREmbeddedData m_netEmbeddedLC;
|
||||
CDMREmbeddedData* m_netEmbeddedData;
|
||||
unsigned int m_netEmbeddedReadN;
|
||||
|
|
47
Display.cpp
47
Display.cpp
|
@ -18,14 +18,15 @@
|
|||
|
||||
#include "Display.h"
|
||||
#include "Defines.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
CDisplay::CDisplay() :
|
||||
m_timer1(1000U, 3U),
|
||||
m_timer2(1000U, 3U),
|
||||
m_timer1(3000U, 3U),
|
||||
m_timer2(3000U, 3U),
|
||||
m_mode1(MODE_IDLE),
|
||||
m_mode2(MODE_IDLE)
|
||||
{
|
||||
|
@ -117,7 +118,6 @@ void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group,
|
|||
m_timer2.start();
|
||||
m_mode2 = MODE_IDLE;
|
||||
}
|
||||
|
||||
writeDMRInt(slotNo, src, group, dst, type);
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,46 @@ void CDisplay::writeDMRRSSI(unsigned int slotNo, unsigned char rssi)
|
|||
writeDMRRSSIInt(slotNo, rssi);
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRTA(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
||||
{
|
||||
unsigned char format;
|
||||
char TA[32];
|
||||
int i,j;
|
||||
|
||||
if (strcmp(type," ")==0) { writeDMRTAInt(slotNo, (unsigned char*)TA, type); return; }
|
||||
|
||||
|
||||
format=talkerAlias[0]>>6;
|
||||
strcpy(TA,"(could not decode)");
|
||||
switch (format) {
|
||||
case 0: // 7 bit
|
||||
break;
|
||||
case 1: // ISO 8 bit
|
||||
case 2: // UTF8
|
||||
strcpy(TA,(char*)talkerAlias+1);
|
||||
break;
|
||||
case 3: // UTF16
|
||||
j=0;
|
||||
memset (&TA,0,32);
|
||||
for(i=0;i<15;i++) {
|
||||
if (talkerAlias[2*i+1]==0)
|
||||
TA[j++]=talkerAlias[2*i+2]; else TA[j++]='?';
|
||||
}
|
||||
TA[j]=0;
|
||||
break;
|
||||
}
|
||||
i=strlen(TA);
|
||||
j=(talkerAlias[0]&0x3F)>>1;
|
||||
LogMessage("DMR Talker Alias (Data Format %u, Received %d/%d char): '%s'", format, i, j, TA);
|
||||
if (i>j) { if (strlen(TA)<29) strcat(TA," ?"); else strcpy(TA+28," ?"); }
|
||||
if (strlen((char*)TA)>4) writeDMRTAInt(slotNo, (unsigned char*)TA, type);
|
||||
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRBER(unsigned int slotNo, float ber)
|
||||
{
|
||||
writeDMRBERInt(slotNo, ber);
|
||||
}
|
||||
|
||||
void CDisplay::clearDMR(unsigned int slotNo)
|
||||
{
|
||||
if (slotNo == 1U) {
|
||||
|
@ -293,6 +328,10 @@ void CDisplay::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
|||
{
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
||||
{
|
||||
}
|
||||
|
||||
void CDisplay::writeDMRBERInt(unsigned int slotNo, float ber)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
void writeDMR(unsigned int slotNo, const std::string& 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);
|
||||
void clearDMR(unsigned int slotNo);
|
||||
|
||||
void writeFusion(const char* source, const char* dest, const char* type, const char* origin);
|
||||
|
@ -74,6 +75,7 @@ protected:
|
|||
|
||||
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
|
||||
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);
|
||||
virtual void clearDMRInt(unsigned int slotNo) = 0;
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ LDFLAGS = -g
|
|||
OBJECTS = \
|
||||
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o \
|
||||
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
|
||||
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
|
||||
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o Network.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
|
||||
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
|
||||
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
|
|
114
Network.cpp
Normal file
114
Network.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2017 by Lieven De Samblanx ON7LDS
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Network.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <clocale>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
|
||||
void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
||||
{
|
||||
#define IFLISTSIZ 25
|
||||
|
||||
LogInfo("Interfaces Info");
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int family, s, n, ifnr;
|
||||
char host[NI_MAXHOST];
|
||||
char interfacelist[IFLISTSIZ][50+INET6_ADDRSTRLEN];
|
||||
char *dflt, *p;
|
||||
FILE *f;
|
||||
char line[100];
|
||||
|
||||
dflt=NULL;
|
||||
f = fopen("/proc/net/route" , "r");
|
||||
|
||||
while(fgets(line , 100 , f))
|
||||
{
|
||||
dflt = strtok(line , " \t");
|
||||
p = strtok(NULL , " \t");
|
||||
|
||||
if(dflt!=NULL && p!=NULL)
|
||||
{
|
||||
if(strcmp(p , "00000000") == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(n=0;n<IFLISTSIZ;n++) {
|
||||
interfacelist[n][0]=0;
|
||||
}
|
||||
ifnr=0;
|
||||
if (getifaddrs(&ifaddr) == -1) {
|
||||
strcpy((char*)info,"getifaddrs failure");
|
||||
} else {
|
||||
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
family = ifa->ifa_addr->sa_family;
|
||||
if (family == AF_INET || family == AF_INET6) {
|
||||
s = getnameinfo(ifa->ifa_addr,
|
||||
(family == AF_INET) ? sizeof(struct sockaddr_in) :
|
||||
sizeof(struct sockaddr_in6),
|
||||
host, NI_MAXHOST,
|
||||
NULL, 0, NI_NUMERICHOST);
|
||||
if (s != 0) {
|
||||
LogInfo("getnameinfo() failed: %s\n", gai_strerror(s));
|
||||
continue;
|
||||
}
|
||||
if (family == AF_INET) {
|
||||
sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name,host);
|
||||
LogInfo(" IPv4: %s", interfacelist[ifnr] );
|
||||
} else {
|
||||
sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name,host);
|
||||
LogInfo(" IPv6: %s", interfacelist[ifnr] );
|
||||
}
|
||||
ifnr++;
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifaddr);
|
||||
|
||||
|
||||
LogInfo(" Default interface is : %s" , dflt);
|
||||
|
||||
for(n=0;n<(ifnr);n++) {
|
||||
p=strchr(interfacelist[n],'%');
|
||||
if (p!=NULL) *p=0;
|
||||
if(strstr(interfacelist[n], dflt) != 0)
|
||||
{
|
||||
strcpy((char*)info,interfacelist[n]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
LogInfo(" IP to show: %s", info );
|
||||
}
|
||||
}
|
||||
|
31
Network.h
Normal file
31
Network.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2017 by Lieven De Samblanx ON7LDS
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if !defined(NETWORK_H)
|
||||
#define NETWORK_H
|
||||
|
||||
|
||||
class CNetworkInfo {
|
||||
public:
|
||||
|
||||
void getNetworkInterface(unsigned char* info);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
136
Nextion.cpp
136
Nextion.cpp
|
@ -18,12 +18,14 @@
|
|||
|
||||
#include "Nextion.h"
|
||||
#include "Log.h"
|
||||
#include "Network.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <clocale>
|
||||
#include <unistd.h>
|
||||
|
||||
const unsigned int DSTAR_RSSI_COUNT = 3U; // 3 * 420ms = 1260ms
|
||||
const unsigned int DSTAR_BER_COUNT = 63U; // 63 * 20ms = 1260ms
|
||||
|
@ -37,6 +39,7 @@ const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms
|
|||
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness) :
|
||||
CDisplay(),
|
||||
m_callsign(callsign),
|
||||
m_ipaddress("(ip unknown)"),
|
||||
m_dmrid(dmrid),
|
||||
m_serial(serial),
|
||||
m_brightness(brightness),
|
||||
|
@ -62,8 +65,13 @@ CNextion::~CNextion()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CNextion::open()
|
||||
{
|
||||
unsigned char info[100U];
|
||||
CNetworkInfo* m_network;
|
||||
|
||||
bool ret = m_serial->open();
|
||||
if (!ret) {
|
||||
LogError("Cannot open the port for the Nextion display");
|
||||
|
@ -71,29 +79,41 @@ bool CNextion::open()
|
|||
return false;
|
||||
}
|
||||
|
||||
info[0]=0;
|
||||
m_network = new CNetworkInfo;
|
||||
m_network->getNetworkInterface(info);
|
||||
m_ipaddress = (char*)info;
|
||||
|
||||
sendCommand("bkcmd=0");
|
||||
m_screenLayout=100;
|
||||
|
||||
setIdle();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CNextion::setIdleInt()
|
||||
{
|
||||
char text[30U];
|
||||
|
||||
sendCommand("page MMDVM");
|
||||
|
||||
char command[30];
|
||||
::sprintf(command, "dim=%u", m_idleBrightness);
|
||||
sendCommand(command);
|
||||
|
||||
::sprintf(command, "t0.txt=\"%-6s / %u\"", m_callsign.c_str(), m_dmrid);
|
||||
|
||||
::sprintf(command, "t0.txt=\"%s/%u\"", m_callsign.c_str(), m_dmrid);
|
||||
sendCommand(command);
|
||||
sendCommand("t1.txt=\"MMDVM IDLE\"");
|
||||
|
||||
::sprintf(text, "t3.txt=\"%s\"", m_ipaddress.c_str());
|
||||
sendCommand(text);
|
||||
|
||||
m_clockDisplayTimer.start();
|
||||
|
||||
m_mode = MODE_IDLE;
|
||||
|
||||
if (m_screenLayout==100) checkScreenLayout();
|
||||
}
|
||||
|
||||
void CNextion::setErrorInt(const char* text)
|
||||
|
@ -226,10 +246,19 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
if (m_mode != MODE_DMR) {
|
||||
sendCommand("page DMR");
|
||||
|
||||
if (slotNo == 1U)
|
||||
if (slotNo == 1U) {
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t2.pco=0");
|
||||
sendCommand("t2.font=4");
|
||||
}
|
||||
sendCommand("t2.txt=\"2 Listening\"");
|
||||
else
|
||||
} else {
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t0.pco=0");
|
||||
sendCommand("t0.font=4");
|
||||
}
|
||||
sendCommand("t0.txt=\"1 Listening\"");
|
||||
}
|
||||
}
|
||||
|
||||
char text[30U];
|
||||
|
@ -238,14 +267,20 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
|
||||
if (slotNo == 1U) {
|
||||
::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str());
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t0.pco=0");
|
||||
sendCommand("t0.font=4");
|
||||
}
|
||||
sendCommand(text);
|
||||
|
||||
::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
||||
sendCommand(text);
|
||||
} else {
|
||||
::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str());
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t2.pco=0");
|
||||
sendCommand("t2.font=4");
|
||||
}
|
||||
sendCommand(text);
|
||||
|
||||
::sprintf(text, "t3.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
||||
sendCommand(text);
|
||||
}
|
||||
|
@ -306,6 +341,42 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
||||
{
|
||||
char text[40U];
|
||||
|
||||
if (type[0]==' ') {
|
||||
if (slotNo == 1U) {
|
||||
sendCommand("t0.pco=33808");
|
||||
} else {
|
||||
sendCommand("t2.pco=33808");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (slotNo == 1U) {
|
||||
::sprintf(text, "t0.txt=\"1 %s %s\"",type,talkerAlias);
|
||||
if (m_screenLayout==2) {
|
||||
if (strlen((char*)talkerAlias)>16-4) sendCommand("t0.font=3");
|
||||
if (strlen((char*)talkerAlias)>20-4) sendCommand("t0.font=2");
|
||||
if (strlen((char*)talkerAlias)>24-4) sendCommand("t0.font=1");
|
||||
}
|
||||
sendCommand("t0.pco=1024");
|
||||
sendCommand(text);
|
||||
} else {
|
||||
::sprintf(text, "t2.txt=\"2 %s %s\"",type,talkerAlias);
|
||||
if (m_screenLayout==2) {
|
||||
if (strlen((char*)talkerAlias)>16-4) sendCommand("t2.font=3");
|
||||
if (strlen((char*)talkerAlias)>20-4) sendCommand("t2.font=2");
|
||||
if (strlen((char*)talkerAlias)>24-4) sendCommand("t2.font=1");
|
||||
}
|
||||
sendCommand("t2.pco=1024");
|
||||
sendCommand(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CNextion::writeDMRBERInt(unsigned int slotNo, float ber)
|
||||
{
|
||||
if (slotNo == 1U) {
|
||||
|
@ -353,11 +424,19 @@ void CNextion::clearDMRInt(unsigned int slotNo)
|
|||
{
|
||||
if (slotNo == 1U) {
|
||||
sendCommand("t0.txt=\"1 Listening\"");
|
||||
sendCommand("t0.pco=0");
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t0.font=4");
|
||||
}
|
||||
sendCommand("t1.txt=\"\"");
|
||||
sendCommand("t4.txt=\"\"");
|
||||
sendCommand("t6.txt=\"\"");
|
||||
} else {
|
||||
sendCommand("t2.txt=\"2 Listening\"");
|
||||
sendCommand("t2.pco=0");
|
||||
if (m_screenLayout==2) {
|
||||
sendCommand("t2.font=4");
|
||||
}
|
||||
sendCommand("t3.txt=\"\"");
|
||||
sendCommand("t5.txt=\"\"");
|
||||
sendCommand("t7.txt=\"\"");
|
||||
|
@ -568,6 +647,8 @@ void CNextion::clockInt(unsigned int ms)
|
|||
|
||||
void CNextion::close()
|
||||
{
|
||||
sendCommand("page MMDVM");
|
||||
sendCommand("t1.txt=\"MMDVM STOPPED\"");
|
||||
m_serial->close();
|
||||
delete m_serial;
|
||||
}
|
||||
|
@ -579,3 +660,44 @@ void CNextion::sendCommand(const char* command)
|
|||
m_serial->write((unsigned char*)command, ::strlen(command));
|
||||
m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CNextion::checkScreenLayout()
|
||||
{
|
||||
unsigned int res;
|
||||
int pos,length,screen;
|
||||
unsigned char data[25];
|
||||
|
||||
memset(data,0,25);
|
||||
pos=0;
|
||||
length=1;
|
||||
screen=0;
|
||||
|
||||
sendCommand("bkcmd=2");
|
||||
res=1; while (m_serial->read(&data[0],1)>0) {;}
|
||||
sendCommand("get MMDVM.screenLayout.val");
|
||||
sleep(1); //have to wait for answer
|
||||
|
||||
while (length>0) {
|
||||
length=m_serial->read(&data[pos],1);
|
||||
if (length>0) {
|
||||
// LogMessage("Nextion %d data received %02X ",length,(char)data[pos]);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
if (pos>0) {
|
||||
if ((data[0]==0x71)&&(pos>4)) screen=data[1]+(data[2]<<8)+(data[3]<<16)+(data[4]<<24);
|
||||
// LogMessage("Result value %d",screen);
|
||||
}
|
||||
|
||||
if ((res==0x1A)||(screen==0)) {
|
||||
m_screenLayout=1;
|
||||
LogMessage(" Display Layout: %d (G4KLX)",screen);
|
||||
} else {
|
||||
m_screenLayout=2;
|
||||
LogMessage(" Display Layout: %d (ON7LDS)",screen);
|
||||
}
|
||||
sendCommand("bkcmd=0");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
|||
|
||||
virtual void writeDMRInt(unsigned int slotNo, const std::string& 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);
|
||||
virtual void clearDMRInt(unsigned int slotNo);
|
||||
|
||||
|
@ -68,6 +69,7 @@ protected:
|
|||
|
||||
private:
|
||||
std::string m_callsign;
|
||||
std::string m_ipaddress;
|
||||
unsigned int m_dmrid;
|
||||
ISerialPort* m_serial;
|
||||
unsigned int m_brightness;
|
||||
|
@ -84,8 +86,11 @@ private:
|
|||
unsigned int m_rssiCount2;
|
||||
unsigned int m_berCount1;
|
||||
unsigned int m_berCount2;
|
||||
unsigned char m_screenLayout;
|
||||
|
||||
void sendCommand(const char* command);
|
||||
void checkScreenLayout();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.tft
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.tft
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.tft
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.tft
Normal file
Binary file not shown.
Loading…
Reference in a new issue