From 022d1a768b1ebf3f37ea79c6ac678d3870edba5f Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Fri, 27 Mar 2020 06:25:54 +0900 Subject: [PATCH 01/50] add IPv6 support (code from DAPNETGateway-IPv6) --- UDPSocket.cpp | 115 ++++++++++++++++++-------------------------------- UDPSocket.h | 9 ++-- 2 files changed, 47 insertions(+), 77 deletions(-) diff --git a/UDPSocket.cpp b/UDPSocket.cpp index ba0e35f..7899601 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -60,49 +60,46 @@ CUDPSocket::~CUDPSocket() #endif } -in_addr CUDPSocket::lookup(const std::string& hostname) +int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage &addr, unsigned int &address_length) { - in_addr addr; -#if defined(_WIN32) || defined(_WIN64) - unsigned long address = ::inet_addr(hostname.c_str()); - if (address != INADDR_NONE && address != INADDR_ANY) { - addr.s_addr = address; - return addr; + int err; + std::string portstr = std::to_string(port); + struct addrinfo hints, *res; + + ::memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_flags = AI_NUMERICSERV; + + err = getaddrinfo(hostname.c_str(), portstr.c_str(), &hints, &res); + if (err) { + sockaddr_in *paddr = (sockaddr_in *)&addr; + ::memset(paddr, 0, address_length = sizeof(sockaddr_in)); + paddr->sin_family = AF_INET; + paddr->sin_port = htons(port); + paddr->sin_addr.s_addr = htonl(INADDR_NONE); + LogError("Cannot find address for host %s", hostname.c_str()); + return err; } - struct hostent* hp = ::gethostbyname(hostname.c_str()); - if (hp != NULL) { - ::memcpy(&addr, hp->h_addr_list[0], sizeof(struct in_addr)); - return addr; - } + ::memcpy(&addr, res->ai_addr, address_length = res->ai_addrlen); - LogError("Cannot find address for host %s", hostname.c_str()); - - addr.s_addr = INADDR_NONE; - return addr; -#else - in_addr_t address = ::inet_addr(hostname.c_str()); - if (address != in_addr_t(-1)) { - addr.s_addr = address; - return addr; - } - - struct hostent* hp = ::gethostbyname(hostname.c_str()); - if (hp != NULL) { - ::memcpy(&addr, hp->h_addr_list[0], sizeof(struct in_addr)); - return addr; - } - - LogError("Cannot find address for host %s", hostname.c_str()); - - addr.s_addr = INADDR_NONE; - return addr; -#endif + freeaddrinfo(res); + return 0; } bool CUDPSocket::open() { - m_fd = ::socket(PF_INET, SOCK_DGRAM, 0); + int err; + sockaddr_storage addr; + unsigned int addrlen; + + /* to determine protocol family, call lookup() first. */ + err = lookup(m_address.empty() ? "0.0.0.0" : m_address.c_str(), m_port, addr, addrlen); + if (err) { + LogError("The local address is invalid - %s", m_address.c_str()); + return false; + } + + m_fd = ::socket(addr.ss_family, SOCK_DGRAM, 0); if (m_fd < 0) { #if defined(_WIN32) || defined(_WIN64) LogError("Cannot create the UDP socket, err: %lu", ::GetLastError()); @@ -113,24 +110,6 @@ bool CUDPSocket::open() } if (m_port > 0U) { - sockaddr_in addr; - ::memset(&addr, 0x00, sizeof(sockaddr_in)); - addr.sin_family = AF_INET; - addr.sin_port = htons(m_port); - addr.sin_addr.s_addr = htonl(INADDR_ANY); - - if (!m_address.empty()) { -#if defined(_WIN32) || defined(_WIN64) - addr.sin_addr.s_addr = ::inet_addr(m_address.c_str()); -#else - addr.sin_addr.s_addr = ::inet_addr(m_address.c_str()); -#endif - if (addr.sin_addr.s_addr == INADDR_NONE) { - LogError("The local address is invalid - %s", m_address.c_str()); - return false; - } - } - int reuse = 1; if (::setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) { #if defined(_WIN32) || defined(_WIN64) @@ -141,7 +120,7 @@ bool CUDPSocket::open() return false; } - if (::bind(m_fd, (sockaddr*)&addr, sizeof(sockaddr_in)) == -1) { + if (::bind(m_fd, (sockaddr*)&addr, addrlen) == -1) { #if defined(_WIN32) || defined(_WIN64) LogError("Cannot bind the UDP address, err: %lu", ::GetLastError()); #else @@ -154,7 +133,7 @@ bool CUDPSocket::open() return true; } -int CUDPSocket::read(unsigned char* buffer, unsigned int length, in_addr& address, unsigned int& port) +int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length) { assert(buffer != NULL); assert(length > 0U); @@ -186,17 +165,16 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, in_addr& addres if (ret == 0) return 0; - sockaddr_in addr; #if defined(_WIN32) || defined(_WIN64) - int size = sizeof(sockaddr_in); + int size = sizeof(sockaddr_storage); #else - socklen_t size = sizeof(sockaddr_in); + socklen_t size = sizeof(sockaddr_storage); #endif #if defined(_WIN32) || defined(_WIN64) - int len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&addr, &size); + int len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&address, &size); #else - ssize_t len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&addr, &size); + ssize_t len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&address, &size); #endif if (len <= 0) { #if defined(_WIN32) || defined(_WIN64) @@ -207,28 +185,19 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, in_addr& addres return -1; } - address = addr.sin_addr; - port = ntohs(addr.sin_port); - + address_length = size; return len; } -bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const in_addr& address, unsigned int port) +bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length) { assert(buffer != NULL); assert(length > 0U); - sockaddr_in addr; - ::memset(&addr, 0x00, sizeof(sockaddr_in)); - - addr.sin_family = AF_INET; - addr.sin_addr = address; - addr.sin_port = htons(port); - #if defined(_WIN32) || defined(_WIN64) - int ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&addr, sizeof(sockaddr_in)); + int ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&address, address_length); #else - ssize_t ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&addr, sizeof(sockaddr_in)); + ssize_t ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&address, address_length); #endif if (ret < 0) { #if defined(_WIN32) || defined(_WIN64) diff --git a/UDPSocket.h b/UDPSocket.h index e0af272..ec5de9c 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -31,7 +31,8 @@ #include #include #else -#include +#include +#include #endif class CUDPSocket { @@ -42,12 +43,12 @@ public: bool open(); - int read(unsigned char* buffer, unsigned int length, in_addr& address, unsigned int& port); - bool write(const unsigned char* buffer, unsigned int length, const in_addr& address, unsigned int port); + int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length); + bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length); void close(); - static in_addr lookup(const std::string& hostName); + static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage &address, unsigned int &address_length); private: std::string m_address; From 5dccd5c5ce6ae5afd424327816366ae1e19cea87 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 28 Mar 2020 04:37:51 +0900 Subject: [PATCH 02/50] add match(), isnone() utility function match() checks address family, IP address and port between two sockaddr_storages. isnone() checks sockaddr_storage has INADDR_NONE IPv4 address. (sockaddr_storage has this address when lookup() failed) --- UDPSocket.cpp | 31 +++++++++++++++++++++++++++++++ UDPSocket.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 7899601..9e5e2cf 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -86,6 +86,37 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_ return 0; } +bool CUDPSocket::match(const sockaddr_storage &addr1, const sockaddr_storage &addr2) +{ + if (addr1.ss_family != addr2.ss_family) + return false; + + switch (addr1.ss_family) { + case AF_INET: + struct sockaddr_in *in_1, *in_2; + in_1 = (struct sockaddr_in *)&addr1; + in_2 = (struct sockaddr_in *)&addr2; + return ( (in_1->sin_addr.s_addr == in_2->sin_addr.s_addr) && + (in_1->sin_port == in_2->sin_port) ); + case AF_INET6: + struct sockaddr_in6 *in6_1, *in6_2; + in6_1 = (struct sockaddr_in6 *)&addr1; + in6_2 = (struct sockaddr_in6 *)&addr2; + return ( IN6_ARE_ADDR_EQUAL(&in6_1->sin6_addr, &in6_2->sin6_addr) && + (in6_1->sin6_port == in6_2->sin6_port) ); + default: + return false; + } +} + +bool CUDPSocket::isnone(const sockaddr_storage &addr) +{ + struct sockaddr_in *in = (struct sockaddr_in *)&addr; + + return ( (addr.ss_family == AF_INET) && + (in->sin_addr.s_addr == htonl(INADDR_NONE)) ); +} + bool CUDPSocket::open() { int err; diff --git a/UDPSocket.h b/UDPSocket.h index ec5de9c..288273f 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -49,6 +49,8 @@ public: void close(); static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage &address, unsigned int &address_length); + static bool match(const sockaddr_storage &addr1, const sockaddr_storage &addr2); + static bool isnone(const sockaddr_storage &addr); private: std::string m_address; From c92039d83bb9f193ff189f5634c365523c5e4b66 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 28 Mar 2020 05:40:35 +0900 Subject: [PATCH 03/50] modified for IPv6 supported CUDPSocket --- DMRNetwork.cpp | 17 +++++++------- DMRNetwork.h | 3 ++- DStarNetwork.cpp | 26 ++++++++------------ DStarNetwork.h | 4 ++-- MMDVMHost.cpp | 15 ++++++------ MobileGPS.cpp | 12 +++++----- MobileGPS.h | 4 ++-- NXDNNetwork.cpp | 22 +++++++---------- NXDNNetwork.h | 4 ++-- P25Network.cpp | 60 +++++++++++++++++++++-------------------------- P25Network.h | 4 ++-- POCSAGNetwork.cpp | 22 +++++++---------- POCSAGNetwork.h | 4 ++-- RemoteCommand.cpp | 6 +++-- RemoteControl.cpp | 6 ++--- YSFNetwork.cpp | 24 +++++++------------ YSFNetwork.h | 4 ++-- 17 files changed, 105 insertions(+), 132 deletions(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index b2aedb5..ea52096 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -36,6 +36,7 @@ const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType) : m_addressStr(address), m_address(), +m_addrlen(), m_port(port), m_id(NULL), m_password(password), @@ -73,7 +74,7 @@ m_beacon(false) assert(id > 1000U); assert(!password.empty()); - m_address = CUDPSocket::lookup(address); + CUDPSocket::lookup(m_addressStr, m_port, m_address, m_addrlen); m_buffer = new unsigned char[BUFFER_LENGTH]; m_salt = new unsigned char[sizeof(uint32_t)]; @@ -124,8 +125,8 @@ bool CDMRNetwork::open() { LogMessage("DMR, Opening DMR Network"); - if (m_address.s_addr == INADDR_NONE) - m_address = CUDPSocket::lookup(m_addressStr); + if (CUDPSocket::isnone(m_address)) + CUDPSocket::lookup(m_addressStr, m_port, m_address, m_addrlen); m_status = WAITING_CONNECT; m_timeoutTimer.stop(); @@ -377,9 +378,9 @@ void CDMRNetwork::clock(unsigned int ms) return; } - in_addr address; - unsigned int port; - int length = m_socket.read(m_buffer, BUFFER_LENGTH, address, port); + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(m_buffer, BUFFER_LENGTH, address, addrlen); if (length < 0) { LogError("DMR, Socket has failed, retrying connection to the master"); close(); @@ -390,7 +391,7 @@ void CDMRNetwork::clock(unsigned int ms) // if (m_debug && length > 0) // CUtils::dump(1U, "Network Received", m_buffer, length); - if (length > 0 && m_address.s_addr == address.s_addr && m_port == port) { + if (length > 0 && CUDPSocket::match(m_address, address)) { if (::memcmp(m_buffer, "DMRD", 4U) == 0) { if (m_enabled) { if (m_debug) @@ -663,7 +664,7 @@ bool CDMRNetwork::write(const unsigned char* data, unsigned int length) // if (m_debug) // CUtils::dump(1U, "Network Transmitted", data, length); - bool ret = m_socket.write(data, length, m_address, m_port); + bool ret = m_socket.write(data, length, m_address, m_addrlen); if (!ret) { LogError("DMR, Socket has failed when writing data to the master, retrying connection"); m_socket.close(); diff --git a/DMRNetwork.h b/DMRNetwork.h index 9d1c52e..96f1074 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -60,7 +60,8 @@ public: private: std::string m_addressStr; - in_addr m_address; + sockaddr_storage m_address; + unsigned int m_addrlen; unsigned int m_port; uint8_t* m_id; std::string m_password; diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index de0af69..295c289 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -33,7 +33,7 @@ const unsigned int BUFFER_LENGTH = 100U; CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) : m_socket(localPort), m_address(), -m_port(gatewayPort), +m_addrlen(), m_duplex(duplex), m_version(version), m_debug(debug), @@ -46,7 +46,7 @@ m_pollTimer(1000U, 60U), m_linkStatus(LS_NONE), m_linkReflector(NULL) { - m_address = CUDPSocket::lookup(gatewayAddress); + CUDPSocket::lookup(gatewayAddress, gatewayPort, m_address, m_addrlen); m_linkReflector = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; @@ -63,7 +63,7 @@ bool CDStarNetwork::open() { LogMessage("Opening D-Star network connection"); - if (m_address.s_addr == INADDR_NONE) + if (CUDPSocket::isnone(m_address)) return false; m_pollTimer.start(); @@ -100,7 +100,7 @@ bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length CUtils::dump(1U, "D-Star Network Header Sent", buffer, 49U); for (unsigned int i = 0U; i < 2U; i++) { - bool ret = m_socket.write(buffer, 49U, m_address, m_port); + bool ret = m_socket.write(buffer, 49U, m_address, m_addrlen); if (!ret) return false; } @@ -143,7 +143,7 @@ bool CDStarNetwork::writeData(const unsigned char* data, unsigned int length, un if (m_debug) CUtils::dump(1U, "D-Star Network Data Sent", buffer, length + 9U); - return m_socket.write(buffer, length + 9U, m_address, m_port); + return m_socket.write(buffer, length + 9U, m_address, m_addrlen); } bool CDStarNetwork::writePoll(const char* text) @@ -167,7 +167,7 @@ bool CDStarNetwork::writePoll(const char* text) // if (m_debug) // CUtils::dump(1U, "D-Star Network Poll Sent", buffer, 6U + length); - return m_socket.write(buffer, 6U + length, m_address, m_port); + return m_socket.write(buffer, 6U + length, m_address, m_addrlen); } void CDStarNetwork::clock(unsigned int ms) @@ -192,18 +192,12 @@ void CDStarNetwork::clock(unsigned int ms) unsigned char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); - if (length <= 0) + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrlen); + if (length <= 0 || !CUDPSocket::match(m_address, address)) return; - // Check if the data is for us - if (m_address.s_addr != address.s_addr || m_port != port) { - LogMessage("D-Star packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port); - return; - } - // Invalid packet type? if (::memcmp(buffer, "DSRP", 4U) != 0) return; diff --git a/DStarNetwork.h b/DStarNetwork.h index aeebbbf..6f96880 100644 --- a/DStarNetwork.h +++ b/DStarNetwork.h @@ -51,8 +51,8 @@ public: private: CUDPSocket m_socket; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; bool m_duplex; const char* m_version; bool m_debug; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 53f6d1f..4769895 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -316,8 +316,8 @@ int CMMDVMHost::run() return 1; } - in_addr transparentAddress; - unsigned int transparentPort = 0U; + sockaddr_storage transparentAddress; + unsigned int transparentAddrLen; CUDPSocket* transparentSocket = NULL; unsigned int sendFrameType = 0U; @@ -333,8 +333,7 @@ int CMMDVMHost::run() LogInfo(" Local Port: %u", localPort); LogInfo(" Send Frame Type: %u", sendFrameType); - transparentAddress = CUDPSocket::lookup(remoteAddress); - transparentPort = remotePort; + CUDPSocket::lookup(remoteAddress, remotePort, transparentAddress, transparentAddrLen); transparentSocket = new CUDPSocket(localPort); ret = transparentSocket->open(); @@ -793,7 +792,7 @@ int CMMDVMHost::run() len = m_modem->readTransparentData(data); if (transparentSocket != NULL && len > 0U) - transparentSocket->write(data, len, transparentAddress, transparentPort); + transparentSocket->write(data, len, transparentAddress, transparentAddrLen); if (!m_fixedMode) { if (m_modeTimer.isRunning() && m_modeTimer.hasExpired()) @@ -942,9 +941,9 @@ int CMMDVMHost::run() } if (transparentSocket != NULL) { - in_addr address; - unsigned int port = 0U; - len = transparentSocket->read(data, 200U, address, port); + sockaddr_storage address; + unsigned int addrlen; + len = transparentSocket->read(data, 200U, address, addrlen); if (len > 0U) m_modem->writeTransparentData(data, len); } diff --git a/MobileGPS.cpp b/MobileGPS.cpp index 27721bd..7cd782e 100644 --- a/MobileGPS.cpp +++ b/MobileGPS.cpp @@ -26,7 +26,7 @@ CMobileGPS::CMobileGPS(const std::string& address, unsigned int port, CDMRNetwork* network) : m_idTimer(1000U, 60U), m_address(), -m_port(port), +m_addrlen(), m_socket(), m_network(network) { @@ -34,7 +34,7 @@ m_network(network) assert(port > 0U); assert(network != NULL); - m_address = CUDPSocket::lookup(address); + CUDPSocket::lookup(address, port, m_address, m_addrlen); } CMobileGPS::~CMobileGPS() @@ -71,16 +71,16 @@ void CMobileGPS::close() bool CMobileGPS::pollGPS() { - return m_socket.write((unsigned char*)"MMDVMHost", 9U, m_address, m_port); + return m_socket.write((unsigned char*)"MMDVMHost", 9U, m_address, m_addrlen); } void CMobileGPS::sendReport() { // Grab GPS data if it's available unsigned char buffer[200U]; - in_addr address; - unsigned int port; - int ret = m_socket.read(buffer, 200U, address, port); + sockaddr_storage address; + unsigned int addrlen; + int ret = m_socket.read(buffer, 200U, address, addrlen); if (ret <= 0) return; diff --git a/MobileGPS.h b/MobileGPS.h index 8d69572..8384c65 100644 --- a/MobileGPS.h +++ b/MobileGPS.h @@ -51,8 +51,8 @@ public: private: CTimer m_idTimer; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; CUDPSocket m_socket; CDMRNetwork* m_network; diff --git a/NXDNNetwork.cpp b/NXDNNetwork.cpp index 9e26900..dcf215e 100644 --- a/NXDNNetwork.cpp +++ b/NXDNNetwork.cpp @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 200U; CNXDNNetwork::CNXDNNetwork(const std::string& localAddress, unsigned int localPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : m_socket(localAddress, localPort), m_address(), -m_port(gatewayPort), +m_addrlen(), m_debug(debug), m_enabled(false), m_buffer(1000U, "NXDN Network") @@ -39,7 +39,7 @@ m_buffer(1000U, "NXDN Network") assert(gatewayPort > 0U); assert(!gatewayAddress.empty()); - m_address = CUDPSocket::lookup(gatewayAddress); + CUDPSocket::lookup(gatewayAddress, gatewayPort, m_address, m_addrlen); } CNXDNNetwork::~CNXDNNetwork() @@ -50,7 +50,7 @@ bool CNXDNNetwork::open() { LogMessage("Opening NXDN network connection"); - if (m_address.s_addr == INADDR_NONE) + if (CUDPSocket::isnone(m_address)) return false; return m_socket.open(); @@ -100,25 +100,19 @@ bool CNXDNNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE ty if (m_debug) CUtils::dump(1U, "NXDN Network Data Sent", buffer, 102U); - return m_socket.write(buffer, 102U, m_address, m_port); + return m_socket.write(buffer, 102U, m_address, m_addrlen); } void CNXDNNetwork::clock(unsigned int ms) { unsigned char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); - if (length <= 0) + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrlen); + if (length <= 0 || !CUDPSocket::match(m_address, address)) return; - // Check if the data is for us - if (m_address.s_addr != address.s_addr || port != m_port) { - LogMessage("NXDN packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port); - return; - } - // Invalid packet type? if (::memcmp(buffer, "ICOM", 4U) != 0) return; diff --git a/NXDNNetwork.h b/NXDNNetwork.h index 3a5b784..ec428d9 100644 --- a/NXDNNetwork.h +++ b/NXDNNetwork.h @@ -57,8 +57,8 @@ public: private: CUDPSocket m_socket; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; bool m_debug; bool m_enabled; CRingBuffer m_buffer; diff --git a/P25Network.cpp b/P25Network.cpp index 14a0fd5..a326966 100644 --- a/P25Network.cpp +++ b/P25Network.cpp @@ -90,13 +90,13 @@ const unsigned int BUFFER_LENGTH = 100U; CP25Network::CP25Network(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool debug) : m_socket(localPort), m_address(), -m_port(gatewayPort), +m_addrlen(), m_debug(debug), m_enabled(false), m_buffer(1000U, "P25 Network"), m_audio() { - m_address = CUDPSocket::lookup(gatewayAddress); + CUDPSocket::lookup(gatewayAddress, gatewayPort, m_address, m_addrlen); } CP25Network::~CP25Network() @@ -107,7 +107,7 @@ bool CP25Network::open() { LogMessage("Opening P25 network connection"); - if (m_address.s_addr == INADDR_NONE) + if (CUDPSocket::isnone(m_address)) return false; return m_socket.open(); @@ -126,7 +126,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 22U); - bool ret = m_socket.write(buffer, 22U, m_address, m_port); + bool ret = m_socket.write(buffer, 22U, m_address, m_addrlen); if (!ret) return false; @@ -137,7 +137,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 14U); - ret = m_socket.write(buffer, 14U, m_address, m_port); + ret = m_socket.write(buffer, 14U, m_address, m_addrlen); if (!ret) return false; @@ -150,7 +150,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -165,7 +165,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -180,7 +180,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -191,7 +191,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -202,7 +202,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -213,7 +213,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -226,7 +226,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU1 Sent", buffer, 16U); - ret = m_socket.write(buffer, 16U, m_address, m_port); + ret = m_socket.write(buffer, 16U, m_address, m_addrlen); if (!ret) return false; @@ -234,7 +234,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network END Sent", REC80, 17U); - ret = m_socket.write(REC80, 17U, m_address, m_port); + ret = m_socket.write(REC80, 17U, m_address, m_addrlen); if (!ret) return false; } @@ -255,7 +255,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 22U); - bool ret = m_socket.write(buffer, 22U, m_address, m_port); + bool ret = m_socket.write(buffer, 22U, m_address, m_addrlen); if (!ret) return false; @@ -266,7 +266,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 14U); - ret = m_socket.write(buffer, 14U, m_address, m_port); + ret = m_socket.write(buffer, 14U, m_address, m_addrlen); if (!ret) return false; @@ -283,7 +283,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -297,7 +297,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -311,7 +311,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -326,7 +326,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -337,7 +337,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -348,7 +348,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 17U); - ret = m_socket.write(buffer, 17U, m_address, m_port); + ret = m_socket.write(buffer, 17U, m_address, m_addrlen); if (!ret) return false; @@ -361,7 +361,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network LDU2 Sent", buffer, 16U); - ret = m_socket.write(buffer, 16U, m_address, m_port); + ret = m_socket.write(buffer, 16U, m_address, m_addrlen); if (!ret) return false; @@ -369,7 +369,7 @@ bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, if (m_debug) CUtils::dump(1U, "P25 Network END Sent", REC80, 17U); - ret = m_socket.write(REC80, 17U, m_address, m_port); + ret = m_socket.write(REC80, 17U, m_address, m_addrlen); if (!ret) return false; } @@ -381,18 +381,12 @@ void CP25Network::clock(unsigned int ms) { unsigned char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); - if (length <= 0) + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrlen); + if (length <= 0 || !CUDPSocket::match(m_address, address)) return; - // Check if the data is for us - if (m_address.s_addr != address.s_addr || m_port != port) { - LogMessage("P25 packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port); - return; - } - if (!m_enabled) return; diff --git a/P25Network.h b/P25Network.h index 054c772..009c994 100644 --- a/P25Network.h +++ b/P25Network.h @@ -49,8 +49,8 @@ public: private: CUDPSocket m_socket; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; bool m_debug; bool m_enabled; CRingBuffer m_buffer; diff --git a/POCSAGNetwork.cpp b/POCSAGNetwork.cpp index 682fdd1..e6b755a 100644 --- a/POCSAGNetwork.cpp +++ b/POCSAGNetwork.cpp @@ -31,12 +31,12 @@ const unsigned int BUFFER_LENGTH = 200U; CPOCSAGNetwork::CPOCSAGNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : m_socket(myAddress, myPort), m_address(), -m_port(gatewayPort), +m_addrlen(), m_debug(debug), m_enabled(false), m_buffer(1000U, "POCSAG Network") { - m_address = CUDPSocket::lookup(gatewayAddress); + CUDPSocket::lookup(gatewayAddress, gatewayPort, m_address, m_addrlen); } CPOCSAGNetwork::~CPOCSAGNetwork() @@ -47,7 +47,7 @@ bool CPOCSAGNetwork::open() { LogMessage("Opening POCSAG network connection"); - if (m_address.s_addr == INADDR_NONE) + if (CUDPSocket::isnone(m_address)) return false; return m_socket.open(); @@ -57,18 +57,12 @@ void CPOCSAGNetwork::clock(unsigned int ms) { unsigned char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); - if (length <= 0) + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrlen); + if (length <= 0 || !CUDPSocket::match(m_address, address)) return; - // Check if the data is for us - if (m_address.s_addr != address.s_addr || m_port != port) { - LogMessage("POCSAG packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port); - return; - } - // Invalid packet type? if (::memcmp(buffer, "POCSAG", 6U) != 0) return; @@ -118,7 +112,7 @@ void CPOCSAGNetwork::enable(bool enabled) unsigned char c = enabled ? 0x00U : 0xFFU; - m_socket.write(&c, 1U, m_address, m_port); + m_socket.write(&c, 1U, m_address, m_addrlen); m_enabled = enabled; } diff --git a/POCSAGNetwork.h b/POCSAGNetwork.h index fe95203..dd3945b 100644 --- a/POCSAGNetwork.h +++ b/POCSAGNetwork.h @@ -46,8 +46,8 @@ public: private: CUDPSocket m_socket; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; bool m_debug; bool m_enabled; CRingBuffer m_buffer; diff --git a/RemoteCommand.cpp b/RemoteCommand.cpp index bf3fb1e..42a09be 100644 --- a/RemoteCommand.cpp +++ b/RemoteCommand.cpp @@ -67,9 +67,11 @@ int CRemoteCommand::send(const std::string& command) if (!ret) return 1; - in_addr address = CUDPSocket::lookup("localhost"); + sockaddr_storage address; + unsigned int addrlen; + CUDPSocket::lookup("localhost", m_port, address, addrlen); - ret = socket.write((unsigned char*)command.c_str(), command.length(), address, m_port); + ret = socket.write((unsigned char*)command.c_str(), command.length(), address, addrlen); if (!ret) { socket.close(); return 1; diff --git a/RemoteControl.cpp b/RemoteControl.cpp index afa1473..0c72f6b 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -53,9 +53,9 @@ REMOTE_COMMAND CRemoteControl::getCommand() char command[BUFFER_LENGTH]; char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int ret = m_socket.read((unsigned char*)buffer, BUFFER_LENGTH, address, port); + sockaddr_storage address; + unsigned int addrlen; + int ret = m_socket.read((unsigned char*)buffer, BUFFER_LENGTH, address, addrlen); if (ret > 0) { buffer[ret] = '\0'; diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index a8effba..ff5cab8 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.cpp @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 200U; CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, const std::string& callsign, bool debug) : m_socket(myAddress, myPort), m_address(), -m_port(gatewayPort), +m_addrlen(), m_callsign(), m_debug(debug), m_enabled(false), @@ -42,7 +42,7 @@ m_tag(NULL) m_callsign = callsign; m_callsign.resize(YSF_CALLSIGN_LENGTH, ' '); - m_address = CUDPSocket::lookup(gatewayAddress); + CUDPSocket::lookup(gatewayAddress, gatewayPort, m_address, m_addrlen); m_tag = new unsigned char[YSF_CALLSIGN_LENGTH]; ::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH); @@ -57,7 +57,7 @@ bool CYSFNetwork::open() { LogMessage("Opening YSF network connection"); - if (m_address.s_addr == INADDR_NONE) + if (CUDPSocket::isnone(m_address)) return false; m_pollTimer.start(); @@ -97,7 +97,7 @@ bool CYSFNetwork::write(const unsigned char* src, const unsigned char* dest, con if (m_debug) CUtils::dump(1U, "YSF Network Data Sent", buffer, 155U); - return m_socket.write(buffer, 155U, m_address, m_port); + return m_socket.write(buffer, 155U, m_address, m_addrlen); } bool CYSFNetwork::writePoll() @@ -115,7 +115,7 @@ bool CYSFNetwork::writePoll() if (m_debug) CUtils::dump(1U, "YSF Network Poll Sent", buffer, 14U); - return m_socket.write(buffer, 14U, m_address, m_port); + return m_socket.write(buffer, 14U, m_address, m_addrlen); } void CYSFNetwork::clock(unsigned int ms) @@ -128,18 +128,12 @@ void CYSFNetwork::clock(unsigned int ms) unsigned char buffer[BUFFER_LENGTH]; - in_addr address; - unsigned int port; - int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); - if (length <= 0) + sockaddr_storage address; + unsigned int addrlen; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrlen); + if (length <= 0 || !CUDPSocket::match(m_address, address)) return; - // Check if the data is for us - if (m_address.s_addr != address.s_addr || m_port != port) { - LogMessage("YSF packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port); - return; - } - // Ignore incoming polls if (::memcmp(buffer, "YSFP", 4U) == 0) return; diff --git a/YSFNetwork.h b/YSFNetwork.h index e9a430f..292364d 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.h @@ -48,8 +48,8 @@ public: private: CUDPSocket m_socket; - in_addr m_address; - unsigned int m_port; + sockaddr_storage m_address; + unsigned int m_addrlen; std::string m_callsign; bool m_debug; bool m_enabled; From dad47317e638d22c8d4008eb63032895ba1739ca Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sun, 29 Mar 2020 15:06:20 +0900 Subject: [PATCH 04/50] set INADDR_ANY/IN6ADDR_ANY_INIT address string to m_socket when CUDPSocket::open() is called with m_address (in CUDPSocket) is nothing, IPv4 socket is created by "0.0.0.0" (INADDR_ANY) address. This causes a problem that DMRGateway cannot connect to reflector on IPv6. To choose default INADDR_ANY/IN6ADDR_ANY_INIT address, added open(address_family) in UDPSocket.cpp. Following code sets address string at construction, not modified. NXDNNetwork.cpp POCSAGNetwork.cpp YSFNetwork.cpp Other codes does not set, modified open() -> open(address_family) DMRNetwork.cpp DStarNetwork.cpp MMDVMHost.cpp MobileGPS.cpp P25Network.cpp RemoteCommand.cpp RemoteControl.cpp I think there is more clever method, but I have no other idea. Maybe IPv6 support for digital radio works, but RemoteControl can work IPv4 only. --- DMRNetwork.cpp | 2 +- DStarNetwork.cpp | 2 +- MMDVMHost.cpp | 2 +- MobileGPS.cpp | 2 +- P25Network.cpp | 2 +- RemoteCommand.cpp | 14 +++++++------- RemoteControl.cpp | 2 +- UDPSocket.cpp | 25 ++++++++++++++++++++++++- UDPSocket.h | 1 + 9 files changed, 38 insertions(+), 14 deletions(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index ea52096..91ae0a4 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -362,7 +362,7 @@ void CDMRNetwork::clock(unsigned int ms) if (m_status == WAITING_CONNECT) { m_retryTimer.clock(ms); if (m_retryTimer.isRunning() && m_retryTimer.hasExpired()) { - bool ret = m_socket.open(); + bool ret = m_socket.open(m_address.ss_family); if (ret) { ret = writeLogin(); if (!ret) diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 295c289..072b7cf 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -68,7 +68,7 @@ bool CDStarNetwork::open() m_pollTimer.start(); - return m_socket.open(); + return m_socket.open(m_address.ss_family); } bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length, bool busy) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 4769895..9f792e5 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -336,7 +336,7 @@ int CMMDVMHost::run() CUDPSocket::lookup(remoteAddress, remotePort, transparentAddress, transparentAddrLen); transparentSocket = new CUDPSocket(localPort); - ret = transparentSocket->open(); + ret = transparentSocket->open(transparentAddress.ss_family); if (!ret) { LogWarning("Could not open the Transparent data socket, disabling"); delete transparentSocket; diff --git a/MobileGPS.cpp b/MobileGPS.cpp index 7cd782e..0cb2c3b 100644 --- a/MobileGPS.cpp +++ b/MobileGPS.cpp @@ -43,7 +43,7 @@ CMobileGPS::~CMobileGPS() bool CMobileGPS::open() { - bool ret = m_socket.open(); + bool ret = m_socket.open(m_address.ss_family); if (!ret) return false; diff --git a/P25Network.cpp b/P25Network.cpp index a326966..ed28fa6 100644 --- a/P25Network.cpp +++ b/P25Network.cpp @@ -110,7 +110,7 @@ bool CP25Network::open() if (CUDPSocket::isnone(m_address)) return false; - return m_socket.open(); + return m_socket.open(m_address.ss_family); } bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, const CP25LowSpeedData& lsd, bool end) diff --git a/RemoteCommand.cpp b/RemoteCommand.cpp index 42a09be..9d7b038 100644 --- a/RemoteCommand.cpp +++ b/RemoteCommand.cpp @@ -61,15 +61,15 @@ CRemoteCommand::~CRemoteCommand() int CRemoteCommand::send(const std::string& command) { - CUDPSocket socket(0U); - - bool ret = socket.open(); - if (!ret) - return 1; - sockaddr_storage address; unsigned int addrlen; - CUDPSocket::lookup("localhost", m_port, address, addrlen); + CUDPSocket::lookup("127.0.0.1", m_port, address, addrlen); + + CUDPSocket socket(0U); + + bool ret = socket.open(address.ss_family); + if (!ret) + return 1; ret = socket.write((unsigned char*)command.c_str(), command.length(), address, addrlen); if (!ret) { diff --git a/RemoteControl.cpp b/RemoteControl.cpp index 0c72f6b..0c29791 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -43,7 +43,7 @@ CRemoteControl::~CRemoteControl() bool CRemoteControl::open() { - return m_socket.open(); + return m_socket.open(AF_INET); /* XXX IPv4 only */ } REMOTE_COMMAND CRemoteControl::getCommand() diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 9e5e2cf..a2b5991 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -117,14 +117,37 @@ bool CUDPSocket::isnone(const sockaddr_storage &addr) (in->sin_addr.s_addr == htonl(INADDR_NONE)) ); } +bool CUDPSocket::open(const unsigned int af) +{ + switch (af) { + case AF_INET6: + m_address = "::"; + break; + case AF_INET: + m_address = "0.0.0.0"; + break; + default: + LogWarning("unknown address family - %d", af); + break; + } + + return open(); +} + bool CUDPSocket::open() { int err; sockaddr_storage addr; unsigned int addrlen; + /* m_address should be defined */ + if (m_address.empty()) { + LogError("The local address is undefined"); + return false; + } + /* to determine protocol family, call lookup() first. */ - err = lookup(m_address.empty() ? "0.0.0.0" : m_address.c_str(), m_port, addr, addrlen); + err = lookup(m_address.c_str(), m_port, addr, addrlen); if (err) { LogError("The local address is invalid - %s", m_address.c_str()); return false; diff --git a/UDPSocket.h b/UDPSocket.h index 288273f..b5add46 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -42,6 +42,7 @@ public: ~CUDPSocket(); bool open(); + bool open(const unsigned int af); int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length); bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length); From 15b5011ebf0212894ca5bf574c1fc1efddf81c72 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 4 Apr 2020 15:18:55 +0900 Subject: [PATCH 05/50] rewrite with getaddrinfo() API to support IPv6 Currently LCDproc seems to be IPv6 unsupported, but this code is modified for the future IPv6-supported LCDproc. --- LCDproc.cpp | 57 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/LCDproc.cpp b/LCDproc.cpp index 8ef2721..eddba78 100644 --- a/LCDproc.cpp +++ b/LCDproc.cpp @@ -121,44 +121,53 @@ CLCDproc::~CLCDproc() bool CLCDproc::open() { - const char *server; - unsigned int port, localPort; - struct sockaddr_in serverAddress, clientAddress; - struct hostent *h; + int err; + unsigned int addrlen; + std::string port, localPort; + struct sockaddr_storage serverAddress, clientAddress; + struct addrinfo hints, *res; - server = m_address.c_str(); - port = m_port; - localPort = m_localPort; + port = std::to_string(m_port); + localPort = std::to_string(m_localPort); + memset(&hints, 0, sizeof(hints)); + /* Lookup the hostname address */ + hints.ai_flags = AI_NUMERICSERV; + hints.ai_socktype = SOCK_STREAM; + err = getaddrinfo(m_address.c_str(), port.c_str(), &hints, &res); + if (err) { + LogError("LCDproc, cannot lookup server"); + return false; + } + memcpy(&serverAddress, res->ai_addr, addrlen = res->ai_addrlen); + freeaddrinfo(res); + + /* Lookup the client address (random port - need to specify manual port from ini file) */ + hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE; + hints.ai_family = serverAddress.ss_family; + err = getaddrinfo(NULL, localPort.c_str(), &hints, &res); + if (err) { + LogError("LCDproc, cannot lookup client"); + return false; + } + memcpy(&clientAddress, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); /* Create TCP socket */ - m_socketfd = socket(AF_INET, SOCK_STREAM, 0); + m_socketfd = socket(clientAddress.ss_family, SOCK_STREAM, 0); if (m_socketfd == -1) { LogError("LCDproc, failed to create socket"); return false; } - /* Sets client address (random port - need to specify manual port from ini file?) */ - clientAddress.sin_family = AF_INET; - clientAddress.sin_addr.s_addr = htonl(INADDR_ANY); - //clientAddress.sin_port = htons(0); - clientAddress.sin_port = htons(localPort); - /* Bind the address to the socket */ - if (bind(m_socketfd, (struct sockaddr *)&clientAddress, sizeof(clientAddress)) == -1) { + if (bind(m_socketfd, (struct sockaddr *)&clientAddress, addrlen) == -1) { LogError("LCDproc, error whilst binding address"); return false; } - /* Lookup the hostname address */ - h = gethostbyname(server); - - /* Sets server address */ - serverAddress.sin_family = h->h_addrtype; - memcpy((char*)&serverAddress.sin_addr.s_addr, h->h_addr_list[0], h->h_length); - serverAddress.sin_port = htons(port); - - if (connect(m_socketfd, (struct sockaddr * )&serverAddress, sizeof(serverAddress))==-1) { + /* Connect to server */ + if (connect(m_socketfd, (struct sockaddr *)&serverAddress, addrlen) == -1) { LogError("LCDproc, cannot connect to server"); return false; } From 88bbb0cd0f5a76269985e3504a550baadaf7512b Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sun, 5 Apr 2020 07:05:33 +0900 Subject: [PATCH 06/50] use getaddrinfo() AI_PASSIVE flag, to remove "::" and "0.0.0.0" --- UDPSocket.cpp | 46 +++++++++++++++++++++------------------------- UDPSocket.h | 1 + 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/UDPSocket.cpp b/UDPSocket.cpp index a2b5991..beec3ce 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -61,15 +61,24 @@ CUDPSocket::~CUDPSocket() } int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage &addr, unsigned int &address_length) +{ + struct addrinfo hints; + + ::memset(&hints, 0, sizeof(hints)); + + return lookup(hostname, port, addr, address_length, hints); +} + +int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage &addr, unsigned int &address_length, struct addrinfo &hints) { int err; std::string portstr = std::to_string(port); - struct addrinfo hints, *res; + struct addrinfo *res; - ::memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_flags = AI_NUMERICSERV; + /* port is always digits, no needs to lookup service */ + hints.ai_flags |= AI_NUMERICSERV; - err = getaddrinfo(hostname.c_str(), portstr.c_str(), &hints, &res); + err = getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res); if (err) { sockaddr_in *paddr = (sockaddr_in *)&addr; ::memset(paddr, 0, address_length = sizeof(sockaddr_in)); @@ -117,37 +126,24 @@ bool CUDPSocket::isnone(const sockaddr_storage &addr) (in->sin_addr.s_addr == htonl(INADDR_NONE)) ); } -bool CUDPSocket::open(const unsigned int af) +bool CUDPSocket::open() { - switch (af) { - case AF_INET6: - m_address = "::"; - break; - case AF_INET: - m_address = "0.0.0.0"; - break; - default: - LogWarning("unknown address family - %d", af); - break; - } - - return open(); + return open(AF_UNSPEC); } -bool CUDPSocket::open() +bool CUDPSocket::open(const unsigned int af) { int err; sockaddr_storage addr; unsigned int addrlen; + struct addrinfo hints; - /* m_address should be defined */ - if (m_address.empty()) { - LogError("The local address is undefined"); - return false; - } + ::memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = af; /* to determine protocol family, call lookup() first. */ - err = lookup(m_address.c_str(), m_port, addr, addrlen); + err = lookup(m_address, m_port, addr, addrlen, hints); if (err) { LogError("The local address is invalid - %s", m_address.c_str()); return false; diff --git a/UDPSocket.h b/UDPSocket.h index b5add46..46b2370 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -50,6 +50,7 @@ public: void close(); static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage &address, unsigned int &address_length); + static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage &address, unsigned int &address_length, struct addrinfo &hints); static bool match(const sockaddr_storage &addr1, const sockaddr_storage &addr2); static bool isnone(const sockaddr_storage &addr); From 535ddba1a0523143f50bf680a27c6f270c4a0ee3 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 9 Apr 2020 22:02:47 +0100 Subject: [PATCH 07/50] Beginnings of FM support. --- Conf.cpp | 197 +++++++++++++++++++++++++++++++++++++- Conf.h | 51 +++++++++- MMDVM.ini | 25 +++++ MMDVMHost.cpp | 60 ++++++++++++ MMDVMHost.h | 3 +- MMDVMHost.vcxproj | 4 + MMDVMHost.vcxproj.filters | 12 +++ UserDB.cpp | 10 +- 8 files changed, 351 insertions(+), 11 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 9325a1b..d857c53 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX * * 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 @@ -44,6 +44,7 @@ enum SECTION { SECTION_P25, SECTION_NXDN, SECTION_POCSAG, + SECTION_FM, SECTION_DSTAR_NETWORK, SECTION_DMR_NETWORK, SECTION_FUSION_NETWORK, @@ -170,6 +171,29 @@ m_nxdnRemoteGateway(false), m_nxdnModeHang(10U), m_pocsagEnabled(false), m_pocsagFrequency(0U), +m_fmEnabled(false), +m_fmCallsign(), +m_fmCallsignSpeed(20U), +m_fmCallsignFrequency(1000U), +m_fmCallsignTime(10U), +m_fmCallsignHoldoff(1U), +m_fmCallsignHighLevel(80U), +m_fmCallsignLowLevel(40U), +m_fmCallsignAtStart(true), +m_fmCallsignAtEnd(true), +m_fmAck("K"), +m_fmAckSpeed(20U), +m_fmAckFrequency(1750U), +m_fmAckDelay(1000U), +m_fmAckLevel(80U), +m_fmTimeoutLevel(80U), +m_fmCTCSSFrequency(88.6F), +m_fmCTCSSThreshold(100U), +m_fmCTCSSLevel(5U), +m_fmInputLevel(50U), +m_fmOutputLevel(50U), +m_fmKerchunkTime(0U), +m_fmHangTime(7U), m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), @@ -244,6 +268,7 @@ m_lcdprocPort(0U), m_lcdprocLocalPort(0U), m_lcdprocDisplayClock(false), m_lcdprocUTC(false), +m_lcdprocDimOnIdle(false), m_lockFileEnabled(false), m_lockFileName(), m_mobileGPSEnabled(false), @@ -304,6 +329,8 @@ bool CConf::read() section = SECTION_NXDN; else if (::strncmp(buffer, "[POCSAG]", 8U) == 0) section = SECTION_POCSAG; + else if (::strncmp(buffer, "[FM]", 4U) == 0) + section = SECTION_FM; else if (::strncmp(buffer, "[D-Star Network]", 16U) == 0) section = SECTION_DSTAR_NETWORK; else if (::strncmp(buffer, "[DMR Network]", 13U) == 0) @@ -652,10 +679,57 @@ bool CConf::read() else if (::strcmp(key, "ModeHang") == 0) m_nxdnModeHang = (unsigned int)::atoi(value); } else if (section == SECTION_POCSAG) { + if (::strcmp(key, "Enable") == 0) + m_pocsagEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Frequency") == 0) + m_pocsagFrequency = (unsigned int)::atoi(value); + } else if (section == SECTION_FM) { if (::strcmp(key, "Enable") == 0) - m_pocsagEnabled = ::atoi(value) == 1; - else if (::strcmp(key, "Frequency") == 0) - m_pocsagFrequency = (unsigned int)::atoi(value); + m_fmEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Callsign") == 0) + m_fmCallsign = value; + else if (::strcmp(key, "CallsignSpeed") == 0) + m_fmCallsignSpeed = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignFrequency") == 0) + m_fmCallsignFrequency = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignTime") == 0) + m_fmCallsignTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignHoldoff") == 0) + m_fmCallsignHoldoff = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignHighLevel") == 0) + m_fmCallsignHighLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignLowLevel") == 0) + m_fmCallsignLowLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignAtStart") == 0) + m_fmCallsignAtStart = ::atoi(value) == 1; + else if (::strcmp(key, "CallsignAtEnd") == 0) + m_fmCallsignAtEnd = ::atoi(value) == 1; + else if (::strcmp(key, "Ack") == 0) + m_fmAck = value; + else if (::strcmp(key, "AckSpeed") == 0) + m_fmAckSpeed = (unsigned int)::atoi(value); + else if (::strcmp(key, "AckFrequency") == 0) + m_fmAckFrequency = (unsigned int)::atoi(value); + else if (::strcmp(key, "AckDelay") == 0) + m_fmAckDelay = (unsigned int)::atoi(value); + else if (::strcmp(key, "AckLevel") == 0) + m_fmAckLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "TimeoutLevel") == 0) + m_fmTimeoutLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSFrequency") == 0) + m_fmCTCSSFrequency = float(::atof(value)); + else if (::strcmp(key, "CTCSSThreshold") == 0) + m_fmCTCSSThreshold = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSLevel") == 0) + m_fmCTCSSLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "InputLevel") == 0) + m_fmInputLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "OutputLevel") == 0) + m_fmOutputLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "KerchunkTime") == 0) + m_fmKerchunkTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "HangTime") == 0) + m_fmHangTime = (unsigned int)::atoi(value); } else if (section == SECTION_DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; @@ -1388,6 +1462,121 @@ unsigned int CConf::getPOCSAGFrequency() const return m_pocsagFrequency; } +bool CConf::getFMEnabled() const +{ + return m_fmEnabled; +} + +std::string CConf::getFMCallsign() const +{ + return m_fmCallsign; +} + +unsigned int CConf::getFMCallsignSpeed() const +{ + return m_fmCallsignSpeed; +} + +unsigned int CConf::getFMCallsignFrequency() const +{ + return m_fmCallsignFrequency; +} + +unsigned int CConf::getFMCallsignTime() const +{ + return m_fmCallsignTime; +} + +unsigned int CConf::getFMCallsignHoldoff() const +{ + return m_fmCallsignHoldoff; +} + +unsigned int CConf::getFMCallsignHighLevel() const +{ + return m_fmCallsignHighLevel; +} + +unsigned int CConf::getFMCallsignLowLevel() const +{ + return m_fmCallsignLowLevel; +} + +bool CConf::getFMCallsignAtStart() const +{ + return m_fmCallsignAtStart; +} + +bool CConf::getFMCallsignAtEnd() const +{ + return m_fmCallsignAtEnd; +} + +std::string CConf::getFMAck() const +{ + return m_fmAck; +} + +unsigned int CConf::getFMAckSpeed() const +{ + return m_fmAckSpeed; +} + +unsigned int CConf::getFMAckFrequency() const +{ + return m_fmAckFrequency; +} + +unsigned int CConf::getFMAckDelay() const +{ + return m_fmAckDelay; +} + +unsigned int CConf::getFMAckLevel() const +{ + return m_fmAckLevel; +} + +unsigned int CConf::getFMTimeoutLevel() const +{ + return m_fmTimeoutLevel; +} + +float CConf::getFMCTCSSFrequency() const +{ + return m_fmCTCSSFrequency; +} + +unsigned int CConf::getFMCTCSSThreshold() const +{ + return m_fmCTCSSThreshold; +} + +unsigned int CConf::getFMCTCSSLevel() const +{ + return m_fmCTCSSLevel; +} + +unsigned int CConf::getFMInputLevel() const +{ + return m_fmInputLevel; +} + +unsigned int CConf::getFMOutputLevel() const +{ + return m_fmOutputLevel; +} + +unsigned int CConf::getFMKerchunkTime() const +{ + return m_fmKerchunkTime; +} + +unsigned int CConf::getFMHangTime() const +{ + return m_fmHangTime; +} + bool CConf::getDStarNetworkEnabled() const { return m_dstarNetworkEnabled; diff --git a/Conf.h b/Conf.h index c76b202..d3189f9 100644 --- a/Conf.h +++ b/Conf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX * * 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 @@ -168,6 +168,31 @@ public: bool getPOCSAGEnabled() const; unsigned int getPOCSAGFrequency() const; + // The FM Section + bool getFMEnabled() const; + std::string getFMCallsign() const; + unsigned int getFMCallsignSpeed() const; + unsigned int getFMCallsignFrequency() const; + unsigned int getFMCallsignTime() const; + unsigned int getFMCallsignHoldoff() const; + unsigned int getFMCallsignHighLevel() const; + unsigned int getFMCallsignLowLevel() const; + bool getFMCallsignAtStart() const; + bool getFMCallsignAtEnd() const; + std::string getFMAck() const; + unsigned int getFMAckSpeed() const; + unsigned int getFMAckFrequency() const; + unsigned int getFMAckDelay() const; + unsigned int getFMAckLevel() const; + unsigned int getFMTimeoutLevel() const; + float getFMCTCSSFrequency() const; + unsigned int getFMCTCSSThreshold() const; + unsigned int getFMCTCSSLevel() const; + unsigned int getFMInputLevel() const; + unsigned int getFMOutputLevel() const; + unsigned int getFMKerchunkTime() const; + unsigned int getFMHangTime() const; + // The D-Star Network section bool getDStarNetworkEnabled() const; std::string getDStarGatewayAddress() const; @@ -403,6 +428,30 @@ private: bool m_pocsagEnabled; unsigned int m_pocsagFrequency; + bool m_fmEnabled; + std::string m_fmCallsign; + unsigned int m_fmCallsignSpeed; + unsigned int m_fmCallsignFrequency; + unsigned int m_fmCallsignTime; + unsigned int m_fmCallsignHoldoff; + unsigned int m_fmCallsignHighLevel; + unsigned int m_fmCallsignLowLevel; + bool m_fmCallsignAtStart; + bool m_fmCallsignAtEnd; + std::string m_fmAck; + unsigned int m_fmAckSpeed; + unsigned int m_fmAckFrequency; + unsigned int m_fmAckDelay; + unsigned int m_fmAckLevel; + unsigned int m_fmTimeoutLevel; + float m_fmCTCSSFrequency; + unsigned int m_fmCTCSSThreshold; + unsigned int m_fmCTCSSLevel; + unsigned int m_fmInputLevel; + unsigned int m_fmOutputLevel; + unsigned int m_fmKerchunkTime; + unsigned int m_fmHangTime; + bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; unsigned int m_dstarGatewayPort; diff --git a/MMDVM.ini b/MMDVM.ini index d6a8d84..6bdeed2 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -138,6 +138,31 @@ RemoteGateway=0 Enable=1 Frequency=439987500 +[FM] +Enable=1 +Callsign=G4KLX +CallsignSpeed=20 +CallsignFrequency=1000 +CallsignTime=10 +CallsignHoldoff=1 +CallsignHighLevel=80 +CallsignLowLevel=40 +CallsignAtStart=1 +CallsignAtEnd=1 +Ack=K +AckSpeed=20 +AckFrequency=1750 +AckDelay=1000 +AckLevel=80 +TimeoutLevel=80 +CTCSSFrequency=88.4 +CTCSSThreshold=100 +CTCSSLevel=5 +InputLevel=50 +OutputLevel=50 +KerchunkTime=0 +HangTime=7 + [D-Star Network] Enable=1 GatewayAddress=127.0.0.1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 53f6d1f..748f3f7 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -150,6 +150,7 @@ m_ysfEnabled(false), m_p25Enabled(false), m_nxdnEnabled(false), m_pocsagEnabled(false), +m_fmEnabled(false), m_cwIdTime(0U), m_dmrLookup(NULL), m_nxdnLookup(NULL), @@ -605,6 +606,63 @@ int CMMDVMHost::run() pocsagTimer.start(); } + if (m_fmEnabled) { + std::string callsign = m_conf.getFMCallsign(); + unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); + unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); + unsigned int callsignTime = m_conf.getFMCallsignTime(); + unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); + unsigned int callsignHighLevel = m_conf.getFMCallsignHighLevel(); + unsigned int callsignLowLevel = m_conf.getFMCallsignLowLevel(); + bool callsignAtStart = m_conf.getFMCallsignAtStart(); + bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + std::string ack = m_conf.getFMCallsign(); + unsigned int ackSpeed = m_conf.getFMAckSpeed(); + unsigned int ackFrequency = m_conf.getFMAckFrequency(); + unsigned int ackDelay = m_conf.getFMAckDelay(); + unsigned int ackLevel = m_conf.getFMAckLevel(); + unsigned int timeout = m_conf.getTimeout(); + unsigned int timeoutLevel = m_conf.getFMTimeoutLevel(); + float ctcssFrequency = m_conf.getFMCTCSSFrequency(); + unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); + unsigned int ctcssLevel = m_conf.getFMCTCSSLevel(); + unsigned int inputLevel = m_conf.getFMInputLevel(); + unsigned int outputLevel = m_conf.getFMOutputLevel(); + unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); + unsigned int hangTime = m_conf.getFMHangTime(); + + LogInfo("FM RF Parameters"); + LogInfo(" Callsign: %s", callsign.c_str()); + LogInfo(" Callsign Speed: %uWPM", callsignSpeed); + LogInfo(" Callsign Frequency: %uHz", callsignFrequency); + LogInfo(" Callsign Time: %umins", callsignTime); + LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); + LogInfo(" Callsign High Level: %u%%", callsignHighLevel); + LogInfo(" Callsign Low Level: %u%%", callsignLowLevel); + LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); + LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); + LogInfo(" Ack: %s", ack.c_str()); + LogInfo(" Ack Speed: %uWPM", ackSpeed); + LogInfo(" Ack Frequency: %uHz", ackFrequency); + LogInfo(" Ack Delay: %ums", ackDelay); + LogInfo(" Ack Level: %u%%", ackLevel); + LogInfo(" Timeout: %us", timeout); + LogInfo(" Timeout Level: %u%%", timeoutLevel); + LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); + LogInfo(" CTCSS Threshold: %u%%", ctcssThreshold); + LogInfo(" CTCSS Level: %u%%", ctcssLevel); + LogInfo(" Input Level: %u%%", inputLevel); + LogInfo(" Output Level: %u%%", outputLevel); + LogInfo(" Kerchunk Time: %us", kerchunkTime); + LogInfo(" Hang Time: %us", hangTime); + + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMAckParams(ack, ackSpeed, ackFrequency, ackDelay, ackLevel); + m_modem->setFMTimeout(timeout, timeoutLevel); + m_modem->setFMCTCSS(ctcssFrequency, ctcssThreshold, ctcssLevel); + m_modem->setFMMisc(inputLevel, outputLevel, kerchunkTime, hangTime); + } + bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); if (remoteControlEnabled) { unsigned int port = m_conf.getRemoteControlPort(); @@ -1450,6 +1508,7 @@ void CMMDVMHost::readParams() m_p25Enabled = m_conf.getP25Enabled(); m_nxdnEnabled = m_conf.getNXDNEnabled(); m_pocsagEnabled = m_conf.getPOCSAGEnabled(); + m_fmEnabled = m_conf.getFMEnabled(); m_duplex = m_conf.getDuplex(); m_callsign = m_conf.getCallsign(); m_id = m_conf.getId(); @@ -1466,6 +1525,7 @@ void CMMDVMHost::readParams() LogInfo(" P25: %s", m_p25Enabled ? "enabled" : "disabled"); LogInfo(" NXDN: %s", m_nxdnEnabled ? "enabled" : "disabled"); LogInfo(" POCSAG: %s", m_pocsagEnabled ? "enabled" : "disabled"); + LogInfo(" FM: %s", m_fmEnabled ? "enabled" : "disabled"); } void CMMDVMHost::setMode(unsigned char mode) diff --git a/MMDVMHost.h b/MMDVMHost.h index 177989a..de22de2 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX * * 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 @@ -93,6 +93,7 @@ private: bool m_p25Enabled; bool m_nxdnEnabled; bool m_pocsagEnabled; + bool m_fmEnabled; unsigned int m_cwIdTime; CDMRLookup* m_dmrLookup; CNXDNLookup* m_nxdnLookup; diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 7b2121c..812c7a4 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -238,6 +238,8 @@ + + @@ -327,6 +329,8 @@ + + diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index 3b299d3..fb8a362 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -293,6 +293,12 @@ Header Files + + Header Files + + + Header Files + @@ -550,5 +556,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/UserDB.cpp b/UserDB.cpp index 9984d63..8c7301b 100644 --- a/UserDB.cpp +++ b/UserDB.cpp @@ -42,7 +42,7 @@ bool CUserDB::lookup(unsigned int id, class CUserDBentry *entry) if (entry != NULL) *entry = m_table.at(id); else - m_table.at(id); + (void)m_table.at(id); rv = true; } catch (...) { @@ -116,8 +116,8 @@ bool CUserDB::makeindex(char* buf, std::unordered_map& index) } try { - index.at(keyRADIO_ID); - index.at(keyCALLSIGN); + (void)index.at(keyRADIO_ID); + (void)index.at(keyCALLSIGN); return true; } catch (...) { return false; @@ -144,8 +144,8 @@ void CUserDB::parse(char* buf, std::unordered_map& index) } try { - ptr.at(keyRADIO_ID); - ptr.at(keyCALLSIGN); + (void)ptr.at(keyRADIO_ID); + (void)ptr.at(keyCALLSIGN); } catch (...) { return; } From 8cd75ce787ce84dd5345707922f00070df57a8c1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 9 Apr 2020 22:55:20 +0100 Subject: [PATCH 08/50] Add the FM repeater modem parameter writes. --- MMDVMHost.cpp | 7 +- Modem.cpp | 267 +++++++++++++++++++++++++++++++++++++++++++++++++- Modem.h | 9 +- Version.h | 4 +- 4 files changed, 280 insertions(+), 7 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 748f3f7..9d4eeb9 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -658,9 +658,10 @@ int CMMDVMHost::run() m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(ack, ackSpeed, ackFrequency, ackDelay, ackLevel); - m_modem->setFMTimeout(timeout, timeoutLevel); - m_modem->setFMCTCSS(ctcssFrequency, ctcssThreshold, ctcssLevel); - m_modem->setFMMisc(inputLevel, outputLevel, kerchunkTime, hangTime); + m_modem->setFMTimeoutParams(timeout, timeoutLevel); + m_modem->setFMCTCSSParams(ctcssFrequency, ctcssThreshold, ctcssLevel); + m_modem->setFMMiscParams(inputLevel, outputLevel, kerchunkTime, hangTime); + m_modem->setFMStart(); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); diff --git a/Modem.cpp b/Modem.cpp index 176a11d..6da68fb 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -76,6 +76,13 @@ const unsigned char MMDVM_NXDN_LOST = 0x41U; const unsigned char MMDVM_POCSAG_DATA = 0x50U; +const unsigned char MMDVM_FM_PARAMS1 = 0x60U; +const unsigned char MMDVM_FM_PARAMS2 = 0x61U; +const unsigned char MMDVM_FM_PARAMS3 = 0x62U; +const unsigned char MMDVM_FM_PARAMS4 = 0x63U; +const unsigned char MMDVM_FM_PARAMS5 = 0x64U; +const unsigned char MMDVM_FM_START = 0x65U; + const unsigned char MMDVM_ACK = 0x70U; const unsigned char MMDVM_NAK = 0x7FU; @@ -1811,6 +1818,264 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } +bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) +{ + assert(m_serial != NULL); + + unsigned char buffer[80U]; + unsigned char len = 10U + callsign.size(); + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = len; + buffer[2U] = MMDVM_FM_PARAMS1; + + buffer[3U] = callsignSpeed; + buffer[4U] = callsignFrequency / 10U; + buffer[5U] = callsignTime; + buffer[6U] = callsignHoldoff; + buffer[7U] = callsignHighLevel; + buffer[8U] = callsignLowLevel; + + buffer[9U] = 0x00U; + if (callsignAtStart) + buffer[9U] |= 0x01U; + if (callsignAtEnd) + buffer[9U] |= 0x02U; + + for (unsigned int i = 0U; i < callsign.size(); i++) + buffer[10U + i] = callsign.at(i); + + // CUtils::dump(1U, "Written", buffer, len); + + int ret = m_serial->write(buffer, len); + if (ret != len) + return false; + + unsigned int count = 0U; + RESP_TYPE_MMDVM resp; + do { + CThread::sleep(10U); + + resp = getResponse(); + if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { + count++; + if (count >= MAX_RESPONSES) { + LogError("The MMDVM is not responding to the SET_FM_PARAMS1 command"); + return false; + } + } + } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); + + // CUtils::dump(1U, "Response", m_buffer, m_length); + + if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { + LogError("Received a NAK to the SET_FM_PARAMS1 command from the modem"); + return false; + } + + return true; +} + +bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel) +{ + assert(m_serial != NULL); + + unsigned char buffer[80U]; + unsigned char len = 7U + ack.size(); + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = len; + buffer[2U] = MMDVM_FM_PARAMS2; + + buffer[3U] = ackSpeed; + buffer[4U] = ackFrequency / 10U; + buffer[5U] = ackDelay / 10U; + buffer[6U] = ackLevel; + + for (unsigned int i = 0U; i < ack.size(); i++) + buffer[7U + i] = ack.at(i); + + // CUtils::dump(1U, "Written", buffer, len); + + int ret = m_serial->write(buffer, len); + if (ret != len) + return false; + + unsigned int count = 0U; + RESP_TYPE_MMDVM resp; + do { + CThread::sleep(10U); + + resp = getResponse(); + if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { + count++; + if (count >= MAX_RESPONSES) { + LogError("The MMDVM is not responding to the SET_FM_PARAMS2 command"); + return false; + } + } + } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); + + // CUtils::dump(1U, "Response", m_buffer, m_length); + + if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { + LogError("Received a NAK to the SET_FM_PARAMS2 command from the modem"); + return false; + } + + return true; +} + +bool CModem::setFMTimeoutParams(unsigned int timeout, unsigned int timeoutLevel) +{ + assert(m_serial != NULL); + + unsigned char buffer[10U]; + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = 5U; + buffer[2U] = MMDVM_FM_PARAMS3; + + buffer[3U] = timeout / 5U; + buffer[4U] = timeoutLevel; + + // CUtils::dump(1U, "Written", buffer, 5U); + + int ret = m_serial->write(buffer, 5U); + if (ret != 5) + return false; + + unsigned int count = 0U; + RESP_TYPE_MMDVM resp; + do { + CThread::sleep(10U); + + resp = getResponse(); + if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { + count++; + if (count >= MAX_RESPONSES) { + LogError("The MMDVM is not responding to the SET_FM_PARAMS3 command"); + return false; + } + } + } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); + + // CUtils::dump(1U, "Response", m_buffer, m_length); + + if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { + LogError("Received a NAK to the SET_FM_PARAMS3 command from the modem"); + return false; + } + + return true; +} + +bool CModem::setFMCTCSSParams(float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel) +{ + assert(m_serial != NULL); + + unsigned char buffer[10U]; + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = 6U; + buffer[2U] = MMDVM_FM_PARAMS4; + + buffer[3U] = ctcssFrequency; // XXX + buffer[4U] = ctcssThreshold; + buffer[5U] = ctcssLevel; + + // CUtils::dump(1U, "Written", buffer, 6U); + + int ret = m_serial->write(buffer, 6U); + if (ret != 6) + return false; + + unsigned int count = 0U; + RESP_TYPE_MMDVM resp; + do { + CThread::sleep(10U); + + resp = getResponse(); + if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { + count++; + if (count >= MAX_RESPONSES) { + LogError("The MMDVM is not responding to the SET_FM_PARAMS4 command"); + return false; + } + } + } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); + + // CUtils::dump(1U, "Response", m_buffer, m_length); + + if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { + LogError("Received a NAK to the SET_FM_PARAMS4 command from the modem"); + return false; + } + + return true; +} + +bool CModem::setFMMiscParams(unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime) +{ + assert(m_serial != NULL); + + unsigned char buffer[10U]; + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = 7U; + buffer[2U] = MMDVM_FM_PARAMS5; + + buffer[3U] = inputLevel; + buffer[4U] = outputLevel; + buffer[5U] = kerchunkTime; + buffer[6U] = hangTime; + + // CUtils::dump(1U, "Written", buffer, 7U); + + int ret = m_serial->write(buffer, 7U); + if (ret != 7) + return false; + + unsigned int count = 0U; + RESP_TYPE_MMDVM resp; + do { + CThread::sleep(10U); + + resp = getResponse(); + if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { + count++; + if (count >= MAX_RESPONSES) { + LogError("The MMDVM is not responding to the SET_FM_PARAMS5 command"); + return false; + } + } + } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); + + // CUtils::dump(1U, "Response", m_buffer, m_length); + + if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { + LogError("Received a NAK to the SET_FM_PARAMS5 command from the modem"); + return false; + } + + return true; +} + +bool CModem::setFMStart() +{ + assert(m_serial != NULL); + + unsigned char buffer[10U]; + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = 3U; + buffer[2U] = MMDVM_FM_START; + + // CUtils::dump(1U, "Written", buffer, 3U); + + return m_serial->write(buffer, 3U) == 3; +} + void CModem::printDebug() { if (m_buffer[2U] == MMDVM_DEBUG1) { diff --git a/Modem.h b/Modem.h index 30af401..7ac387b 100644 --- a/Modem.h +++ b/Modem.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -45,6 +45,13 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); + virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); + virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel); + virtual bool setFMTimeoutParams(unsigned int timeout, unsigned int timeoutLevel); + virtual bool setFMCTCSSParams(float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel); + virtual bool setFMMiscParams(unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMStart(); + virtual bool open(); virtual unsigned int readDStarData(unsigned char* data); diff --git a/Version.h b/Version.h index bbe810c..430e00d 100644 --- a/Version.h +++ b/Version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX * * 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 @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20190131"; +const char* VERSION = "20200409"; #endif From c381f2ceac554dfd349807ddc6a7c5bc6687fb2c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 10 Apr 2020 13:52:49 +0100 Subject: [PATCH 09/50] Convert the callsign and ack to upper case. --- Conf.cpp | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index d857c53..07a5eea 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -683,30 +683,37 @@ bool CConf::read() m_pocsagEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Frequency") == 0) m_pocsagFrequency = (unsigned int)::atoi(value); - } else if (section == SECTION_FM) { + } + else if (section == SECTION_FM) { if (::strcmp(key, "Enable") == 0) m_fmEnabled = ::atoi(value) == 1; - else if (::strcmp(key, "Callsign") == 0) + else if (::strcmp(key, "Callsign") == 0) { + // Convert the callsign to upper case + for (unsigned int i = 0U; value[i] != 0; i++) + value[i] = ::toupper(value[i]); m_fmCallsign = value; - else if (::strcmp(key, "CallsignSpeed") == 0) - m_fmCallsignSpeed = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignFrequency") == 0) - m_fmCallsignFrequency = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignTime") == 0) - m_fmCallsignTime = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignHoldoff") == 0) - m_fmCallsignHoldoff = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignHighLevel") == 0) - m_fmCallsignHighLevel = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignLowLevel") == 0) - m_fmCallsignLowLevel = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignAtStart") == 0) - m_fmCallsignAtStart = ::atoi(value) == 1; - else if (::strcmp(key, "CallsignAtEnd") == 0) - m_fmCallsignAtEnd = ::atoi(value) == 1; - else if (::strcmp(key, "Ack") == 0) - m_fmAck = value; - else if (::strcmp(key, "AckSpeed") == 0) + } else if (::strcmp(key, "CallsignSpeed") == 0) + m_fmCallsignSpeed = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignFrequency") == 0) + m_fmCallsignFrequency = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignTime") == 0) + m_fmCallsignTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignHoldoff") == 0) + m_fmCallsignHoldoff = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignHighLevel") == 0) + m_fmCallsignHighLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignLowLevel") == 0) + m_fmCallsignLowLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "CallsignAtStart") == 0) + m_fmCallsignAtStart = ::atoi(value) == 1; + else if (::strcmp(key, "CallsignAtEnd") == 0) + m_fmCallsignAtEnd = ::atoi(value) == 1; + else if (::strcmp(key, "Ack") == 0) { + // Convert the ack to upper case + for (unsigned int i = 0U; value[i] != 0; i++) + value[i] = ::toupper(value[i]); + m_fmAck = value; + } else if (::strcmp(key, "AckSpeed") == 0) m_fmAckSpeed = (unsigned int)::atoi(value); else if (::strcmp(key, "AckFrequency") == 0) m_fmAckFrequency = (unsigned int)::atoi(value); From 5df1fe551f232c25dff1302ff1f9350062b93995 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 11 Apr 2020 13:12:19 +0900 Subject: [PATCH 10/50] add IPv6 support for RemoteControl To specify IP(v4/v6) address for RemoteControl port, add Address parameter in [RemoteControl] section to MMDVM.ini. Different from other Address(es), the default IP address of RemoteControl is 127.0.0.1 for security. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- RemoteControl.cpp | 6 +++--- RemoteControl.h | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 9325a1b..e365827 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -250,6 +250,7 @@ m_mobileGPSEnabled(false), m_mobileGPSAddress(), m_mobileGPSPort(0U), m_remoteControlEnabled(false), +m_remoteControlAddress("127.0.0.1"), m_remoteControlPort(0U) { } @@ -838,6 +839,8 @@ bool CConf::read() } else if (section == SECTION_REMOTE_CONTROL) { if (::strcmp(key, "Enable") == 0) m_remoteControlEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Address") == 0) + m_remoteControlAddress = value; else if (::strcmp(key, "Port") == 0) m_remoteControlPort = (unsigned int)::atoi(value); } @@ -1794,6 +1797,11 @@ bool CConf::getRemoteControlEnabled() const return m_remoteControlEnabled; } +std::string CConf::getRemoteControlAddress() const +{ + return m_remoteControlAddress; +} + unsigned int CConf::getRemoteControlPort() const { return m_remoteControlPort; diff --git a/Conf.h b/Conf.h index c76b202..42fa261 100644 --- a/Conf.h +++ b/Conf.h @@ -276,6 +276,7 @@ public: // The Remote Control section bool getRemoteControlEnabled() const; + std::string getRemoteControlAddress() const; unsigned int getRemoteControlPort() const; private: @@ -497,6 +498,7 @@ private: unsigned int m_mobileGPSPort; bool m_remoteControlEnabled; + std::string m_remoteControlAddress; unsigned int m_remoteControlPort; }; diff --git a/MMDVM.ini b/MMDVM.ini index d6a8d84..bf07c6a 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -257,4 +257,5 @@ Port=7834 [Remote Control] Enable=0 +Address=127.0.0.1 Port=7642 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9f792e5..5ee837a 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -606,12 +606,14 @@ int CMMDVMHost::run() bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); if (remoteControlEnabled) { + std::string address = m_conf.getRemoteControlAddress(); unsigned int port = m_conf.getRemoteControlPort(); LogInfo("Remote Control Parameters"); + LogInfo(" Address: %s", address.c_str()); LogInfo(" Port: %u", port); - m_remoteControl = new CRemoteControl(port); + m_remoteControl = new CRemoteControl(address, port); ret = m_remoteControl->open(); if (!ret) { diff --git a/RemoteControl.cpp b/RemoteControl.cpp index 0c29791..e982894 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -29,8 +29,8 @@ const unsigned int PAGE_ARGS = 3U; const unsigned int BUFFER_LENGTH = 100U; -CRemoteControl::CRemoteControl(unsigned int port) : -m_socket(port), +CRemoteControl::CRemoteControl(const std::string address, unsigned int port) : +m_socket(address, port), m_command(RCD_NONE), m_args() { @@ -43,7 +43,7 @@ CRemoteControl::~CRemoteControl() bool CRemoteControl::open() { - return m_socket.open(AF_INET); /* XXX IPv4 only */ + return m_socket.open(); } REMOTE_COMMAND CRemoteControl::getCommand() diff --git a/RemoteControl.h b/RemoteControl.h index 479987a..079d983 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -38,7 +38,7 @@ enum REMOTE_COMMAND { class CRemoteControl { public: - CRemoteControl(unsigned int port); + CRemoteControl(const std::string address, unsigned int port); ~CRemoteControl(); bool open(); From dcdfca39d7ae1cba1d8bfa5b56f5b23ac1155ca4 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 11 Apr 2020 20:42:05 +0100 Subject: [PATCH 11/50] Add FM mode display. --- CASTInfo.cpp | 6 +- CASTInfo.h | 3 +- Defines.h | 3 + Display.cpp | 14 ++++- Display.h | 4 +- HD44780.cpp | 31 +++++++++++ HD44780.h | 3 +- LCDproc.cpp | 19 ++++++- LCDproc.h | 4 +- MMDVMHost.cpp | 50 +++++++++++++++-- Modem.cpp | 142 +++++++++--------------------------------------- Modem.h | 7 +-- Nextion.cpp | 22 +++++++- Nextion.h | 3 +- NullDisplay.cpp | 6 +- NullDisplay.h | 3 +- TFTSerial.cpp | 18 +++++- TFTSerial.h | 3 +- TFTSurenoo.cpp | 10 +++- TFTSurenoo.h | 3 +- Version.h | 2 +- 21 files changed, 213 insertions(+), 143 deletions(-) diff --git a/CASTInfo.cpp b/CASTInfo.cpp index b1bed7f..cce34d8 100644 --- a/CASTInfo.cpp +++ b/CASTInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -76,6 +76,10 @@ void CCASTInfo::setQuitInt() { } +void CCASTInfo::setFMInt() +{ +} + void CCASTInfo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { if (m_modem != NULL) diff --git a/CASTInfo.h b/CASTInfo.h index 326ecad..9254995 100644 --- a/CASTInfo.h +++ b/CASTInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -40,6 +40,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); diff --git a/Defines.h b/Defines.h index 5c7fe76..18c103e 100644 --- a/Defines.h +++ b/Defines.h @@ -26,6 +26,9 @@ const unsigned char MODE_YSF = 3U; const unsigned char MODE_P25 = 4U; const unsigned char MODE_NXDN = 5U; const unsigned char MODE_POCSAG = 6U; + +const unsigned char MODE_FM = 10U; + const unsigned char MODE_CW = 98U; const unsigned char MODE_LOCKOUT = 99U; const unsigned char MODE_ERROR = 100U; diff --git a/Display.cpp b/Display.cpp index 5a74747..0b47b64 100644 --- a/Display.cpp +++ b/Display.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -101,6 +101,17 @@ void CDisplay::setQuit() setQuitInt(); } +void CDisplay::setFM() +{ + m_timer1.stop(); + m_timer2.stop(); + + m_mode1 = MODE_FM; + m_mode2 = MODE_FM; + + setFMInt(); +} + void CDisplay::writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); @@ -190,6 +201,7 @@ void CDisplay::writeDMRBER(unsigned int slotNo, float ber) { writeDMRBERInt(slotNo, ber); } + void CDisplay::clearDMR(unsigned int slotNo) { if (slotNo == 1U) { diff --git a/Display.h b/Display.h index 74fa25b..17caa41 100644 --- a/Display.h +++ b/Display.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -42,6 +42,7 @@ public: void setLockout(); void setError(const char* text); void setQuit(); + void setFM(); void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); void writeDStarRSSI(unsigned char rssi); @@ -87,6 +88,7 @@ protected: virtual void setLockoutInt() = 0; virtual void setErrorInt(const char* text) = 0; virtual void setQuitInt() = 0; + virtual void setFMInt() = 0; virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) = 0; virtual void writeDStarRSSIInt(unsigned char rssi); diff --git a/HD44780.cpp b/HD44780.cpp index 970f174..ebbfcac 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -399,6 +399,37 @@ void CHD44780::setQuitInt() m_dmr = false; } +void CHD44780::setIdleInt() +{ + m_clockDisplayTimer.stop(); + ::lcdClear(m_fd); + +#ifdef ADAFRUIT_DISPLAY + adafruitLCDColour(AC_WHITE); +#endif + + if (m_pwm) { + if (m_pwmPin != 1U) + ::softPwmWrite(m_pwmPin, m_pwmDim); + else + ::pwmWrite(m_pwmPin, (m_pwmDim / 100) * 1024); + } + + // Print callsign and ID at on top row for all screen sizes + ::lcdPosition(m_fd, 0, 0); + ::lcdPrintf(m_fd, "%-6s", m_callsign.c_str()); + ::lcdPosition(m_fd, m_cols - 7, 0); + ::lcdPrintf(m_fd, "%7u", m_dmrid); + + // Print MMDVM and Idle on bottom row for all screen sizes + ::lcdPosition(m_fd, 0, m_rows - 1); + ::lcdPuts(m_fd, "MMDVM"); + ::lcdPosition(m_fd, m_cols - 4, m_rows - 1); + ::lcdPuts(m_fd, "FM"); // Gets overwritten by clock on 2 line screen + + m_dmr = false; +} + void CHD44780::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); diff --git a/HD44780.h b/HD44780.h index 6160482..18c036e 100644 --- a/HD44780.h +++ b/HD44780.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX & Tony Corbett G0WFV + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX & Tony Corbett G0WFV * * 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 @@ -101,6 +101,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void writeDStarRSSIInt(unsigned char rssi); diff --git a/LCDproc.cpp b/LCDproc.cpp index 8ef2721..96d9487 100644 --- a/LCDproc.cpp +++ b/LCDproc.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016,2017,2018 by Tony Corbett G0WFV - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -241,6 +241,23 @@ void CLCDproc::setQuitInt() m_dmr = false; } +void CLCDproc::setFMInt() +{ + m_clockDisplayTimer.stop(); // Stop the clock display + + if (m_screensDefined) { + socketPrintf(m_socketfd, "screen_set DStar -priority hidden"); + socketPrintf(m_socketfd, "screen_set DMR -priority hidden"); + socketPrintf(m_socketfd, "screen_set YSF -priority hidden"); + socketPrintf(m_socketfd, "screen_set P25 -priority hidden"); + socketPrintf(m_socketfd, "screen_set NXDN -priority hidden"); + socketPrintf(m_socketfd, "widget_set Status Status %u %u FM", m_cols - 6, m_rows); + socketPrintf(m_socketfd, "output 0"); // Clear all LEDs + } + + m_dmr = false; +} + void CLCDproc::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); diff --git a/LCDproc.h b/LCDproc.h index 2554d36..0352251 100644 --- a/LCDproc.h +++ b/LCDproc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016,2017 by Tony Corbett G0WFV - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -40,8 +40,8 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); - virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void writeDStarRSSIInt(unsigned char rssi); virtual void clearDStarInt(); diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9d4eeb9..157c5bb 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -658,10 +658,7 @@ int CMMDVMHost::run() m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(ack, ackSpeed, ackFrequency, ackDelay, ackLevel); - m_modem->setFMTimeoutParams(timeout, timeoutLevel); - m_modem->setFMCTCSSParams(ctcssFrequency, ctcssThreshold, ctcssLevel); - m_modem->setFMMiscParams(inputLevel, outputLevel, kerchunkTime, hangTime); - m_modem->setFMStart(); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, inputLevel, outputLevel, kerchunkTime, hangTime); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); @@ -701,6 +698,12 @@ int CMMDVMHost::run() else if (!error && m_mode == MODE_ERROR) setMode(MODE_IDLE); + unsigned char mode = m_modem->getMode(); + if (mode == MODE_FM && m_mode != MODE_FM) + setMode(mode); + else if (mode != MODE_FM && m_mode == MODE_FM) + setMode(mode); + if (m_ump != NULL) { bool tx = m_modem->hasTX(); m_ump->setTX(tx); @@ -1743,6 +1746,45 @@ void CMMDVMHost::setMode(unsigned char mode) createLockFile("POCSAG"); break; + case MODE_FM: + LogMessage("Mode set to FM"); + if (m_dstarNetwork != NULL) + m_dstarNetwork->enable(false); + if (m_dmrNetwork != NULL) + m_dmrNetwork->enable(false); + if (m_ysfNetwork != NULL) + m_ysfNetwork->enable(false); + if (m_p25Network != NULL) + m_p25Network->enable(false); + if (m_nxdnNetwork != NULL) + m_nxdnNetwork->enable(false); + if (m_pocsagNetwork != NULL) + m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); + if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { + m_modem->writeDMRStart(false); + m_dmrTXTimer.stop(); + } + if (m_ump != NULL) + m_ump->setMode(MODE_FM); + m_display->setFM(); + m_mode = MODE_FM; + m_modeTimer.stop(); + m_cwIdTimer.stop(); + createLockFile("FM"); + break; + case MODE_LOCKOUT: LogMessage("Mode set to Lockout"); if (m_dstarNetwork != NULL) diff --git a/Modem.cpp b/Modem.cpp index 6da68fb..798d4fe 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -79,9 +79,6 @@ const unsigned char MMDVM_POCSAG_DATA = 0x50U; const unsigned char MMDVM_FM_PARAMS1 = 0x60U; const unsigned char MMDVM_FM_PARAMS2 = 0x61U; const unsigned char MMDVM_FM_PARAMS3 = 0x62U; -const unsigned char MMDVM_FM_PARAMS4 = 0x63U; -const unsigned char MMDVM_FM_PARAMS5 = 0x64U; -const unsigned char MMDVM_FM_START = 0x65U; const unsigned char MMDVM_ACK = 0x70U; const unsigned char MMDVM_NAK = 0x7FU; @@ -168,11 +165,12 @@ m_tx(false), m_cd(false), m_lockout(false), m_error(false), +m_mode(MODE_IDLE), m_hwType(HWT_UNKNOWN) { - assert(!port.empty()); - m_buffer = new unsigned char[BUFFER_LENGTH]; + + assert(!port.empty()); } CModem::~CModem() @@ -525,6 +523,8 @@ void CModem::clock(unsigned int ms) m_nxdnSpace = 0U; m_pocsagSpace = 0U; + m_mode = m_buffer[4U]; + m_tx = (m_buffer[5U] & 0x01U) == 0x01U; bool adcOverflow = (m_buffer[5U] & 0x02U) == 0x02U; @@ -1713,6 +1713,11 @@ HW_TYPE CModem::getHWType() const return m_hwType; } +unsigned char CModem::getMode() const +{ + return m_mode; +} + bool CModem::setMode(unsigned char mode) { assert(m_serial != NULL); @@ -1926,23 +1931,32 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig return true; } -bool CModem::setFMTimeoutParams(unsigned int timeout, unsigned int timeoutLevel) +bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); - unsigned char buffer[10U]; + unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 5U; + buffer[1U] = 12U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; buffer[4U] = timeoutLevel; - // CUtils::dump(1U, "Written", buffer, 5U); + buffer[5U] = (unsigned char)ctcssFrequency; + buffer[6U] = ctcssThreshold; + buffer[7U] = ctcssLevel; - int ret = m_serial->write(buffer, 5U); - if (ret != 5) + buffer[8U] = inputLevel; + buffer[9U] = outputLevel; + buffer[10U] = kerchunkTime; + buffer[11U] = hangTime; + + // CUtils::dump(1U, "Written", buffer, 12U); + + int ret = m_serial->write(buffer, 12U); + if (ret != 12) return false; unsigned int count = 0U; @@ -1970,112 +1984,6 @@ bool CModem::setFMTimeoutParams(unsigned int timeout, unsigned int timeoutLevel) return true; } -bool CModem::setFMCTCSSParams(float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel) -{ - assert(m_serial != NULL); - - unsigned char buffer[10U]; - - buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 6U; - buffer[2U] = MMDVM_FM_PARAMS4; - - buffer[3U] = ctcssFrequency; // XXX - buffer[4U] = ctcssThreshold; - buffer[5U] = ctcssLevel; - - // CUtils::dump(1U, "Written", buffer, 6U); - - int ret = m_serial->write(buffer, 6U); - if (ret != 6) - return false; - - unsigned int count = 0U; - RESP_TYPE_MMDVM resp; - do { - CThread::sleep(10U); - - resp = getResponse(); - if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { - count++; - if (count >= MAX_RESPONSES) { - LogError("The MMDVM is not responding to the SET_FM_PARAMS4 command"); - return false; - } - } - } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); - - // CUtils::dump(1U, "Response", m_buffer, m_length); - - if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { - LogError("Received a NAK to the SET_FM_PARAMS4 command from the modem"); - return false; - } - - return true; -} - -bool CModem::setFMMiscParams(unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime) -{ - assert(m_serial != NULL); - - unsigned char buffer[10U]; - - buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 7U; - buffer[2U] = MMDVM_FM_PARAMS5; - - buffer[3U] = inputLevel; - buffer[4U] = outputLevel; - buffer[5U] = kerchunkTime; - buffer[6U] = hangTime; - - // CUtils::dump(1U, "Written", buffer, 7U); - - int ret = m_serial->write(buffer, 7U); - if (ret != 7) - return false; - - unsigned int count = 0U; - RESP_TYPE_MMDVM resp; - do { - CThread::sleep(10U); - - resp = getResponse(); - if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) { - count++; - if (count >= MAX_RESPONSES) { - LogError("The MMDVM is not responding to the SET_FM_PARAMS5 command"); - return false; - } - } - } while (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK); - - // CUtils::dump(1U, "Response", m_buffer, m_length); - - if (resp == RTM_OK && m_buffer[2U] == MMDVM_NAK) { - LogError("Received a NAK to the SET_FM_PARAMS5 command from the modem"); - return false; - } - - return true; -} - -bool CModem::setFMStart() -{ - assert(m_serial != NULL); - - unsigned char buffer[10U]; - - buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 3U; - buffer[2U] = MMDVM_FM_START; - - // CUtils::dump(1U, "Written", buffer, 3U); - - return m_serial->write(buffer, 3U) == 3; -} - void CModem::printDebug() { if (m_buffer[2U] == MMDVM_DEBUG1) { diff --git a/Modem.h b/Modem.h index 7ac387b..068c4d6 100644 --- a/Modem.h +++ b/Modem.h @@ -47,10 +47,7 @@ public: virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel); - virtual bool setFMTimeoutParams(unsigned int timeout, unsigned int timeoutLevel); - virtual bool setFMCTCSSParams(float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel); - virtual bool setFMMiscParams(unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime); - virtual bool setFMStart(); + virtual bool setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); @@ -102,6 +99,7 @@ public: virtual bool writeSerial(const unsigned char* data, unsigned int length); + virtual unsigned char getMode() const; virtual bool setMode(unsigned char mode); virtual bool sendCWId(const std::string& callsign); @@ -181,6 +179,7 @@ private: bool m_cd; bool m_lockout; bool m_error; + unsigned char m_mode; HW_TYPE m_hwType; bool readVersion(); diff --git a/Nextion.cpp b/Nextion.cpp index 4f9c9ca..f15d6cf 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -102,7 +102,6 @@ bool CNextion::open() return true; } - void CNextion::setIdleInt() { // a few bits borrowed from Lieven De Samblanx ON7LDS, NextionDriver @@ -240,6 +239,25 @@ void CNextion::setQuitInt() m_mode = MODE_QUIT; } +void CNextion::setFMInt() +{ + sendCommand("page MMDVM"); + sendCommandAction(1U); + + char command[20]; + if (m_brightness > 0) { + ::sprintf(command, "dim=%u", m_brightness); + sendCommand(command); + } + + sendCommand("t0.txt=\"FM\""); + sendCommandAction(15U); + + m_clockDisplayTimer.stop(); + + m_mode = MODE_FM; +} + void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); diff --git a/Nextion.h b/Nextion.h index 1c70134..d9896e0 100644 --- a/Nextion.h +++ b/Nextion.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -41,6 +41,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void writeDStarRSSIInt(unsigned char rssi); diff --git a/NullDisplay.cpp b/NullDisplay.cpp index 6219ec8..d08cf00 100644 --- a/NullDisplay.cpp +++ b/NullDisplay.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -60,6 +60,10 @@ void CNullDisplay::setQuitInt() { } +void CNullDisplay::setFMInt() +{ +} + void CNullDisplay::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { #if defined(RASPBERRY_PI) diff --git a/NullDisplay.h b/NullDisplay.h index 50f40b8..ac99dd8 100644 --- a/NullDisplay.h +++ b/NullDisplay.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -38,6 +38,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); diff --git a/TFTSerial.cpp b/TFTSerial.cpp index c2338f3..59867b9 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -161,6 +161,22 @@ void CTFTSerial::setQuitInt() m_mode = MODE_QUIT; } +void CTFTSerial::setFMInt() +{ + // Clear the screen + clearScreen(); + + setFontSize(FONT_LARGE); + + // Draw MMDVM logo + displayBitmap(0U, 0U, "MMDVM_sm.bmp"); + + gotoPosPixel(20U, 60U); + displayText("FM"); + + m_mode = MODE_FM; +} + void CTFTSerial::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); diff --git a/TFTSerial.h b/TFTSerial.h index 296a4b1..314e555 100644 --- a/TFTSerial.h +++ b/TFTSerial.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -40,6 +40,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); diff --git a/TFTSurenoo.cpp b/TFTSurenoo.cpp index a2eba9e..5f0ddbd 100644 --- a/TFTSurenoo.cpp +++ b/TFTSurenoo.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2019 by SASANO Takayoshi JG1UAA - * Copyright (C) 2015,2016,2018,2019 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2018,2019,2020 by Jonathan Naylor G4KLX * * 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 @@ -174,6 +174,14 @@ void CTFTSurenoo::setQuitInt() m_mode = MODE_QUIT; } +void CTFTSurenoo::setFMInt() +{ + setModeLine(STR_MMDVM); + setStatusLine(statusLineNo(1), "FM"); + + m_mode = MODE_FM; +} + void CTFTSurenoo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(my1 != NULL); diff --git a/TFTSurenoo.h b/TFTSurenoo.h index d058c3e..0c54c24 100644 --- a/TFTSurenoo.h +++ b/TFTSurenoo.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2019 by SASANO Takayoshi JG1UAA - * Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -42,6 +42,7 @@ protected: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); diff --git a/Version.h b/Version.h index 430e00d..d1073ff 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200409"; +const char* VERSION = "20200411"; #endif From 927f31cdfa5a6c81986070ea26a1f769eb78da41 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 12 Apr 2020 15:10:51 +0100 Subject: [PATCH 12/50] Move the levels to the overall MMDVM control message. --- Conf.cpp | 36 ++++++++++++++++++------------------ Conf.h | 8 ++++---- MMDVM.ini | 4 ++-- MMDVMHost.cpp | 15 +++++++-------- Modem.cpp | 39 ++++++++++++++++++++++++--------------- Modem.h | 9 ++++++--- 6 files changed, 61 insertions(+), 50 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 07a5eea..ba4964c 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -110,6 +110,8 @@ m_modemYSFTXLevel(50.0F), m_modemP25TXLevel(50.0F), m_modemNXDNTXLevel(50.0F), m_modemPOCSAGTXLevel(50.0F), +m_modemFMTXLevel(50.0F), +m_modemFMRXLevel(50.0F), m_modemRSSIMappingFile(), m_modemTrace(false), m_modemDebug(false), @@ -190,8 +192,6 @@ m_fmTimeoutLevel(80U), m_fmCTCSSFrequency(88.6F), m_fmCTCSSThreshold(100U), m_fmCTCSSLevel(5U), -m_fmInputLevel(50U), -m_fmOutputLevel(50U), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_dstarNetworkEnabled(false), @@ -480,9 +480,9 @@ bool CConf::read() else if (::strcmp(key, "RFLevel") == 0) m_modemRFLevel = float(::atof(value)); else if (::strcmp(key, "RXLevel") == 0) - m_modemRXLevel = float(::atof(value)); + m_modemFMRXLevel = m_modemRXLevel = float(::atof(value)); else if (::strcmp(key, "TXLevel") == 0) - m_modemCWIdTXLevel = m_modemDStarTXLevel = m_modemDMRTXLevel = m_modemYSFTXLevel = m_modemP25TXLevel = m_modemNXDNTXLevel = float(::atof(value)); + m_modemFMTXLevel = m_modemCWIdTXLevel = m_modemDStarTXLevel = m_modemDMRTXLevel = m_modemYSFTXLevel = m_modemP25TXLevel = m_modemNXDNTXLevel = float(::atof(value)); else if (::strcmp(key, "CWIdTXLevel") == 0) m_modemCWIdTXLevel = float(::atof(value)); else if (::strcmp(key, "D-StarTXLevel") == 0) @@ -497,6 +497,10 @@ bool CConf::read() m_modemNXDNTXLevel = float(::atof(value)); else if (::strcmp(key, "POCSAGTXLevel") == 0) m_modemPOCSAGTXLevel = float(::atof(value)); + else if (::strcmp(key, "FMTXLevel") == 0) + m_modemFMTXLevel = float(::atof(value)); + else if (::strcmp(key, "FMRXLevel") == 0) + m_modemFMRXLevel = float(::atof(value)); else if (::strcmp(key, "RSSIMappingFile") == 0) m_modemRSSIMappingFile = value; else if (::strcmp(key, "Trace") == 0) @@ -729,10 +733,6 @@ bool CConf::read() m_fmCTCSSThreshold = (unsigned int)::atoi(value); else if (::strcmp(key, "CTCSSLevel") == 0) m_fmCTCSSLevel = (unsigned int)::atoi(value); - else if (::strcmp(key, "InputLevel") == 0) - m_fmInputLevel = (unsigned int)::atoi(value); - else if (::strcmp(key, "OutputLevel") == 0) - m_fmOutputLevel = (unsigned int)::atoi(value); else if (::strcmp(key, "KerchunkTime") == 0) m_fmKerchunkTime = (unsigned int)::atoi(value); else if (::strcmp(key, "HangTime") == 0) @@ -1164,6 +1164,16 @@ float CConf::getModemPOCSAGTXLevel() const return m_modemPOCSAGTXLevel; } +float CConf::getModemFMTXLevel() const +{ + return m_modemFMTXLevel; +} + +float CConf::getModemFMRXLevel() const +{ + return m_modemFMRXLevel; +} + std::string CConf::getModemRSSIMappingFile () const { return m_modemRSSIMappingFile; @@ -1564,16 +1574,6 @@ unsigned int CConf::getFMCTCSSLevel() const return m_fmCTCSSLevel; } -unsigned int CConf::getFMInputLevel() const -{ - return m_fmInputLevel; -} - -unsigned int CConf::getFMOutputLevel() const -{ - return m_fmOutputLevel; -} - unsigned int CConf::getFMKerchunkTime() const { return m_fmKerchunkTime; diff --git a/Conf.h b/Conf.h index d3189f9..3cdfccc 100644 --- a/Conf.h +++ b/Conf.h @@ -90,6 +90,8 @@ public: float getModemP25TXLevel() const; float getModemNXDNTXLevel() const; float getModemPOCSAGTXLevel() const; + float getModemFMTXLevel() const; + float getModemFMRXLevel() const; std::string getModemRSSIMappingFile() const; bool getModemTrace() const; bool getModemDebug() const; @@ -188,8 +190,6 @@ public: float getFMCTCSSFrequency() const; unsigned int getFMCTCSSThreshold() const; unsigned int getFMCTCSSLevel() const; - unsigned int getFMInputLevel() const; - unsigned int getFMOutputLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; @@ -358,6 +358,8 @@ private: float m_modemP25TXLevel; float m_modemNXDNTXLevel; float m_modemPOCSAGTXLevel; + float m_modemFMTXLevel; + float m_modemFMRXLevel; std::string m_modemRSSIMappingFile; bool m_modemTrace; bool m_modemDebug; @@ -447,8 +449,6 @@ private: float m_fmCTCSSFrequency; unsigned int m_fmCTCSSThreshold; unsigned int m_fmCTCSSLevel; - unsigned int m_fmInputLevel; - unsigned int m_fmOutputLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/MMDVM.ini b/MMDVM.ini index 6bdeed2..d44374d 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -65,6 +65,8 @@ RFLevel=100 # P25TXLevel=50 # NXDNTXLevel=50 # POCSAGTXLevel=50 +# FMTXLevel=50 +# FMRXLevel=50 RSSIMappingFile=RSSI.dat Trace=0 Debug=0 @@ -158,8 +160,6 @@ TimeoutLevel=80 CTCSSFrequency=88.4 CTCSSThreshold=100 CTCSSLevel=5 -InputLevel=50 -OutputLevel=50 KerchunkTime=0 HangTime=7 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 157c5bb..72442fe 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -626,8 +626,6 @@ int CMMDVMHost::run() float ctcssFrequency = m_conf.getFMCTCSSFrequency(); unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); unsigned int ctcssLevel = m_conf.getFMCTCSSLevel(); - unsigned int inputLevel = m_conf.getFMInputLevel(); - unsigned int outputLevel = m_conf.getFMOutputLevel(); unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); @@ -651,14 +649,12 @@ int CMMDVMHost::run() LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); LogInfo(" CTCSS Threshold: %u%%", ctcssThreshold); LogInfo(" CTCSS Level: %u%%", ctcssLevel); - LogInfo(" Input Level: %u%%", inputLevel); - LogInfo(" Output Level: %u%%", outputLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(ack, ackSpeed, ackFrequency, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, inputLevel, outputLevel, kerchunkTime, hangTime); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); @@ -1211,6 +1207,8 @@ bool CMMDVMHost::createModem() float p25TXLevel = m_conf.getModemP25TXLevel(); float nxdnTXLevel = m_conf.getModemNXDNTXLevel(); float pocsagTXLevel = m_conf.getModemPOCSAGTXLevel(); + float fmTXLevel = m_conf.getModemFMTXLevel(); + float fmRXLevel = m_conf.getModemFMRXLevel(); bool trace = m_conf.getModemTrace(); bool debug = m_conf.getModemDebug(); unsigned int colorCode = m_conf.getDMRColorCode(); @@ -1248,13 +1246,14 @@ bool CMMDVMHost::createModem() LogInfo(" P25 TX Level: %.1f%%", p25TXLevel); LogInfo(" NXDN TX Level: %.1f%%", nxdnTXLevel); LogInfo(" POCSAG TX Level: %.1f%%", pocsagTXLevel); - LogInfo(" RX Frequency: %uHz (%uHz)", rxFrequency, rxFrequency + rxOffset); + LogInfo(" FM TX Level: %.1f%%", fmTXLevel); + LogInfo(" FM RX Level: %.1f%%", fmRXLevel); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); m_modem->setSerialParams(protocol,address); - m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled); - m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel); + m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); + m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel, fmRXLevel); m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); m_modem->setDMRParams(colorCode); m_modem->setYSFParams(lowDeviation, txHang); diff --git a/Modem.cpp b/Modem.cpp index 798d4fe..6f37c4d 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -118,6 +118,8 @@ m_ysfTXLevel(0U), m_p25TXLevel(0U), m_nxdnTXLevel(0U), m_pocsagTXLevel(0U), +m_fmTXLevel(0U), +m_fmRXLevel(0U), m_trace(trace), m_debug(debug), m_rxFrequency(0U), @@ -129,6 +131,7 @@ m_ysfEnabled(false), m_p25Enabled(false), m_nxdnEnabled(false), m_pocsagEnabled(false), +m_fmEnabled(false), m_rxDCOffset(0), m_txDCOffset(0), m_serial(NULL), @@ -198,7 +201,7 @@ void CModem::setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int tx m_pocsagFrequency = pocsagFrequency + txOffset; } -void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled) +void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled) { m_dstarEnabled = dstarEnabled; m_dmrEnabled = dmrEnabled; @@ -206,9 +209,10 @@ void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, m_p25Enabled = p25Enabled; m_nxdnEnabled = nxdnEnabled; m_pocsagEnabled = pocsagEnabled; + m_fmEnabled = fmEnabled; } -void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagTXLevel) +void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagTXLevel, float fmTXLevel, float fmRXLevel) { m_rxLevel = rxLevel; m_cwIdTXLevel = cwIdTXLevel; @@ -218,6 +222,8 @@ void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, flo m_p25TXLevel = p25TXLevel; m_nxdnTXLevel = nxdnTXLevel; m_pocsagTXLevel = pocsagTXLevel; + m_fmTXLevel = fmTXLevel; + m_fmRXLevel = fmRXLevel; } void CModem::setDMRParams(unsigned int colorCode) @@ -1444,7 +1450,7 @@ bool CModem::setConfig() buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 21U; + buffer[1U] = 23U; buffer[2U] = MMDVM_SET_CONFIG; @@ -1475,6 +1481,8 @@ bool CModem::setConfig() buffer[4U] |= 0x10U; if (m_pocsagEnabled) buffer[4U] |= 0x20U; + if (m_fmEnabled) + buffer[4U] |= 0x40U; buffer[5U] = m_txDelay / 10U; // In 10ms units @@ -1504,10 +1512,13 @@ bool CModem::setConfig() buffer[20U] = (unsigned char)(m_pocsagTXLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 21U); + buffer[21U] = (unsigned char)(m_fmTXLevel * 2.55F + 0.5F); + buffer[22U] = (unsigned char)(m_fmRXLevel * 2.55F + 0.5F); - int ret = m_serial->write(buffer, 21U); - if (ret != 21) + // CUtils::dump(1U, "Written", buffer, 23U); + + int ret = m_serial->write(buffer, 23U); + if (ret != 23) return false; unsigned int count = 0U; @@ -1931,14 +1942,14 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig return true; } -bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 12U; + buffer[1U] = 10U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; @@ -1948,15 +1959,13 @@ bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, fl buffer[6U] = ctcssThreshold; buffer[7U] = ctcssLevel; - buffer[8U] = inputLevel; - buffer[9U] = outputLevel; - buffer[10U] = kerchunkTime; - buffer[11U] = hangTime; + buffer[8U] = kerchunkTime; + buffer[9U] = hangTime; - // CUtils::dump(1U, "Written", buffer, 12U); + // CUtils::dump(1U, "Written", buffer, 10U); - int ret = m_serial->write(buffer, 12U); - if (ret != 12) + int ret = m_serial->write(buffer, 10U); + if (ret != 10) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 068c4d6..5cf6579 100644 --- a/Modem.h +++ b/Modem.h @@ -39,15 +39,15 @@ public: virtual void setSerialParams(const std::string& protocol, unsigned int address); virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency); - virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled); - virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel); + virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled); + virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel, float fmRXLevel); virtual void setDMRParams(unsigned int colorCode); virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel); - virtual bool setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int inputLevel, unsigned int outputLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); @@ -131,6 +131,8 @@ private: float m_p25TXLevel; float m_nxdnTXLevel; float m_pocsagTXLevel; + float m_fmTXLevel; + float m_fmRXLevel; float m_rfLevel; bool m_trace; bool m_debug; @@ -143,6 +145,7 @@ private: bool m_p25Enabled; bool m_nxdnEnabled; bool m_pocsagEnabled; + bool m_fmEnabled; int m_rxDCOffset; int m_txDCOffset; CSerialController* m_serial; From 211e96a86de73f2aa61d0995c2f5a1fe28b517fe Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 12 Apr 2020 16:01:28 +0100 Subject: [PATCH 13/50] Convert to percentages. --- Conf.cpp | 36 ++++++++++++++++++------------------ Conf.h | 24 ++++++++++++------------ MMDVM.ini | 4 ++-- MMDVMHost.cpp | 24 ++++++++++++------------ Modem.cpp | 20 +++++++++++--------- Modem.h | 6 +++--- 6 files changed, 58 insertions(+), 56 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index ba4964c..32387c4 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -179,19 +179,19 @@ m_fmCallsignSpeed(20U), m_fmCallsignFrequency(1000U), m_fmCallsignTime(10U), m_fmCallsignHoldoff(1U), -m_fmCallsignHighLevel(80U), -m_fmCallsignLowLevel(40U), +m_fmCallsignHighLevel(80.0F), +m_fmCallsignLowLevel(40.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmAck("K"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), m_fmAckDelay(1000U), -m_fmAckLevel(80U), -m_fmTimeoutLevel(80U), +m_fmAckLevel(80.0F), +m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), -m_fmCTCSSThreshold(100U), -m_fmCTCSSLevel(5U), +m_fmCTCSSThreshold(10.0F), +m_fmCTCSSLevel(5.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_dstarNetworkEnabled(false), @@ -705,9 +705,9 @@ bool CConf::read() else if (::strcmp(key, "CallsignHoldoff") == 0) m_fmCallsignHoldoff = (unsigned int)::atoi(value); else if (::strcmp(key, "CallsignHighLevel") == 0) - m_fmCallsignHighLevel = (unsigned int)::atoi(value); + m_fmCallsignHighLevel = float(::atof(value)); else if (::strcmp(key, "CallsignLowLevel") == 0) - m_fmCallsignLowLevel = (unsigned int)::atoi(value); + m_fmCallsignLowLevel = float(::atof(value)); else if (::strcmp(key, "CallsignAtStart") == 0) m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) @@ -724,15 +724,15 @@ bool CConf::read() else if (::strcmp(key, "AckDelay") == 0) m_fmAckDelay = (unsigned int)::atoi(value); else if (::strcmp(key, "AckLevel") == 0) - m_fmAckLevel = (unsigned int)::atoi(value); + m_fmAckLevel = float(::atof(value)); else if (::strcmp(key, "TimeoutLevel") == 0) - m_fmTimeoutLevel = (unsigned int)::atoi(value); + m_fmTimeoutLevel = float(::atof(value)); else if (::strcmp(key, "CTCSSFrequency") == 0) m_fmCTCSSFrequency = float(::atof(value)); else if (::strcmp(key, "CTCSSThreshold") == 0) - m_fmCTCSSThreshold = (unsigned int)::atoi(value); + m_fmCTCSSThreshold = float(::atoi(value)); else if (::strcmp(key, "CTCSSLevel") == 0) - m_fmCTCSSLevel = (unsigned int)::atoi(value); + m_fmCTCSSLevel = float(::atof(value)); else if (::strcmp(key, "KerchunkTime") == 0) m_fmKerchunkTime = (unsigned int)::atoi(value); else if (::strcmp(key, "HangTime") == 0) @@ -1509,12 +1509,12 @@ unsigned int CConf::getFMCallsignHoldoff() const return m_fmCallsignHoldoff; } -unsigned int CConf::getFMCallsignHighLevel() const +float CConf::getFMCallsignHighLevel() const { return m_fmCallsignHighLevel; } -unsigned int CConf::getFMCallsignLowLevel() const +float CConf::getFMCallsignLowLevel() const { return m_fmCallsignLowLevel; } @@ -1549,12 +1549,12 @@ unsigned int CConf::getFMAckDelay() const return m_fmAckDelay; } -unsigned int CConf::getFMAckLevel() const +float CConf::getFMAckLevel() const { return m_fmAckLevel; } -unsigned int CConf::getFMTimeoutLevel() const +float CConf::getFMTimeoutLevel() const { return m_fmTimeoutLevel; } @@ -1564,12 +1564,12 @@ float CConf::getFMCTCSSFrequency() const return m_fmCTCSSFrequency; } -unsigned int CConf::getFMCTCSSThreshold() const +float CConf::getFMCTCSSThreshold() const { return m_fmCTCSSThreshold; } -unsigned int CConf::getFMCTCSSLevel() const +float CConf::getFMCTCSSLevel() const { return m_fmCTCSSLevel; } diff --git a/Conf.h b/Conf.h index 3cdfccc..b8817f7 100644 --- a/Conf.h +++ b/Conf.h @@ -177,19 +177,19 @@ public: unsigned int getFMCallsignFrequency() const; unsigned int getFMCallsignTime() const; unsigned int getFMCallsignHoldoff() const; - unsigned int getFMCallsignHighLevel() const; - unsigned int getFMCallsignLowLevel() const; + float getFMCallsignHighLevel() const; + float getFMCallsignLowLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; std::string getFMAck() const; unsigned int getFMAckSpeed() const; unsigned int getFMAckFrequency() const; unsigned int getFMAckDelay() const; - unsigned int getFMAckLevel() const; - unsigned int getFMTimeoutLevel() const; + float getFMAckLevel() const; + float getFMTimeoutLevel() const; float getFMCTCSSFrequency() const; - unsigned int getFMCTCSSThreshold() const; - unsigned int getFMCTCSSLevel() const; + float getFMCTCSSThreshold() const; + float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; @@ -436,19 +436,19 @@ private: unsigned int m_fmCallsignFrequency; unsigned int m_fmCallsignTime; unsigned int m_fmCallsignHoldoff; - unsigned int m_fmCallsignHighLevel; - unsigned int m_fmCallsignLowLevel; + float m_fmCallsignHighLevel; + float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; unsigned int m_fmAckDelay; - unsigned int m_fmAckLevel; - unsigned int m_fmTimeoutLevel; + float m_fmAckLevel; + float m_fmTimeoutLevel; float m_fmCTCSSFrequency; - unsigned int m_fmCTCSSThreshold; - unsigned int m_fmCTCSSLevel; + float m_fmCTCSSThreshold; + float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/MMDVM.ini b/MMDVM.ini index d44374d..d7c7aa0 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -157,8 +157,8 @@ AckFrequency=1750 AckDelay=1000 AckLevel=80 TimeoutLevel=80 -CTCSSFrequency=88.4 -CTCSSThreshold=100 +CTCSSFrequency=88.8 +CTCSSThreshold=10 CTCSSLevel=5 KerchunkTime=0 HangTime=7 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 72442fe..0ea37be 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -612,20 +612,20 @@ int CMMDVMHost::run() unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); unsigned int callsignTime = m_conf.getFMCallsignTime(); unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - unsigned int callsignHighLevel = m_conf.getFMCallsignHighLevel(); - unsigned int callsignLowLevel = m_conf.getFMCallsignLowLevel(); + float callsignHighLevel = m_conf.getFMCallsignHighLevel(); + float callsignLowLevel = m_conf.getFMCallsignLowLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); std::string ack = m_conf.getFMCallsign(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); unsigned int ackFrequency = m_conf.getFMAckFrequency(); unsigned int ackDelay = m_conf.getFMAckDelay(); - unsigned int ackLevel = m_conf.getFMAckLevel(); + float ackLevel = m_conf.getFMAckLevel(); unsigned int timeout = m_conf.getTimeout(); - unsigned int timeoutLevel = m_conf.getFMTimeoutLevel(); + float timeoutLevel = m_conf.getFMTimeoutLevel(); float ctcssFrequency = m_conf.getFMCTCSSFrequency(); - unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); - unsigned int ctcssLevel = m_conf.getFMCTCSSLevel(); + float ctcssThreshold = m_conf.getFMCTCSSThreshold(); + float ctcssLevel = m_conf.getFMCTCSSLevel(); unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); @@ -635,20 +635,20 @@ int CMMDVMHost::run() LogInfo(" Callsign Frequency: %uHz", callsignFrequency); LogInfo(" Callsign Time: %umins", callsignTime); LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); - LogInfo(" Callsign High Level: %u%%", callsignHighLevel); - LogInfo(" Callsign Low Level: %u%%", callsignLowLevel); + LogInfo(" Callsign High Level: %.1f%%", callsignHighLevel); + LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); LogInfo(" Ack: %s", ack.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); LogInfo(" Ack Delay: %ums", ackDelay); - LogInfo(" Ack Level: %u%%", ackLevel); + LogInfo(" Ack Level: %.1f%%", ackLevel); LogInfo(" Timeout: %us", timeout); - LogInfo(" Timeout Level: %u%%", timeoutLevel); + LogInfo(" Timeout Level: %.1f%%", timeoutLevel); LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); - LogInfo(" CTCSS Threshold: %u%%", ctcssThreshold); - LogInfo(" CTCSS Level: %u%%", ctcssLevel); + LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold); + LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); diff --git a/Modem.cpp b/Modem.cpp index 6f37c4d..a3fa859 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1834,7 +1834,7 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) +bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) { assert(m_serial != NULL); @@ -1849,8 +1849,9 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls buffer[4U] = callsignFrequency / 10U; buffer[5U] = callsignTime; buffer[6U] = callsignHoldoff; - buffer[7U] = callsignHighLevel; - buffer[8U] = callsignLowLevel; + + buffer[7U] = (unsigned char)(callsignHighLevel * 2.55F + 0.5F); + buffer[8U] = (unsigned char)(callsignLowLevel * 2.55F + 0.5F); buffer[9U] = 0x00U; if (callsignAtStart) @@ -1892,7 +1893,7 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls return true; } -bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel) +bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, float ackLevel) { assert(m_serial != NULL); @@ -1906,7 +1907,8 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig buffer[3U] = ackSpeed; buffer[4U] = ackFrequency / 10U; buffer[5U] = ackDelay / 10U; - buffer[6U] = ackLevel; + + buffer[6U] = (unsigned char)(ackLevel * 2.55F + 0.5F); for (unsigned int i = 0U; i < ack.size(); i++) buffer[7U + i] = ack.at(i); @@ -1942,7 +1944,7 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig return true; } -bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); @@ -1953,11 +1955,11 @@ bool CModem::setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, fl buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; - buffer[4U] = timeoutLevel; + buffer[4U] = (unsigned char)(timeoutLevel * 2.55F + 0.5F); buffer[5U] = (unsigned char)ctcssFrequency; - buffer[6U] = ctcssThreshold; - buffer[7U] = ctcssLevel; + buffer[6U] = (unsigned char)(ctcssThreshold * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(ctcssLevel * 2.55F + 0.5F); buffer[8U] = kerchunkTime; buffer[9U] = hangTime; diff --git a/Modem.h b/Modem.h index 5cf6579..6b0fbe3 100644 --- a/Modem.h +++ b/Modem.h @@ -45,9 +45,9 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, unsigned int callsignHighLevel, unsigned int callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); - virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, unsigned int ackLevel); - virtual bool setFMMiscParams(unsigned int timeout, unsigned int timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, unsigned int ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); + virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, float ackLevel); + virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); From 58aff1ab77aadc9af3d525a547b54685192f6b0b Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 13 Apr 2020 13:36:16 +0100 Subject: [PATCH 14/50] Split the RF and Network acks. --- Conf.cpp | 29 ++++++++++++++++++++--------- Conf.h | 6 ++++-- MMDVM.ini | 3 ++- MMDVMHost.cpp | 8 +++++--- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 32387c4..eaf7263 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -183,7 +183,8 @@ m_fmCallsignHighLevel(80.0F), m_fmCallsignLowLevel(40.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), -m_fmAck("K"), +m_fmRFAck("K"), +m_fmNetAck("N"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), m_fmAckDelay(1000U), @@ -712,12 +713,17 @@ bool CConf::read() m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) m_fmCallsignAtEnd = ::atoi(value) == 1; - else if (::strcmp(key, "Ack") == 0) { - // Convert the ack to upper case - for (unsigned int i = 0U; value[i] != 0; i++) - value[i] = ::toupper(value[i]); - m_fmAck = value; - } else if (::strcmp(key, "AckSpeed") == 0) + else if (::strcmp(key, "RFAck") == 0) { + // Convert the ack to upper case + for (unsigned int i = 0U; value[i] != 0; i++) + value[i] = ::toupper(value[i]); + m_fmRFAck = value; + } else if (::strcmp(key, "NetAck") == 0) { + // Convert the ack to upper case + for (unsigned int i = 0U; value[i] != 0; i++) + value[i] = ::toupper(value[i]); + m_fmNetAck = value; + } else if (::strcmp(key, "AckSpeed") == 0) m_fmAckSpeed = (unsigned int)::atoi(value); else if (::strcmp(key, "AckFrequency") == 0) m_fmAckFrequency = (unsigned int)::atoi(value); @@ -1529,9 +1535,14 @@ bool CConf::getFMCallsignAtEnd() const return m_fmCallsignAtEnd; } -std::string CConf::getFMAck() const +std::string CConf::getFMRFAck() const { - return m_fmAck; + return m_fmRFAck; +} + +std::string CConf::getFMNetAck() const +{ + return m_fmNetAck; } unsigned int CConf::getFMAckSpeed() const diff --git a/Conf.h b/Conf.h index b8817f7..2460cb9 100644 --- a/Conf.h +++ b/Conf.h @@ -181,7 +181,8 @@ public: float getFMCallsignLowLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; - std::string getFMAck() const; + std::string getFMRFAck() const; + std::string getFMNetAck() const; unsigned int getFMAckSpeed() const; unsigned int getFMAckFrequency() const; unsigned int getFMAckDelay() const; @@ -440,7 +441,8 @@ private: float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; - std::string m_fmAck; + std::string m_fmRFAck; + std::string m_fmNetAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; unsigned int m_fmAckDelay; diff --git a/MMDVM.ini b/MMDVM.ini index d7c7aa0..f7c73bc 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -151,7 +151,8 @@ CallsignHighLevel=80 CallsignLowLevel=40 CallsignAtStart=1 CallsignAtEnd=1 -Ack=K +RFAck=K +NetAck=N AckSpeed=20 AckFrequency=1750 AckDelay=1000 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 0ea37be..9693309 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -616,7 +616,8 @@ int CMMDVMHost::run() float callsignLowLevel = m_conf.getFMCallsignLowLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); - std::string ack = m_conf.getFMCallsign(); + std::string rfAck = m_conf.getFMRFAck(); + std::string netAck = m_conf.getFMNetAck(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); unsigned int ackFrequency = m_conf.getFMAckFrequency(); unsigned int ackDelay = m_conf.getFMAckDelay(); @@ -639,7 +640,8 @@ int CMMDVMHost::run() LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); - LogInfo(" Ack: %s", ack.c_str()); + LogInfo(" RF Ack: %s", rfAck.c_str()); + LogInfo(" Net Ack: %s", netAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); LogInfo(" Ack Delay: %ums", ackDelay); @@ -653,7 +655,7 @@ int CMMDVMHost::run() LogInfo(" Hang Time: %us", hangTime); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); - m_modem->setFMAckParams(ack, ackSpeed, ackFrequency, ackDelay, ackLevel); + m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackDelay, ackLevel); m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } From 1f17aec1f1a7e5bbe937a5cd40670e0c794cf40f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 13 Apr 2020 15:53:18 +0100 Subject: [PATCH 15/50] Add the minimum time for a 'K' parameter. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 11 ++++++----- Modem.h | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index eaf7263..0f62639 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -187,6 +187,7 @@ m_fmRFAck("K"), m_fmNetAck("N"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), +m_fmAckMinTime(5U), m_fmAckDelay(1000U), m_fmAckLevel(80.0F), m_fmTimeoutLevel(80.0F), @@ -727,6 +728,8 @@ bool CConf::read() m_fmAckSpeed = (unsigned int)::atoi(value); else if (::strcmp(key, "AckFrequency") == 0) m_fmAckFrequency = (unsigned int)::atoi(value); + else if (::strcmp(key, "AckMinTime") == 0) + m_fmAckMinTime = (unsigned int)::atoi(value); else if (::strcmp(key, "AckDelay") == 0) m_fmAckDelay = (unsigned int)::atoi(value); else if (::strcmp(key, "AckLevel") == 0) @@ -1555,6 +1558,11 @@ unsigned int CConf::getFMAckFrequency() const return m_fmAckFrequency; } +unsigned int CConf::getFMAckMinTime() const +{ + return m_fmAckMinTime; +} + unsigned int CConf::getFMAckDelay() const { return m_fmAckDelay; diff --git a/Conf.h b/Conf.h index 2460cb9..84127a4 100644 --- a/Conf.h +++ b/Conf.h @@ -185,6 +185,7 @@ public: std::string getFMNetAck() const; unsigned int getFMAckSpeed() const; unsigned int getFMAckFrequency() const; + unsigned int getFMAckMinTime() const; unsigned int getFMAckDelay() const; float getFMAckLevel() const; float getFMTimeoutLevel() const; @@ -445,6 +446,7 @@ private: std::string m_fmNetAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; + unsigned int m_fmAckMinTime; unsigned int m_fmAckDelay; float m_fmAckLevel; float m_fmTimeoutLevel; diff --git a/MMDVM.ini b/MMDVM.ini index f7c73bc..c7b70a4 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -155,6 +155,7 @@ RFAck=K NetAck=N AckSpeed=20 AckFrequency=1750 +AckMinTime=4 AckDelay=1000 AckLevel=80 TimeoutLevel=80 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9693309..e1c34ad 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -620,6 +620,7 @@ int CMMDVMHost::run() std::string netAck = m_conf.getFMNetAck(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); unsigned int ackFrequency = m_conf.getFMAckFrequency(); + unsigned int ackMinTime = m_conf.getFMAckMinTime(); unsigned int ackDelay = m_conf.getFMAckDelay(); float ackLevel = m_conf.getFMAckLevel(); unsigned int timeout = m_conf.getTimeout(); @@ -644,6 +645,7 @@ int CMMDVMHost::run() LogInfo(" Net Ack: %s", netAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); + LogInfo(" Ack Min Time: %us", ackMinTime); LogInfo(" Ack Delay: %ums", ackDelay); LogInfo(" Ack Level: %.1f%%", ackLevel); LogInfo(" Timeout: %us", timeout); @@ -655,7 +657,7 @@ int CMMDVMHost::run() LogInfo(" Hang Time: %us", hangTime); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); - m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackDelay, ackLevel); + m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } diff --git a/Modem.cpp b/Modem.cpp index a3fa859..3b9e51a 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1893,12 +1893,12 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls return true; } -bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, float ackLevel) +bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 7U + ack.size(); + unsigned char len = 8U + ack.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; @@ -1906,12 +1906,13 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig buffer[3U] = ackSpeed; buffer[4U] = ackFrequency / 10U; - buffer[5U] = ackDelay / 10U; + buffer[5U] = ackMinTime; + buffer[6U] = ackDelay / 10U; - buffer[6U] = (unsigned char)(ackLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(ackLevel * 2.55F + 0.5F); for (unsigned int i = 0U; i < ack.size(); i++) - buffer[7U + i] = ack.at(i); + buffer[8U + i] = ack.at(i); // CUtils::dump(1U, "Written", buffer, len); diff --git a/Modem.h b/Modem.h index 6b0fbe3..82ba207 100644 --- a/Modem.h +++ b/Modem.h @@ -46,7 +46,7 @@ public: virtual void setTransparentDataParams(unsigned int sendFrameType); virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); - virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackDelay, float ackLevel); + virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); From 960a60f3822c2494e3867ee92da4f16581583aeb Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 14 Apr 2020 12:22:23 +0100 Subject: [PATCH 16/50] Pass the net ack text to the modem. --- MMDVMHost.cpp | 2 +- Modem.cpp | 22 +++++++++++++--------- Modem.h | 4 ++-- Version.h | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index e1c34ad..132b3ad 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -658,7 +658,7 @@ int CMMDVMHost::run() m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + m_modem->setFMMiscParams(netAck, timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); diff --git a/Modem.cpp b/Modem.cpp index 3b9e51a..318e5d2 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1893,12 +1893,12 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls return true; } -bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) +bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 8U + ack.size(); + unsigned char len = 8U + rfAck.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; @@ -1911,8 +1911,8 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig buffer[7U] = (unsigned char)(ackLevel * 2.55F + 0.5F); - for (unsigned int i = 0U; i < ack.size(); i++) - buffer[8U + i] = ack.at(i); + for (unsigned int i = 0U; i < rfAck.size(); i++) + buffer[8U + i] = rfAck.at(i); // CUtils::dump(1U, "Written", buffer, len); @@ -1945,14 +1945,15 @@ bool CModem::setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsig return true; } -bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); unsigned char buffer[20U]; + unsigned char len = 10U + netAck.size(); buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 10U; + buffer[1U] = len; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; @@ -1965,10 +1966,13 @@ bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc buffer[8U] = kerchunkTime; buffer[9U] = hangTime; - // CUtils::dump(1U, "Written", buffer, 10U); + for (unsigned int i = 0U; i < netAck.size(); i++) + buffer[10U + i] = netAck.at(i); - int ret = m_serial->write(buffer, 10U); - if (ret != 10) + // CUtils::dump(1U, "Written", buffer, len); + + int ret = m_serial->write(buffer, len); + if (ret != len) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 82ba207..4571ef5 100644 --- a/Modem.h +++ b/Modem.h @@ -46,8 +46,8 @@ public: virtual void setTransparentDataParams(unsigned int sendFrameType); virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); - virtual bool setFMAckParams(const std::string& ack, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); - virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); + virtual bool setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); diff --git a/Version.h b/Version.h index d1073ff..118163d 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200411"; +const char* VERSION = "20200414"; #endif From f8bce3823ad1db64735a2d2492d81b5d19aba16e Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 15 Apr 2020 14:14:38 +0100 Subject: [PATCH 17/50] Allow for a seperate FM timeout value. --- Conf.cpp | 10 +++++++++- Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 2 +- Version.h | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 0f62639..d97fae7 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -190,6 +190,7 @@ m_fmAckFrequency(1750U), m_fmAckMinTime(5U), m_fmAckDelay(1000U), m_fmAckLevel(80.0F), +m_fmTimeout(180U), m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), m_fmCTCSSThreshold(10.0F), @@ -391,7 +392,7 @@ bool CConf::read() } else if (::strcmp(key, "Id") == 0) m_id = m_p25Id = m_dmrId = (unsigned int)::atoi(value); else if (::strcmp(key, "Timeout") == 0) - m_timeout = (unsigned int)::atoi(value); + m_fmTimeout = m_timeout = (unsigned int)::atoi(value); else if (::strcmp(key, "Duplex") == 0) m_duplex = ::atoi(value) == 1; else if (::strcmp(key, "ModeHang") == 0) @@ -734,6 +735,8 @@ bool CConf::read() m_fmAckDelay = (unsigned int)::atoi(value); else if (::strcmp(key, "AckLevel") == 0) m_fmAckLevel = float(::atof(value)); + else if (::strcmp(key, "Timeout") == 0) + m_fmTimeout = (unsigned int)::atoi(value); else if (::strcmp(key, "TimeoutLevel") == 0) m_fmTimeoutLevel = float(::atof(value)); else if (::strcmp(key, "CTCSSFrequency") == 0) @@ -1573,6 +1576,11 @@ float CConf::getFMAckLevel() const return m_fmAckLevel; } +unsigned int CConf::getFMTimeout() const +{ + return m_fmTimeout; +} + float CConf::getFMTimeoutLevel() const { return m_fmTimeoutLevel; diff --git a/Conf.h b/Conf.h index 84127a4..87c5fc9 100644 --- a/Conf.h +++ b/Conf.h @@ -188,6 +188,7 @@ public: unsigned int getFMAckMinTime() const; unsigned int getFMAckDelay() const; float getFMAckLevel() const; + unsigned int getFMTimeout() const; float getFMTimeoutLevel() const; float getFMCTCSSFrequency() const; float getFMCTCSSThreshold() const; @@ -449,6 +450,7 @@ private: unsigned int m_fmAckMinTime; unsigned int m_fmAckDelay; float m_fmAckLevel; + unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCTCSSFrequency; float m_fmCTCSSThreshold; diff --git a/MMDVM.ini b/MMDVM.ini index c7b70a4..d64eddd 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -158,6 +158,7 @@ AckFrequency=1750 AckMinTime=4 AckDelay=1000 AckLevel=80 +# Timeout=180 TimeoutLevel=80 CTCSSFrequency=88.8 CTCSSThreshold=10 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 132b3ad..73561c5 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -623,7 +623,7 @@ int CMMDVMHost::run() unsigned int ackMinTime = m_conf.getFMAckMinTime(); unsigned int ackDelay = m_conf.getFMAckDelay(); float ackLevel = m_conf.getFMAckLevel(); - unsigned int timeout = m_conf.getTimeout(); + unsigned int timeout = m_conf.getFMTimeout(); float timeoutLevel = m_conf.getFMTimeoutLevel(); float ctcssFrequency = m_conf.getFMCTCSSFrequency(); float ctcssThreshold = m_conf.getFMCTCSSThreshold(); diff --git a/Version.h b/Version.h index 118163d..a8bedbc 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200414"; +const char* VERSION = "20200415"; #endif From 11cd5679a78aab7a3050567e2d955e21e6f43a4f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 18 Apr 2020 13:43:36 +0100 Subject: [PATCH 18/50] Simplify the FM configuration. --- Conf.cpp | 18 +++++------------- Conf.h | 6 ++---- MMDVM.ini | 5 ++--- MMDVMHost.cpp | 12 +++++------- Modem.cpp | 29 ++++++++++++----------------- Modem.h | 4 ++-- Version.h | 2 +- 7 files changed, 29 insertions(+), 47 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index d97fae7..1663d48 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -179,8 +179,7 @@ m_fmCallsignSpeed(20U), m_fmCallsignFrequency(1000U), m_fmCallsignTime(10U), m_fmCallsignHoldoff(1U), -m_fmCallsignHighLevel(80.0F), -m_fmCallsignLowLevel(40.0F), +m_fmCallsignLevel(40.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmRFAck("K"), @@ -707,10 +706,8 @@ bool CConf::read() m_fmCallsignTime = (unsigned int)::atoi(value); else if (::strcmp(key, "CallsignHoldoff") == 0) m_fmCallsignHoldoff = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignHighLevel") == 0) - m_fmCallsignHighLevel = float(::atof(value)); - else if (::strcmp(key, "CallsignLowLevel") == 0) - m_fmCallsignLowLevel = float(::atof(value)); + else if (::strcmp(key, "CallsignLevel") == 0) + m_fmCallsignLevel = float(::atof(value)); else if (::strcmp(key, "CallsignAtStart") == 0) m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) @@ -1521,14 +1518,9 @@ unsigned int CConf::getFMCallsignHoldoff() const return m_fmCallsignHoldoff; } -float CConf::getFMCallsignHighLevel() const +float CConf::getFMCallsignLevel() const { - return m_fmCallsignHighLevel; -} - -float CConf::getFMCallsignLowLevel() const -{ - return m_fmCallsignLowLevel; + return m_fmCallsignLevel; } bool CConf::getFMCallsignAtStart() const diff --git a/Conf.h b/Conf.h index 87c5fc9..af882a2 100644 --- a/Conf.h +++ b/Conf.h @@ -177,8 +177,7 @@ public: unsigned int getFMCallsignFrequency() const; unsigned int getFMCallsignTime() const; unsigned int getFMCallsignHoldoff() const; - float getFMCallsignHighLevel() const; - float getFMCallsignLowLevel() const; + float getFMCallsignLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; std::string getFMRFAck() const; @@ -439,8 +438,7 @@ private: unsigned int m_fmCallsignFrequency; unsigned int m_fmCallsignTime; unsigned int m_fmCallsignHoldoff; - float m_fmCallsignHighLevel; - float m_fmCallsignLowLevel; + float m_fmCallsignLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmRFAck; diff --git a/MMDVM.ini b/MMDVM.ini index d64eddd..c8a5403 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -147,12 +147,11 @@ CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 CallsignHoldoff=1 -CallsignHighLevel=80 -CallsignLowLevel=40 +CallsignLevel=40 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K -NetAck=N +# NetAck=N AckSpeed=20 AckFrequency=1750 AckMinTime=4 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 73561c5..708fa97 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -612,8 +612,7 @@ int CMMDVMHost::run() unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); unsigned int callsignTime = m_conf.getFMCallsignTime(); unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - float callsignHighLevel = m_conf.getFMCallsignHighLevel(); - float callsignLowLevel = m_conf.getFMCallsignLowLevel(); + float callsignLevel = m_conf.getFMCallsignLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); std::string rfAck = m_conf.getFMRFAck(); @@ -637,12 +636,11 @@ int CMMDVMHost::run() LogInfo(" Callsign Frequency: %uHz", callsignFrequency); LogInfo(" Callsign Time: %umins", callsignTime); LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); - LogInfo(" Callsign High Level: %.1f%%", callsignHighLevel); - LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); + LogInfo(" Callsign Level: %.1f%%", callsignLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); - LogInfo(" Net Ack: %s", netAck.c_str()); + // LogInfo(" Net Ack: %s", netAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); LogInfo(" Ack Min Time: %us", ackMinTime); @@ -656,9 +654,9 @@ int CMMDVMHost::run() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(netAck, timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); diff --git a/Modem.cpp b/Modem.cpp index 318e5d2..db47265 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1834,12 +1834,12 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) +bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd) { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 10U + callsign.size(); + unsigned char len = 9U + callsign.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; @@ -1850,17 +1850,16 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls buffer[5U] = callsignTime; buffer[6U] = callsignHoldoff; - buffer[7U] = (unsigned char)(callsignHighLevel * 2.55F + 0.5F); - buffer[8U] = (unsigned char)(callsignLowLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(callsignLevel * 2.55F + 0.5F); - buffer[9U] = 0x00U; + buffer[8U] = 0x00U; if (callsignAtStart) - buffer[9U] |= 0x01U; + buffer[8U] |= 0x01U; if (callsignAtEnd) - buffer[9U] |= 0x02U; + buffer[8U] |= 0x02U; for (unsigned int i = 0U; i < callsign.size(); i++) - buffer[10U + i] = callsign.at(i); + buffer[9U + i] = callsign.at(i); // CUtils::dump(1U, "Written", buffer, len); @@ -1945,15 +1944,14 @@ bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns return true; } -bool CModem::setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); unsigned char buffer[20U]; - unsigned char len = 10U + netAck.size(); buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = len; + buffer[1U] = 10U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; @@ -1966,13 +1964,10 @@ bool CModem::setFMMiscParams(const std::string& netAck, unsigned int timeout, fl buffer[8U] = kerchunkTime; buffer[9U] = hangTime; - for (unsigned int i = 0U; i < netAck.size(); i++) - buffer[10U + i] = netAck.at(i); + // CUtils::dump(1U, "Written", buffer, 10U); - // CUtils::dump(1U, "Written", buffer, len); - - int ret = m_serial->write(buffer, len); - if (ret != len) + int ret = m_serial->write(buffer, 10U); + if (ret != 10) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 4571ef5..4a33116 100644 --- a/Modem.h +++ b/Modem.h @@ -45,9 +45,9 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); + virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); virtual bool setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); - virtual bool setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); diff --git a/Version.h b/Version.h index a8bedbc..049e6ea 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200415"; +const char* VERSION = "20200418"; #endif From c359d874b5b79f52818cadedb4d3af0b98db255a Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 18 Apr 2020 14:59:19 +0100 Subject: [PATCH 19/50] Regularise the FM configuration. --- MMDVMHost.cpp | 106 +++++++++++++++++++------------------- Modem.cpp | 140 +++++++++++++++++++++++++++++++++++++++----------- Modem.h | 31 +++++++++-- 3 files changed, 192 insertions(+), 85 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 708fa97..751d25f 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -606,59 +606,6 @@ int CMMDVMHost::run() pocsagTimer.start(); } - if (m_fmEnabled) { - std::string callsign = m_conf.getFMCallsign(); - unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); - unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); - unsigned int callsignTime = m_conf.getFMCallsignTime(); - unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - float callsignLevel = m_conf.getFMCallsignLevel(); - bool callsignAtStart = m_conf.getFMCallsignAtStart(); - bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); - std::string rfAck = m_conf.getFMRFAck(); - std::string netAck = m_conf.getFMNetAck(); - unsigned int ackSpeed = m_conf.getFMAckSpeed(); - unsigned int ackFrequency = m_conf.getFMAckFrequency(); - unsigned int ackMinTime = m_conf.getFMAckMinTime(); - unsigned int ackDelay = m_conf.getFMAckDelay(); - float ackLevel = m_conf.getFMAckLevel(); - unsigned int timeout = m_conf.getFMTimeout(); - float timeoutLevel = m_conf.getFMTimeoutLevel(); - float ctcssFrequency = m_conf.getFMCTCSSFrequency(); - float ctcssThreshold = m_conf.getFMCTCSSThreshold(); - float ctcssLevel = m_conf.getFMCTCSSLevel(); - unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); - unsigned int hangTime = m_conf.getFMHangTime(); - - LogInfo("FM RF Parameters"); - LogInfo(" Callsign: %s", callsign.c_str()); - LogInfo(" Callsign Speed: %uWPM", callsignSpeed); - LogInfo(" Callsign Frequency: %uHz", callsignFrequency); - LogInfo(" Callsign Time: %umins", callsignTime); - LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); - LogInfo(" Callsign Level: %.1f%%", callsignLevel); - LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); - LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); - LogInfo(" RF Ack: %s", rfAck.c_str()); - // LogInfo(" Net Ack: %s", netAck.c_str()); - LogInfo(" Ack Speed: %uWPM", ackSpeed); - LogInfo(" Ack Frequency: %uHz", ackFrequency); - LogInfo(" Ack Min Time: %us", ackMinTime); - LogInfo(" Ack Delay: %ums", ackDelay); - LogInfo(" Ack Level: %.1f%%", ackLevel); - LogInfo(" Timeout: %us", timeout); - LogInfo(" Timeout Level: %.1f%%", timeoutLevel); - LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); - LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold); - LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); - LogInfo(" Kerchunk Time: %us", kerchunkTime); - LogInfo(" Hang Time: %us", hangTime); - - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd); - m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); - } - bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); if (remoteControlEnabled) { unsigned int port = m_conf.getRemoteControlPort(); @@ -1252,6 +1199,59 @@ bool CMMDVMHost::createModem() LogInfo(" FM RX Level: %.1f%%", fmRXLevel); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); + if (m_fmEnabled) { + std::string callsign = m_conf.getFMCallsign(); + unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); + unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); + unsigned int callsignTime = m_conf.getFMCallsignTime(); + unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); + float callsignLevel = m_conf.getFMCallsignLevel(); + bool callsignAtStart = m_conf.getFMCallsignAtStart(); + bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + std::string rfAck = m_conf.getFMRFAck(); + std::string netAck = m_conf.getFMNetAck(); + unsigned int ackSpeed = m_conf.getFMAckSpeed(); + unsigned int ackFrequency = m_conf.getFMAckFrequency(); + unsigned int ackMinTime = m_conf.getFMAckMinTime(); + unsigned int ackDelay = m_conf.getFMAckDelay(); + float ackLevel = m_conf.getFMAckLevel(); + unsigned int timeout = m_conf.getFMTimeout(); + float timeoutLevel = m_conf.getFMTimeoutLevel(); + float ctcssFrequency = m_conf.getFMCTCSSFrequency(); + float ctcssThreshold = m_conf.getFMCTCSSThreshold(); + float ctcssLevel = m_conf.getFMCTCSSLevel(); + unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); + unsigned int hangTime = m_conf.getFMHangTime(); + + LogInfo("FM Parameters"); + LogInfo(" Callsign: %s", callsign.c_str()); + LogInfo(" Callsign Speed: %uWPM", callsignSpeed); + LogInfo(" Callsign Frequency: %uHz", callsignFrequency); + LogInfo(" Callsign Time: %umins", callsignTime); + LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); + LogInfo(" Callsign Level: %.1f%%", callsignLevel); + LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); + LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); + LogInfo(" RF Ack: %s", rfAck.c_str()); + // LogInfo(" Net Ack: %s", netAck.c_str()); + LogInfo(" Ack Speed: %uWPM", ackSpeed); + LogInfo(" Ack Frequency: %uHz", ackFrequency); + LogInfo(" Ack Min Time: %us", ackMinTime); + LogInfo(" Ack Delay: %ums", ackDelay); + LogInfo(" Ack Level: %.1f%%", ackLevel); + LogInfo(" Timeout: %us", timeout); + LogInfo(" Timeout Level: %.1f%%", timeoutLevel); + LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); + LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold); + LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); + LogInfo(" Kerchunk Time: %us", kerchunkTime); + LogInfo(" Hang Time: %us", hangTime); + + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + } + m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); m_modem->setSerialParams(protocol,address); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); diff --git a/Modem.cpp b/Modem.cpp index db47265..850b2e6 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -169,7 +169,28 @@ m_cd(false), m_lockout(false), m_error(false), m_mode(MODE_IDLE), -m_hwType(HWT_UNKNOWN) +m_hwType(HWT_UNKNOWN), +m_fmCallsign(), +m_fmCallsignSpeed(20U), +m_fmCallsignFrequency(1000U), +m_fmCallsignTime(600U), +m_fmCallsignHoldoff(0U), +m_fmCallsignLevel(40.0F), +m_fmCallsignAtStart(true), +m_fmCallsignAtEnd(true), +m_fmRfAck("K"), +m_fmAckSpeed(20U), +m_fmAckFrequency(1750U), +m_fmAckMinTime(4U), +m_fmAckDelay(1000U), +m_fmAckLevel(80.0F), +m_fmTimeout(120U), +m_fmTimeoutLevel(80.0F), +m_fmCtcssFrequency(88.4F), +m_fmCtcssThreshold(10.0F), +m_fmCtcssLevel(10.0F), +m_fmKerchunkTime(0U), +m_fmHangTime(5U) { m_buffer = new unsigned char[BUFFER_LENGTH]; @@ -280,6 +301,32 @@ bool CModem::open() return false; } + if (m_fmEnabled) { + ret = setFMCallsignParams(); + if (!ret) { + m_serial->close(); + delete m_serial; + m_serial = NULL; + return false; + } + + ret = setFMAckParams(); + if (!ret) { + m_serial->close(); + delete m_serial; + m_serial = NULL; + return false; + } + + ret = setFMMiscParams(); + if (!ret) { + m_serial->close(); + delete m_serial; + m_serial = NULL; + return false; + } + } + m_statusTimer.start(); m_error = false; @@ -1834,32 +1881,67 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd) +void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd) +{ + m_fmCallsign = callsign; + m_fmCallsignSpeed = callsignSpeed; + m_fmCallsignFrequency = callsignFrequency; + m_fmCallsignTime = callsignTime; + m_fmCallsignHoldoff = callsignHoldoff; + m_fmCallsignLevel = callsignLevel; + m_fmCallsignAtStart = callsignAtStart; + m_fmCallsignAtEnd = callsignAtEnd; +} + +void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) +{ + m_fmRfAck = rfAck; + m_fmAckSpeed = ackSpeed; + m_fmAckFrequency = ackFrequency; + m_fmAckMinTime = ackMinTime; + m_fmAckDelay = ackDelay; + m_fmAckLevel = ackLevel; +} + +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +{ + m_fmTimeout = timeout; + m_fmTimeoutLevel = timeoutLevel; + + m_fmCtcssFrequency = ctcssFrequency; + m_fmCtcssThreshold = ctcssThreshold; + m_fmCtcssLevel = ctcssLevel; + + m_fmKerchunkTime = kerchunkTime; + m_fmHangTime = hangTime; +} + +bool CModem::setFMCallsignParams() { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 9U + callsign.size(); + unsigned char len = 9U + m_fmCallsign.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; buffer[2U] = MMDVM_FM_PARAMS1; - buffer[3U] = callsignSpeed; - buffer[4U] = callsignFrequency / 10U; - buffer[5U] = callsignTime; - buffer[6U] = callsignHoldoff; + buffer[3U] = m_fmCallsignSpeed; + buffer[4U] = m_fmCallsignFrequency / 10U; + buffer[5U] = m_fmCallsignTime; + buffer[6U] = m_fmCallsignHoldoff; - buffer[7U] = (unsigned char)(callsignLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(m_fmCallsignLevel * 2.55F + 0.5F); buffer[8U] = 0x00U; - if (callsignAtStart) + if (m_fmCallsignAtStart) buffer[8U] |= 0x01U; - if (callsignAtEnd) + if (m_fmCallsignAtEnd) buffer[8U] |= 0x02U; - for (unsigned int i = 0U; i < callsign.size(); i++) - buffer[9U + i] = callsign.at(i); + for (unsigned int i = 0U; i < m_fmCallsign.size(); i++) + buffer[9U + i] = m_fmCallsign.at(i); // CUtils::dump(1U, "Written", buffer, len); @@ -1892,26 +1974,26 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls return true; } -bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) +bool CModem::setFMAckParams() { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 8U + rfAck.size(); + unsigned char len = 8U + m_fmRfAck.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; buffer[2U] = MMDVM_FM_PARAMS2; - buffer[3U] = ackSpeed; - buffer[4U] = ackFrequency / 10U; - buffer[5U] = ackMinTime; - buffer[6U] = ackDelay / 10U; + buffer[3U] = m_fmAckSpeed; + buffer[4U] = m_fmAckFrequency / 10U; + buffer[5U] = m_fmAckMinTime; + buffer[6U] = m_fmAckDelay / 10U; - buffer[7U] = (unsigned char)(ackLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(m_fmAckLevel * 2.55F + 0.5F); - for (unsigned int i = 0U; i < rfAck.size(); i++) - buffer[8U + i] = rfAck.at(i); + for (unsigned int i = 0U; i < m_fmRfAck.size(); i++) + buffer[8U + i] = m_fmRfAck.at(i); // CUtils::dump(1U, "Written", buffer, len); @@ -1944,7 +2026,7 @@ bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns return true; } -bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams() { assert(m_serial != NULL); @@ -1954,15 +2036,15 @@ bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc buffer[1U] = 10U; buffer[2U] = MMDVM_FM_PARAMS3; - buffer[3U] = timeout / 5U; - buffer[4U] = (unsigned char)(timeoutLevel * 2.55F + 0.5F); + buffer[3U] = m_fmTimeout / 5U; + buffer[4U] = (unsigned char)(m_fmTimeoutLevel * 2.55F + 0.5F); - buffer[5U] = (unsigned char)ctcssFrequency; - buffer[6U] = (unsigned char)(ctcssThreshold * 2.55F + 0.5F); - buffer[7U] = (unsigned char)(ctcssLevel * 2.55F + 0.5F); + buffer[5U] = (unsigned char)m_fmCtcssFrequency; + buffer[6U] = (unsigned char)(m_fmCtcssThreshold * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); - buffer[8U] = kerchunkTime; - buffer[9U] = hangTime; + buffer[8U] = m_fmKerchunkTime; + buffer[9U] = m_fmHangTime; // CUtils::dump(1U, "Written", buffer, 10U); diff --git a/Modem.h b/Modem.h index 4a33116..fdca2e3 100644 --- a/Modem.h +++ b/Modem.h @@ -45,9 +45,9 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); - virtual bool setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); - virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); + virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); @@ -185,10 +185,35 @@ private: unsigned char m_mode; HW_TYPE m_hwType; + std::string m_fmCallsign; + unsigned int m_fmCallsignSpeed; + unsigned int m_fmCallsignFrequency; + unsigned int m_fmCallsignTime; + unsigned int m_fmCallsignHoldoff; + float m_fmCallsignLevel; + bool m_fmCallsignAtStart; + bool m_fmCallsignAtEnd; + std::string m_fmRfAck; + unsigned int m_fmAckSpeed; + unsigned int m_fmAckFrequency; + unsigned int m_fmAckMinTime; + unsigned int m_fmAckDelay; + float m_fmAckLevel; + unsigned int m_fmTimeout; + float m_fmTimeoutLevel; + float m_fmCtcssFrequency; + float m_fmCtcssThreshold; + float m_fmCtcssLevel; + unsigned int m_fmKerchunkTime; + unsigned int m_fmHangTime; + bool readVersion(); bool readStatus(); bool setConfig(); bool setFrequency(); + bool setFMCallsignParams(); + bool setFMAckParams(); + bool setFMMiscParams(); void printDebug(); From 9acd523bc309629865a9b3091885e7cd25122bfe Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 19 Apr 2020 16:36:29 +0200 Subject: [PATCH 20/50] Fix Set FM params after creating modem, not before --- MMDVMHost.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 751d25f..bddfd65 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1199,6 +1199,14 @@ bool CMMDVMHost::createModem() LogInfo(" FM RX Level: %.1f%%", fmRXLevel); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); + m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); + m_modem->setSerialParams(protocol,address); + m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); + m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel, fmRXLevel); + m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); + m_modem->setDMRParams(colorCode); + m_modem->setYSFParams(lowDeviation, txHang); + if (m_fmEnabled) { std::string callsign = m_conf.getFMCallsign(); unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); @@ -1252,14 +1260,6 @@ bool CMMDVMHost::createModem() m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } - m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); - m_modem->setSerialParams(protocol,address); - m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); - m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel, fmRXLevel); - m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); - m_modem->setDMRParams(colorCode); - m_modem->setYSFParams(lowDeviation, txHang); - bool ret = m_modem->open(); if (!ret) { delete m_modem; From cb732c9a62eb640bf51db663952f5b1f288b66ee Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 19 Apr 2020 16:11:55 +0100 Subject: [PATCH 21/50] Only allow FM mode in full duplex. --- Modem.cpp | 4 ++-- Version.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modem.cpp b/Modem.cpp index 850b2e6..df2c9c5 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -301,7 +301,7 @@ bool CModem::open() return false; } - if (m_fmEnabled) { + if (m_fmEnabled && m_duplex) { ret = setFMCallsignParams(); if (!ret) { m_serial->close(); @@ -1528,7 +1528,7 @@ bool CModem::setConfig() buffer[4U] |= 0x10U; if (m_pocsagEnabled) buffer[4U] |= 0x20U; - if (m_fmEnabled) + if (m_fmEnabled && m_duplex) buffer[4U] |= 0x40U; buffer[5U] = m_txDelay / 10U; // In 10ms units diff --git a/Version.h b/Version.h index 049e6ea..4029d27 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200418"; +const char* VERSION = "20200419"; #endif From 93effcad3d3e5d927bf453e842c1f299f8e41d5d Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 20 Apr 2020 13:21:56 +0100 Subject: [PATCH 22/50] Convert the CTCSS threshold to a raw value. --- Conf.cpp | 6 +++--- Conf.h | 4 ++-- MMDVM.ini | 2 +- MMDVMHost.cpp | 4 ++-- Modem.cpp | 6 +++--- Modem.h | 4 ++-- Version.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 1663d48..c964b61 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -192,7 +192,7 @@ m_fmAckLevel(80.0F), m_fmTimeout(180U), m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), -m_fmCTCSSThreshold(10.0F), +m_fmCTCSSThreshold(25U), m_fmCTCSSLevel(5.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), @@ -739,7 +739,7 @@ bool CConf::read() else if (::strcmp(key, "CTCSSFrequency") == 0) m_fmCTCSSFrequency = float(::atof(value)); else if (::strcmp(key, "CTCSSThreshold") == 0) - m_fmCTCSSThreshold = float(::atoi(value)); + m_fmCTCSSThreshold = (unsigned int)::atoi(value); else if (::strcmp(key, "CTCSSLevel") == 0) m_fmCTCSSLevel = float(::atof(value)); else if (::strcmp(key, "KerchunkTime") == 0) @@ -1583,7 +1583,7 @@ float CConf::getFMCTCSSFrequency() const return m_fmCTCSSFrequency; } -float CConf::getFMCTCSSThreshold() const +unsigned int CConf::getFMCTCSSThreshold() const { return m_fmCTCSSThreshold; } diff --git a/Conf.h b/Conf.h index af882a2..df6a581 100644 --- a/Conf.h +++ b/Conf.h @@ -190,7 +190,7 @@ public: unsigned int getFMTimeout() const; float getFMTimeoutLevel() const; float getFMCTCSSFrequency() const; - float getFMCTCSSThreshold() const; + unsigned int getFMCTCSSThreshold() const; float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; @@ -451,7 +451,7 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCTCSSFrequency; - float m_fmCTCSSThreshold; + unsigned int m_fmCTCSSThreshold; float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/MMDVM.ini b/MMDVM.ini index c8a5403..b9a1220 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -160,7 +160,7 @@ AckLevel=80 # Timeout=180 TimeoutLevel=80 CTCSSFrequency=88.8 -CTCSSThreshold=10 +CTCSSThreshold=25 CTCSSLevel=5 KerchunkTime=0 HangTime=7 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index bddfd65..9246195 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1226,7 +1226,7 @@ bool CMMDVMHost::createModem() unsigned int timeout = m_conf.getFMTimeout(); float timeoutLevel = m_conf.getFMTimeoutLevel(); float ctcssFrequency = m_conf.getFMCTCSSFrequency(); - float ctcssThreshold = m_conf.getFMCTCSSThreshold(); + unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); float ctcssLevel = m_conf.getFMCTCSSLevel(); unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); @@ -1250,7 +1250,7 @@ bool CMMDVMHost::createModem() LogInfo(" Timeout: %us", timeout); LogInfo(" Timeout Level: %.1f%%", timeoutLevel); LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); - LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold); + LogInfo(" CTCSS Threshold: %u", ctcssThreshold); LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); diff --git a/Modem.cpp b/Modem.cpp index df2c9c5..f443cec 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -187,7 +187,7 @@ m_fmAckLevel(80.0F), m_fmTimeout(120U), m_fmTimeoutLevel(80.0F), m_fmCtcssFrequency(88.4F), -m_fmCtcssThreshold(10.0F), +m_fmCtcssThreshold(25U), m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U) @@ -1903,7 +1903,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -2040,7 +2040,7 @@ bool CModem::setFMMiscParams() buffer[4U] = (unsigned char)(m_fmTimeoutLevel * 2.55F + 0.5F); buffer[5U] = (unsigned char)m_fmCtcssFrequency; - buffer[6U] = (unsigned char)(m_fmCtcssThreshold * 2.55F + 0.5F); + buffer[6U] = m_fmCtcssThreshold; buffer[7U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); buffer[8U] = m_fmKerchunkTime; diff --git a/Modem.h b/Modem.h index fdca2e3..a4181cd 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); @@ -202,7 +202,7 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCtcssFrequency; - float m_fmCtcssThreshold; + unsigned int m_fmCtcssThreshold; float m_fmCtcssLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/Version.h b/Version.h index 4029d27..5532a2c 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200419"; +const char* VERSION = "20200420"; #endif From 6df6094ebf9fad2da558e367e2159bc1e398cf8f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 21 Apr 2020 21:46:39 +0100 Subject: [PATCH 23/50] Change the levels for FM. --- MMDVM.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MMDVM.ini b/MMDVM.ini index b9a1220..0cc32f2 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -147,7 +147,7 @@ CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 CallsignHoldoff=1 -CallsignLevel=40 +CallsignLevel=35 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K @@ -156,12 +156,12 @@ AckSpeed=20 AckFrequency=1750 AckMinTime=4 AckDelay=1000 -AckLevel=80 +AckLevel=35 # Timeout=180 TimeoutLevel=80 CTCSSFrequency=88.8 -CTCSSThreshold=25 -CTCSSLevel=5 +CTCSSThreshold=40 +CTCSSLevel=2 KerchunkTime=0 HangTime=7 From 0d956b16fa5788e2996c9c944f70395355137a4d Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Apr 2020 21:51:43 +0100 Subject: [PATCH 24/50] Add a second callsign level setting. --- Conf.cpp | 22 +++++++++++++++------- Conf.h | 6 ++++-- MMDVM.ini | 3 ++- MMDVMHost.cpp | 8 +++++--- Modem.cpp | 21 ++++++++++++--------- Modem.h | 5 +++-- Version.h | 2 +- 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index c964b61..3764a61 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -179,7 +179,8 @@ m_fmCallsignSpeed(20U), m_fmCallsignFrequency(1000U), m_fmCallsignTime(10U), m_fmCallsignHoldoff(1U), -m_fmCallsignLevel(40.0F), +m_fmCallsignHighLevel(35.0F), +m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmRFAck("K"), @@ -192,8 +193,8 @@ m_fmAckLevel(80.0F), m_fmTimeout(180U), m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), -m_fmCTCSSThreshold(25U), -m_fmCTCSSLevel(5.0F), +m_fmCTCSSThreshold(40U), +m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_dstarNetworkEnabled(false), @@ -706,8 +707,10 @@ bool CConf::read() m_fmCallsignTime = (unsigned int)::atoi(value); else if (::strcmp(key, "CallsignHoldoff") == 0) m_fmCallsignHoldoff = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignLevel") == 0) - m_fmCallsignLevel = float(::atof(value)); + else if (::strcmp(key, "CallsignHighLevel") == 0) + m_fmCallsignHighLevel = float(::atof(value)); + else if (::strcmp(key, "CallsignLowLevel") == 0) + m_fmCallsignLowLevel = float(::atof(value)); else if (::strcmp(key, "CallsignAtStart") == 0) m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) @@ -1518,9 +1521,14 @@ unsigned int CConf::getFMCallsignHoldoff() const return m_fmCallsignHoldoff; } -float CConf::getFMCallsignLevel() const +float CConf::getFMCallsignHighLevel() const { - return m_fmCallsignLevel; + return m_fmCallsignHighLevel; +} + +float CConf::getFMCallsignLowLevel() const +{ + return m_fmCallsignLowLevel; } bool CConf::getFMCallsignAtStart() const diff --git a/Conf.h b/Conf.h index df6a581..1fa10b0 100644 --- a/Conf.h +++ b/Conf.h @@ -177,7 +177,8 @@ public: unsigned int getFMCallsignFrequency() const; unsigned int getFMCallsignTime() const; unsigned int getFMCallsignHoldoff() const; - float getFMCallsignLevel() const; + float getFMCallsignHighLevel() const; + float getFMCallsignLowLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; std::string getFMRFAck() const; @@ -438,7 +439,8 @@ private: unsigned int m_fmCallsignFrequency; unsigned int m_fmCallsignTime; unsigned int m_fmCallsignHoldoff; - float m_fmCallsignLevel; + float m_fmCallsignHighLevel; + float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmRFAck; diff --git a/MMDVM.ini b/MMDVM.ini index 0cc32f2..063505f 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -147,7 +147,8 @@ CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 CallsignHoldoff=1 -CallsignLevel=35 +CallsignHighLevel=35 +CallsignLowLevel=15 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9246195..dc19d45 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1213,7 +1213,8 @@ bool CMMDVMHost::createModem() unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); unsigned int callsignTime = m_conf.getFMCallsignTime(); unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - float callsignLevel = m_conf.getFMCallsignLevel(); + float callsignHighLevel = m_conf.getFMCallsignHighLevel(); + float callsignLowLevel = m_conf.getFMCallsignLowLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); std::string rfAck = m_conf.getFMRFAck(); @@ -1237,7 +1238,8 @@ bool CMMDVMHost::createModem() LogInfo(" Callsign Frequency: %uHz", callsignFrequency); LogInfo(" Callsign Time: %umins", callsignTime); LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); - LogInfo(" Callsign Level: %.1f%%", callsignLevel); + LogInfo(" Callsign High Level: %.1f%%", callsignHighLevel); + LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); @@ -1255,7 +1257,7 @@ bool CMMDVMHost::createModem() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } diff --git a/Modem.cpp b/Modem.cpp index f443cec..f26ca53 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -175,7 +175,8 @@ m_fmCallsignSpeed(20U), m_fmCallsignFrequency(1000U), m_fmCallsignTime(600U), m_fmCallsignHoldoff(0U), -m_fmCallsignLevel(40.0F), +m_fmCallsignHighLevel(35.0F), +m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmRfAck("K"), @@ -1881,14 +1882,15 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd) +void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) { m_fmCallsign = callsign; m_fmCallsignSpeed = callsignSpeed; m_fmCallsignFrequency = callsignFrequency; m_fmCallsignTime = callsignTime; m_fmCallsignHoldoff = callsignHoldoff; - m_fmCallsignLevel = callsignLevel; + m_fmCallsignHighLevel = callsignHighLevel; + m_fmCallsignLowLevel = callsignLowLevel; m_fmCallsignAtStart = callsignAtStart; m_fmCallsignAtEnd = callsignAtEnd; } @@ -1921,7 +1923,7 @@ bool CModem::setFMCallsignParams() assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 9U + m_fmCallsign.size(); + unsigned char len = 10U + m_fmCallsign.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; @@ -1932,16 +1934,17 @@ bool CModem::setFMCallsignParams() buffer[5U] = m_fmCallsignTime; buffer[6U] = m_fmCallsignHoldoff; - buffer[7U] = (unsigned char)(m_fmCallsignLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(m_fmCallsignHighLevel * 2.55F + 0.5F); + buffer[8U] = (unsigned char)(m_fmCallsignLowLevel * 2.55F + 0.5F); - buffer[8U] = 0x00U; + buffer[9U] = 0x00U; if (m_fmCallsignAtStart) - buffer[8U] |= 0x01U; + buffer[9U] |= 0x01U; if (m_fmCallsignAtEnd) - buffer[8U] |= 0x02U; + buffer[9U] |= 0x02U; for (unsigned int i = 0U; i < m_fmCallsign.size(); i++) - buffer[9U + i] = m_fmCallsign.at(i); + buffer[10U + i] = m_fmCallsign.at(i); // CUtils::dump(1U, "Written", buffer, len); diff --git a/Modem.h b/Modem.h index a4181cd..5db21bd 100644 --- a/Modem.h +++ b/Modem.h @@ -45,7 +45,7 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); + virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); @@ -190,7 +190,8 @@ private: unsigned int m_fmCallsignFrequency; unsigned int m_fmCallsignTime; unsigned int m_fmCallsignHoldoff; - float m_fmCallsignLevel; + float m_fmCallsignHighLevel; + float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmRfAck; diff --git a/Version.h b/Version.h index 5532a2c..ac2d5dc 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200420"; +const char* VERSION = "20200422"; #endif From fbdee0edf1b8aed5ad74f6b89c437c8601e6f197 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 24 Apr 2020 12:59:33 +0100 Subject: [PATCH 25/50] Remove the FM RX level. --- Conf.cpp | 10 +--------- Conf.h | 2 -- MMDVM.ini | 1 - MMDVMHost.cpp | 4 +--- Modem.cpp | 13 +++++-------- Modem.h | 3 +-- Version.h | 2 +- 7 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 3764a61..3641e73 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -111,7 +111,6 @@ m_modemP25TXLevel(50.0F), m_modemNXDNTXLevel(50.0F), m_modemPOCSAGTXLevel(50.0F), m_modemFMTXLevel(50.0F), -m_modemFMRXLevel(50.0F), m_modemRSSIMappingFile(), m_modemTrace(false), m_modemDebug(false), @@ -483,7 +482,7 @@ bool CConf::read() else if (::strcmp(key, "RFLevel") == 0) m_modemRFLevel = float(::atof(value)); else if (::strcmp(key, "RXLevel") == 0) - m_modemFMRXLevel = m_modemRXLevel = float(::atof(value)); + m_modemRXLevel = float(::atof(value)); else if (::strcmp(key, "TXLevel") == 0) m_modemFMTXLevel = m_modemCWIdTXLevel = m_modemDStarTXLevel = m_modemDMRTXLevel = m_modemYSFTXLevel = m_modemP25TXLevel = m_modemNXDNTXLevel = float(::atof(value)); else if (::strcmp(key, "CWIdTXLevel") == 0) @@ -502,8 +501,6 @@ bool CConf::read() m_modemPOCSAGTXLevel = float(::atof(value)); else if (::strcmp(key, "FMTXLevel") == 0) m_modemFMTXLevel = float(::atof(value)); - else if (::strcmp(key, "FMRXLevel") == 0) - m_modemFMRXLevel = float(::atof(value)); else if (::strcmp(key, "RSSIMappingFile") == 0) m_modemRSSIMappingFile = value; else if (::strcmp(key, "Trace") == 0) @@ -1181,11 +1178,6 @@ float CConf::getModemFMTXLevel() const return m_modemFMTXLevel; } -float CConf::getModemFMRXLevel() const -{ - return m_modemFMRXLevel; -} - std::string CConf::getModemRSSIMappingFile () const { return m_modemRSSIMappingFile; diff --git a/Conf.h b/Conf.h index 1fa10b0..7be95d6 100644 --- a/Conf.h +++ b/Conf.h @@ -91,7 +91,6 @@ public: float getModemNXDNTXLevel() const; float getModemPOCSAGTXLevel() const; float getModemFMTXLevel() const; - float getModemFMRXLevel() const; std::string getModemRSSIMappingFile() const; bool getModemTrace() const; bool getModemDebug() const; @@ -362,7 +361,6 @@ private: float m_modemNXDNTXLevel; float m_modemPOCSAGTXLevel; float m_modemFMTXLevel; - float m_modemFMRXLevel; std::string m_modemRSSIMappingFile; bool m_modemTrace; bool m_modemDebug; diff --git a/MMDVM.ini b/MMDVM.ini index 063505f..d2a42ce 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -66,7 +66,6 @@ RFLevel=100 # NXDNTXLevel=50 # POCSAGTXLevel=50 # FMTXLevel=50 -# FMRXLevel=50 RSSIMappingFile=RSSI.dat Trace=0 Debug=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index dc19d45..123f4ee 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1157,7 +1157,6 @@ bool CMMDVMHost::createModem() float nxdnTXLevel = m_conf.getModemNXDNTXLevel(); float pocsagTXLevel = m_conf.getModemPOCSAGTXLevel(); float fmTXLevel = m_conf.getModemFMTXLevel(); - float fmRXLevel = m_conf.getModemFMRXLevel(); bool trace = m_conf.getModemTrace(); bool debug = m_conf.getModemDebug(); unsigned int colorCode = m_conf.getDMRColorCode(); @@ -1196,13 +1195,12 @@ bool CMMDVMHost::createModem() LogInfo(" NXDN TX Level: %.1f%%", nxdnTXLevel); LogInfo(" POCSAG TX Level: %.1f%%", pocsagTXLevel); LogInfo(" FM TX Level: %.1f%%", fmTXLevel); - LogInfo(" FM RX Level: %.1f%%", fmRXLevel); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); m_modem->setSerialParams(protocol,address); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); - m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel, fmRXLevel); + m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel); m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); m_modem->setDMRParams(colorCode); m_modem->setYSFParams(lowDeviation, txHang); diff --git a/Modem.cpp b/Modem.cpp index f26ca53..5bc6485 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -119,7 +119,6 @@ m_p25TXLevel(0U), m_nxdnTXLevel(0U), m_pocsagTXLevel(0U), m_fmTXLevel(0U), -m_fmRXLevel(0U), m_trace(trace), m_debug(debug), m_rxFrequency(0U), @@ -234,7 +233,7 @@ void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, m_fmEnabled = fmEnabled; } -void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagTXLevel, float fmTXLevel, float fmRXLevel) +void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagTXLevel, float fmTXLevel) { m_rxLevel = rxLevel; m_cwIdTXLevel = cwIdTXLevel; @@ -245,7 +244,6 @@ void CModem::setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, flo m_nxdnTXLevel = nxdnTXLevel; m_pocsagTXLevel = pocsagTXLevel; m_fmTXLevel = fmTXLevel; - m_fmRXLevel = fmRXLevel; } void CModem::setDMRParams(unsigned int colorCode) @@ -1498,7 +1496,7 @@ bool CModem::setConfig() buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 23U; + buffer[1U] = 22U; buffer[2U] = MMDVM_SET_CONFIG; @@ -1561,12 +1559,11 @@ bool CModem::setConfig() buffer[20U] = (unsigned char)(m_pocsagTXLevel * 2.55F + 0.5F); buffer[21U] = (unsigned char)(m_fmTXLevel * 2.55F + 0.5F); - buffer[22U] = (unsigned char)(m_fmRXLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 23U); + // CUtils::dump(1U, "Written", buffer, 22U); - int ret = m_serial->write(buffer, 23U); - if (ret != 23) + int ret = m_serial->write(buffer, 22U); + if (ret != 22) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 5db21bd..d879b1c 100644 --- a/Modem.h +++ b/Modem.h @@ -40,7 +40,7 @@ public: virtual void setSerialParams(const std::string& protocol, unsigned int address); virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency); virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled); - virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel, float fmRXLevel); + virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel); virtual void setDMRParams(unsigned int colorCode); virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); @@ -132,7 +132,6 @@ private: float m_nxdnTXLevel; float m_pocsagTXLevel; float m_fmTXLevel; - float m_fmRXLevel; float m_rfLevel; bool m_trace; bool m_debug; diff --git a/Version.h b/Version.h index ac2d5dc..b5fc453 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200422"; +const char* VERSION = "20200424"; #endif From a73c0dbd72a1861e3f441cfa03575c6098a5ece1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 24 Apr 2020 13:16:21 +0100 Subject: [PATCH 26/50] Rescale some of the levels. --- MMDVM.ini | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MMDVM.ini b/MMDVM.ini index d2a42ce..f083c88 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -145,9 +145,9 @@ Callsign=G4KLX CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 -CallsignHoldoff=1 -CallsignHighLevel=35 -CallsignLowLevel=15 +CallsignHoldoff=0 +CallsignHighLevel=50 +CallsignLowLevel=20 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K @@ -156,12 +156,12 @@ AckSpeed=20 AckFrequency=1750 AckMinTime=4 AckDelay=1000 -AckLevel=35 +AckLevel=50 # Timeout=180 TimeoutLevel=80 -CTCSSFrequency=88.8 -CTCSSThreshold=40 -CTCSSLevel=2 +CTCSSFrequency=88.4 +CTCSSThreshold=30 +CTCSSLevel=20 KerchunkTime=0 HangTime=7 From ac344cec69f1bb36bf61f0e3b91cf82f7a513b7a Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 24 Apr 2020 15:37:26 +0100 Subject: [PATCH 27/50] Allow for a global callsign. --- Conf.cpp | 2 +- MMDVM.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 3641e73..0b573bb 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -387,7 +387,7 @@ bool CConf::read() // Convert the callsign to upper case for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); - m_cwIdCallsign = m_callsign = value; + m_fmCallsign = m_cwIdCallsign = m_callsign = value; } else if (::strcmp(key, "Id") == 0) m_id = m_p25Id = m_dmrId = (unsigned int)::atoi(value); else if (::strcmp(key, "Timeout") == 0) diff --git a/MMDVM.ini b/MMDVM.ini index f083c88..25aabde 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -141,7 +141,7 @@ Frequency=439987500 [FM] Enable=1 -Callsign=G4KLX +# Callsign=G4KLX CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 From 3d1602e50e8d9d0637ece47eb26ddbbda1df9718 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 25 Apr 2020 15:15:56 +0100 Subject: [PATCH 28/50] Add two more FM parameters. --- Conf.cpp | 16 ++++++++++++++++ Conf.h | 4 ++++ MMDVM.ini | 2 ++ MMDVMHost.cpp | 6 +++++- Modem.cpp | 23 +++++++++++++++++------ Modem.h | 4 +++- Version.h | 2 +- 7 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 0b573bb..a83792e 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -196,6 +196,8 @@ m_fmCTCSSThreshold(40U), m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), +m_fmUseCOS(true), +m_fmRXBoost(1U), m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), @@ -746,6 +748,10 @@ bool CConf::read() m_fmKerchunkTime = (unsigned int)::atoi(value); else if (::strcmp(key, "HangTime") == 0) m_fmHangTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "UseCOS") == 0) + m_fmUseCOS = ::atoi(value) == 1; + else if (::strcmp(key, "RXBoost") == 0) + m_fmRXBoost = (unsigned int)::atoi(value); } else if (section == SECTION_DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; @@ -1603,6 +1609,16 @@ unsigned int CConf::getFMHangTime() const return m_fmHangTime; } +bool CConf::getFMUseCOS() const +{ + return m_fmUseCOS; +} + +unsigned int CConf::getFMRXBoost() const +{ + return m_fmRXBoost; +} + bool CConf::getDStarNetworkEnabled() const { return m_dstarNetworkEnabled; diff --git a/Conf.h b/Conf.h index 7be95d6..1e2ac51 100644 --- a/Conf.h +++ b/Conf.h @@ -194,6 +194,8 @@ public: float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; + bool getFMUseCOS() const; + unsigned int getFMRXBoost() const; // The D-Star Network section bool getDStarNetworkEnabled() const; @@ -455,6 +457,8 @@ private: float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; + bool m_fmUseCOS; + unsigned int m_fmRXBoost; bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; diff --git a/MMDVM.ini b/MMDVM.ini index 25aabde..36b1c1b 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -164,6 +164,8 @@ CTCSSThreshold=30 CTCSSLevel=20 KerchunkTime=0 HangTime=7 +UseCOS=1 +RXBoost=1 [D-Star Network] Enable=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 123f4ee..2ba9346 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1229,6 +1229,8 @@ bool CMMDVMHost::createModem() float ctcssLevel = m_conf.getFMCTCSSLevel(); unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); + bool useCOS = m_conf.getFMUseCOS(); + unsigned int rxBoost = m_conf.getFMRXBoost(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1254,10 +1256,12 @@ bool CMMDVMHost::createModem() LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); + LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); + LogInfo(" RX Boost: x%u", rxBoost); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 5bc6485..2f6d24b 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -190,7 +190,9 @@ m_fmCtcssFrequency(88.4F), m_fmCtcssThreshold(25U), m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), -m_fmHangTime(5U) +m_fmHangTime(5U), +m_fmUseCOS(true), +m_fmRXBoost(1U) { m_buffer = new unsigned char[BUFFER_LENGTH]; @@ -1902,7 +1904,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1913,6 +1915,9 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmKerchunkTime = kerchunkTime; m_fmHangTime = hangTime; + + m_fmUseCOS = useCOS; + m_fmRXBoost = rxBoost; } bool CModem::setFMCallsignParams() @@ -2033,7 +2038,7 @@ bool CModem::setFMMiscParams() unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 10U; + buffer[1U] = 12U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = m_fmTimeout / 5U; @@ -2046,10 +2051,16 @@ bool CModem::setFMMiscParams() buffer[8U] = m_fmKerchunkTime; buffer[9U] = m_fmHangTime; - // CUtils::dump(1U, "Written", buffer, 10U); + buffer[10U] = 0x00U; + if (m_fmUseCOS) + buffer[10U] |= 0x01U; - int ret = m_serial->write(buffer, 10U); - if (ret != 10) + buffer[11U] = m_fmRXBoost; + + // CUtils::dump(1U, "Written", buffer, 12U); + + int ret = m_serial->write(buffer, 12U); + if (ret != 12) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index d879b1c..2aecf67 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost); virtual bool open(); @@ -206,6 +206,8 @@ private: float m_fmCtcssLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; + bool m_fmUseCOS; + unsigned int m_fmRXBoost; bool readVersion(); bool readStatus(); diff --git a/Version.h b/Version.h index b5fc453..5247a92 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200424"; +const char* VERSION = "20200425"; #endif From 56746e1320863ec4ab56d57dfcb423915d0ef7a0 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 25 Apr 2020 22:43:14 +0100 Subject: [PATCH 29/50] Add the maximum deviation level. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 16 ++++++++++------ Modem.h | 3 ++- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index a83792e..f1e3643 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -198,6 +198,7 @@ m_fmKerchunkTime(0U), m_fmHangTime(7U), m_fmUseCOS(true), m_fmRXBoost(1U), +m_fmMaxDevLevel(90.0F), m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), @@ -752,6 +753,8 @@ bool CConf::read() m_fmUseCOS = ::atoi(value) == 1; else if (::strcmp(key, "RXBoost") == 0) m_fmRXBoost = (unsigned int)::atoi(value); + else if (::strcmp(key, "MaxDevLevel") == 0) + m_fmMaxDevLevel = float(::atof(value)); } else if (section == SECTION_DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; @@ -1619,6 +1622,11 @@ unsigned int CConf::getFMRXBoost() const return m_fmRXBoost; } +float CConf::getFMMaxDevLevel() const +{ + return m_fmMaxDevLevel; +} + bool CConf::getDStarNetworkEnabled() const { return m_dstarNetworkEnabled; diff --git a/Conf.h b/Conf.h index 1e2ac51..41f0d96 100644 --- a/Conf.h +++ b/Conf.h @@ -196,6 +196,7 @@ public: unsigned int getFMHangTime() const; bool getFMUseCOS() const; unsigned int getFMRXBoost() const; + float getFMMaxDevLevel() const; // The D-Star Network section bool getDStarNetworkEnabled() const; @@ -459,6 +460,7 @@ private: unsigned int m_fmHangTime; bool m_fmUseCOS; unsigned int m_fmRXBoost; + float m_fmMaxDevLevel; bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; diff --git a/MMDVM.ini b/MMDVM.ini index 36b1c1b..2ae5180 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -166,6 +166,7 @@ KerchunkTime=0 HangTime=7 UseCOS=1 RXBoost=1 +MaxDevLevel=90 [D-Star Network] Enable=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2ba9346..09b9e08 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1231,6 +1231,7 @@ bool CMMDVMHost::createModem() unsigned int hangTime = m_conf.getFMHangTime(); bool useCOS = m_conf.getFMUseCOS(); unsigned int rxBoost = m_conf.getFMRXBoost(); + float maxDevLevel = m_conf.getFMMaxDevLevel(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1258,10 +1259,11 @@ bool CMMDVMHost::createModem() LogInfo(" Hang Time: %us", hangTime); LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); LogInfo(" RX Boost: x%u", rxBoost); + LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 2f6d24b..1c6695e 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -192,7 +192,8 @@ m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), m_fmUseCOS(true), -m_fmRXBoost(1U) +m_fmRXBoost(1U), +m_fmMaxDevLevel(90.0F) { m_buffer = new unsigned char[BUFFER_LENGTH]; @@ -1904,7 +1905,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1918,6 +1919,7 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmUseCOS = useCOS; m_fmRXBoost = rxBoost; + m_fmMaxDevLevel = maxDevLevel; } bool CModem::setFMCallsignParams() @@ -2038,7 +2040,7 @@ bool CModem::setFMMiscParams() unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 12U; + buffer[1U] = 13U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = m_fmTimeout / 5U; @@ -2057,10 +2059,12 @@ bool CModem::setFMMiscParams() buffer[11U] = m_fmRXBoost; - // CUtils::dump(1U, "Written", buffer, 12U); + buffer[12U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); - int ret = m_serial->write(buffer, 12U); - if (ret != 12) + // CUtils::dump(1U, "Written", buffer, 13U); + + int ret = m_serial->write(buffer, 13U); + if (ret != 13) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 2aecf67..2906538 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost, float maxDevLevel); virtual bool open(); @@ -208,6 +208,7 @@ private: unsigned int m_fmHangTime; bool m_fmUseCOS; unsigned int m_fmRXBoost; + float m_fmMaxDevLevel; bool readVersion(); bool readStatus(); From 463bda2688ed739f5d4aed288006ea838462894f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 26 Apr 2020 13:23:26 +0100 Subject: [PATCH 30/50] Bump the version date. --- Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version.h b/Version.h index 5247a92..2ec3a11 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200425"; +const char* VERSION = "20200426"; #endif From 70ca7c06dd9ae2f8afbe1e0369a372d4d27aa3b1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 26 Apr 2020 21:50:03 +0100 Subject: [PATCH 31/50] Pass the RX level to the FM controller. --- Modem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Modem.cpp b/Modem.cpp index 1c6695e..75413cf 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -2040,7 +2040,7 @@ bool CModem::setFMMiscParams() unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 13U; + buffer[1U] = 14U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = m_fmTimeout / 5U; @@ -2061,10 +2061,12 @@ bool CModem::setFMMiscParams() buffer[12U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 13U); + buffer[13U] = (unsigned char)(m_rxLevel * 2.55F + 0.5F); - int ret = m_serial->write(buffer, 13U); - if (ret != 13) + // CUtils::dump(1U, "Written", buffer, 14U); + + int ret = m_serial->write(buffer, 14U); + if (ret != 14) return false; unsigned int count = 0U; From 4a923fb27e9789f031052835fdc1c7ef1815204c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 28 Apr 2020 14:39:14 +0100 Subject: [PATCH 32/50] Rename RXBoost to RFAudioBoost. --- Conf.cpp | 28 ++++++++++++++++++---------- Conf.h | 10 ++++++---- MMDVM.ini | 7 ++++--- MMDVMHost.cpp | 12 +++++++----- Modem.cpp | 8 ++++---- Modem.h | 4 ++-- Version.h | 2 +- 7 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index f1e3643..e204fa9 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -183,7 +183,7 @@ m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmRFAck("K"), -m_fmNetAck("N"), +m_fmExtAck("N"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), m_fmAckMinTime(5U), @@ -197,8 +197,9 @@ m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_fmUseCOS(true), -m_fmRXBoost(1U), +m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F), +m_fmExtAudioBoost(1U), m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), @@ -720,11 +721,11 @@ bool CConf::read() for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); m_fmRFAck = value; - } else if (::strcmp(key, "NetAck") == 0) { + } else if (::strcmp(key, "ExtAck") == 0) { // Convert the ack to upper case for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); - m_fmNetAck = value; + m_fmExtAck = value; } else if (::strcmp(key, "AckSpeed") == 0) m_fmAckSpeed = (unsigned int)::atoi(value); else if (::strcmp(key, "AckFrequency") == 0) @@ -751,10 +752,12 @@ bool CConf::read() m_fmHangTime = (unsigned int)::atoi(value); else if (::strcmp(key, "UseCOS") == 0) m_fmUseCOS = ::atoi(value) == 1; - else if (::strcmp(key, "RXBoost") == 0) - m_fmRXBoost = (unsigned int)::atoi(value); + else if (::strcmp(key, "RFAudioBoost") == 0) + m_fmRFAudioBoost = (unsigned int)::atoi(value); else if (::strcmp(key, "MaxDevLevel") == 0) m_fmMaxDevLevel = float(::atof(value)); + else if (::strcmp(key, "ExtAudioBoost") == 0) + m_fmExtAudioBoost = (unsigned int)::atoi(value); } else if (section == SECTION_DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; @@ -1547,9 +1550,9 @@ std::string CConf::getFMRFAck() const return m_fmRFAck; } -std::string CConf::getFMNetAck() const +std::string CConf::getFMExtAck() const { - return m_fmNetAck; + return m_fmExtAck; } unsigned int CConf::getFMAckSpeed() const @@ -1617,9 +1620,9 @@ bool CConf::getFMUseCOS() const return m_fmUseCOS; } -unsigned int CConf::getFMRXBoost() const +unsigned int CConf::getFMRFAudioBoost() const { - return m_fmRXBoost; + return m_fmRFAudioBoost; } float CConf::getFMMaxDevLevel() const @@ -1627,6 +1630,11 @@ float CConf::getFMMaxDevLevel() const return m_fmMaxDevLevel; } +unsigned int CConf::getFMExtAudioBoost() const +{ + return m_fmExtAudioBoost; +} + bool CConf::getDStarNetworkEnabled() const { return m_dstarNetworkEnabled; diff --git a/Conf.h b/Conf.h index 41f0d96..14678e1 100644 --- a/Conf.h +++ b/Conf.h @@ -181,7 +181,7 @@ public: bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; std::string getFMRFAck() const; - std::string getFMNetAck() const; + std::string getFMExtAck() const; unsigned int getFMAckSpeed() const; unsigned int getFMAckFrequency() const; unsigned int getFMAckMinTime() const; @@ -195,8 +195,9 @@ public: unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; bool getFMUseCOS() const; - unsigned int getFMRXBoost() const; + unsigned int getFMRFAudioBoost() const; float getFMMaxDevLevel() const; + unsigned int getFMExtAudioBoost() const; // The D-Star Network section bool getDStarNetworkEnabled() const; @@ -445,7 +446,7 @@ private: bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmRFAck; - std::string m_fmNetAck; + std::string m_fmExtAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; unsigned int m_fmAckMinTime; @@ -459,8 +460,9 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; - unsigned int m_fmRXBoost; + unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; + unsigned int m_fmExtAudioBoost; bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; diff --git a/MMDVM.ini b/MMDVM.ini index 2ae5180..d504978 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -43,7 +43,7 @@ Time=24 [Modem] # Port=/dev/ttyACM0 # Port=/dev/ttyAMA0 -Port=\\.\COM3 +Port=\\.\COM4 Protocol=uart # Address=0x22 TXInvert=1 @@ -151,7 +151,7 @@ CallsignLowLevel=20 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K -# NetAck=N +ExtAck=N AckSpeed=20 AckFrequency=1750 AckMinTime=4 @@ -165,8 +165,9 @@ CTCSSLevel=20 KerchunkTime=0 HangTime=7 UseCOS=1 -RXBoost=1 +RFAudioBoost=1 MaxDevLevel=90 +ExtAudioBoost=1 [D-Star Network] Enable=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 09b9e08..2134223 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1216,7 +1216,7 @@ bool CMMDVMHost::createModem() bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); std::string rfAck = m_conf.getFMRFAck(); - std::string netAck = m_conf.getFMNetAck(); + std::string extAck = m_conf.getFMExtAck(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); unsigned int ackFrequency = m_conf.getFMAckFrequency(); unsigned int ackMinTime = m_conf.getFMAckMinTime(); @@ -1230,8 +1230,9 @@ bool CMMDVMHost::createModem() unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); bool useCOS = m_conf.getFMUseCOS(); - unsigned int rxBoost = m_conf.getFMRXBoost(); + unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); float maxDevLevel = m_conf.getFMMaxDevLevel(); + unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1244,7 +1245,7 @@ bool CMMDVMHost::createModem() LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); - // LogInfo(" Net Ack: %s", netAck.c_str()); + // LogInfo(" Ext. Ack: %s", extAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); LogInfo(" Ack Min Time: %us", ackMinTime); @@ -1258,12 +1259,13 @@ bool CMMDVMHost::createModem() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); - LogInfo(" RX Boost: x%u", rxBoost); + LogInfo(" RF Audio Boost: x%u", rfAudioBoost); LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); + // LogInfo(" Ext. Audio Boost: x%u", extAudioBoost); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 75413cf..729dd59 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -192,7 +192,7 @@ m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), m_fmUseCOS(true), -m_fmRXBoost(1U), +m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F) { m_buffer = new unsigned char[BUFFER_LENGTH]; @@ -1905,7 +1905,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1918,7 +1918,7 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmHangTime = hangTime; m_fmUseCOS = useCOS; - m_fmRXBoost = rxBoost; + m_fmRFAudioBoost = rfAudioBoost; m_fmMaxDevLevel = maxDevLevel; } @@ -2057,7 +2057,7 @@ bool CModem::setFMMiscParams() if (m_fmUseCOS) buffer[10U] |= 0x01U; - buffer[11U] = m_fmRXBoost; + buffer[11U] = m_fmRFAudioBoost; buffer[12U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); diff --git a/Modem.h b/Modem.h index 2906538..c12466f 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rxBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -207,7 +207,7 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; - unsigned int m_fmRXBoost; + unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; bool readVersion(); diff --git a/Version.h b/Version.h index 2ec3a11..8e901ee 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200426"; +const char* VERSION = "20200428"; #endif From 3687eb71a84891a374ca603cb24315e60f14169f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 2 May 2020 20:42:54 +0100 Subject: [PATCH 33/50] Add FM to the OLED display. --- OLED.cpp | 17 ++++++++++++++++- OLED.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index 8dbfbe5..6f9b4ec 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -306,6 +306,21 @@ void COLED::setQuitInt() m_display.display(); } +void COLED::setFMInt() +{ + m_mode = MODE_FM; + + m_display.clearDisplay(); + OLED_statusbar(); + + m_display.setCursor(0,30); + m_display.setTextSize(3); + m_display.print("FM"); + + m_display.setTextSize(1); + m_display.display(); +} + void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { m_mode = MODE_DSTAR; diff --git a/OLED.h b/OLED.h index 6f40371..dec7b41 100644 --- a/OLED.h +++ b/OLED.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX * * 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 @@ -50,6 +50,7 @@ public: virtual void setErrorInt(const char* text); virtual void setLockoutInt(); virtual void setQuitInt(); + virtual void setFMInt(); virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); From 9796b400c8053c553ee4bae0020c4e5cf4c49235 Mon Sep 17 00:00:00 2001 From: m0vse Date: Sat, 2 May 2020 21:40:55 +0100 Subject: [PATCH 34/50] Add enable/disable commands to RemoteCommand --- MMDVMHost.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ MMDVMHost.h | 1 + Modem.cpp | 5 ++++ Modem.h | 1 + RemoteControl.cpp | 28 ++++++++++++++++++++++ RemoteControl.h | 13 ++++++++++ 6 files changed, 109 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2134223..b9449e0 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1975,6 +1975,58 @@ void CMMDVMHost::remoteControl() if (m_nxdn != NULL) processModeCommand(MODE_NXDN, m_nxdnRFModeHang); break; + case RCD_MODE_FM: + if (m_fmEnabled != false) + processModeCommand(MODE_FM, 0); + break; + case RCD_ENABLE_DSTAR: + if (m_dstar != NULL && m_dstarEnabled==false) + processEnableCommand(m_dstarEnabled, true); + break; + case RCD_ENABLE_DMR: + if (m_dmr != NULL && m_dmrEnabled==false) + processEnableCommand(m_dmrEnabled, true); + break; + case RCD_ENABLE_YSF: + if (m_ysf != NULL && m_ysfEnabled==false) + processEnableCommand(m_ysfEnabled, true); + break; + case RCD_ENABLE_P25: + if (m_p25 != NULL && m_p25Enabled==false) + processEnableCommand(m_p25Enabled, true); + break; + case RCD_ENABLE_NXDN: + if (m_nxdn != NULL && m_nxdnEnabled==false) + processEnableCommand(m_nxdnEnabled, true); + break; + case RCD_ENABLE_FM: + if (m_fmEnabled==false) + processEnableCommand(m_fmEnabled, true); + break; + case RCD_DISABLE_DSTAR: + if (m_dstar != NULL && m_dstarEnabled==true) + processEnableCommand(m_dstarEnabled, false); + break; + case RCD_DISABLE_DMR: + if (m_dmr != NULL && m_dmrEnabled==true) + processEnableCommand(m_dmrEnabled, false); + break; + case RCD_DISABLE_YSF: + if (m_ysf != NULL && m_ysfEnabled==true) + processEnableCommand(m_ysfEnabled, false); + break; + case RCD_DISABLE_P25: + if (m_p25 != NULL && m_p25Enabled==true) + processEnableCommand(m_p25Enabled, false); + break; + case RCD_DISABLE_NXDN: + if (m_nxdn != NULL && m_nxdnEnabled==true) + processEnableCommand(m_nxdnEnabled, false); + break; + case RCD_DISABLE_FM: + if (m_fmEnabled == true) + processEnableCommand(m_fmEnabled, false); + break; case RCD_PAGE: if (m_pocsag != NULL) { unsigned int ric = m_remoteControl->getArgUInt(0U); @@ -2008,3 +2060,12 @@ void CMMDVMHost::processModeCommand(unsigned char mode, unsigned int timeout) setMode(mode); } + +void CMMDVMHost::processEnableCommand(bool& mode, bool enabled) +{ + LogDebug("Setting mode current=%s new=%s",mode ? "true" : "false",enabled ? "true" : "false"); + mode=enabled; + m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); + if (!m_modem->writeConfig()) + LogError("Cannot write Config to MMDVM"); +} diff --git a/MMDVMHost.h b/MMDVMHost.h index de22de2..17d6786 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -117,6 +117,7 @@ private: void remoteControl(); void processModeCommand(unsigned char mode, unsigned int timeout); + void processEnableCommand(bool& mode, bool enabled); void setMode(unsigned char mode); diff --git a/Modem.cpp b/Modem.cpp index 729dd59..784aa3e 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1491,6 +1491,11 @@ bool CModem::readStatus() return m_serial->write(buffer, 3U) == 3; } +bool CModem::writeConfig() +{ + return setConfig(); +} + bool CModem::setConfig() { assert(m_serial != NULL); diff --git a/Modem.h b/Modem.h index c12466f..0533fa1 100644 --- a/Modem.h +++ b/Modem.h @@ -75,6 +75,7 @@ public: virtual bool hasLockout() const; virtual bool hasError() const; + virtual bool writeConfig(); virtual bool writeDStarData(const unsigned char* data, unsigned int length); virtual bool writeDMRData1(const unsigned char* data, unsigned int length); virtual bool writeDMRData2(const unsigned char* data, unsigned int length); diff --git a/RemoteControl.cpp b/RemoteControl.cpp index afa1473..3a62213 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -25,6 +25,8 @@ #include const unsigned int SET_MODE_ARGS = 2U; +const unsigned int ENABLE_ARGS = 2U; +const unsigned int DISABLE_ARGS = 2U; const unsigned int PAGE_ARGS = 3U; const unsigned int BUFFER_LENGTH = 100U; @@ -86,6 +88,32 @@ REMOTE_COMMAND CRemoteControl::getCommand() m_command = RCD_MODE_P25; else if (m_args.at(1U) == "nxdn") m_command = RCD_MODE_NXDN; + } else if (m_args.at(0U) == "enable" && m_args.size() >= ENABLE_ARGS) { + if (m_args.at(1U) == "dstar") + m_command = RCD_ENABLE_DSTAR; + else if (m_args.at(1U) == "dmr") + m_command = RCD_ENABLE_DMR; + else if (m_args.at(1U) == "ysf") + m_command = RCD_ENABLE_YSF; + else if (m_args.at(1U) == "p25") + m_command = RCD_ENABLE_P25; + else if (m_args.at(1U) == "nxdn") + m_command = RCD_ENABLE_NXDN; + else if (m_args.at(1U) == "fm") + m_command = RCD_ENABLE_FM; + } else if (m_args.at(0U) == "disable" && m_args.size() >= DISABLE_ARGS) { + if (m_args.at(1U) == "dstar") + m_command = RCD_DISABLE_DSTAR; + else if (m_args.at(1U) == "dmr") + m_command = RCD_DISABLE_DMR; + else if (m_args.at(1U) == "ysf") + m_command = RCD_DISABLE_YSF; + else if (m_args.at(1U) == "p25") + m_command = RCD_DISABLE_P25; + else if (m_args.at(1U) == "nxdn") + m_command = RCD_DISABLE_NXDN; + else if (m_args.at(1U) == "fm") + m_command = RCD_DISABLE_FM; } else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) { // Page command is in the form of "page " m_command = RCD_PAGE; diff --git a/RemoteControl.h b/RemoteControl.h index 479987a..31d546d 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -33,6 +33,19 @@ enum REMOTE_COMMAND { RCD_MODE_YSF, RCD_MODE_P25, RCD_MODE_NXDN, + RCD_MODE_FM, + RCD_ENABLE_DSTAR, + RCD_ENABLE_DMR, + RCD_ENABLE_YSF, + RCD_ENABLE_P25, + RCD_ENABLE_NXDN, + RCD_ENABLE_FM, + RCD_DISABLE_DSTAR, + RCD_DISABLE_DMR, + RCD_DISABLE_YSF, + RCD_DISABLE_P25, + RCD_DISABLE_NXDN, + RCD_DISABLE_FM, RCD_PAGE }; From 7e145d288acae331e69b8aa4ced33acf7103c775 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 3 May 2020 18:33:22 +0100 Subject: [PATCH 35/50] Update HD44780.cpp The section at line 402 is mostly the same as the section at line 294, I suspect the new section should be setFMInt() instead.... --- HD44780.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HD44780.cpp b/HD44780.cpp index ebbfcac..32f15fb 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -399,7 +399,7 @@ void CHD44780::setQuitInt() m_dmr = false; } -void CHD44780::setIdleInt() +void CHD44780::setFMInt() { m_clockDisplayTimer.stop(); ::lcdClear(m_fd); From 1a142e36cb1dc794c1cacd2cf57f7f23e358ce08 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 4 May 2020 22:30:16 +0100 Subject: [PATCH 36/50] Host support for the CallsignAtLatch option. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 6 +++++- Modem.h | 3 ++- Version.h | 2 +- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index e204fa9..23f7596 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -182,6 +182,7 @@ m_fmCallsignHighLevel(35.0F), m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), +m_fmCallsignAtLatch(true), m_fmRFAck("K"), m_fmExtAck("N"), m_fmAckSpeed(20U), @@ -716,6 +717,8 @@ bool CConf::read() m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) m_fmCallsignAtEnd = ::atoi(value) == 1; + else if (::strcmp(key, "CallsignAtLatch") == 0) + m_fmCallsignAtLatch = ::atoi(value) == 1; else if (::strcmp(key, "RFAck") == 0) { // Convert the ack to upper case for (unsigned int i = 0U; value[i] != 0; i++) @@ -1545,6 +1548,11 @@ bool CConf::getFMCallsignAtEnd() const return m_fmCallsignAtEnd; } +bool CConf::getFMCallsignAtLatch() const +{ + return m_fmCallsignAtLatch; +} + std::string CConf::getFMRFAck() const { return m_fmRFAck; diff --git a/Conf.h b/Conf.h index 14678e1..0ba0955 100644 --- a/Conf.h +++ b/Conf.h @@ -180,6 +180,7 @@ public: float getFMCallsignLowLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; + bool getFMCallsignAtLatch() const; std::string getFMRFAck() const; std::string getFMExtAck() const; unsigned int getFMAckSpeed() const; @@ -445,6 +446,7 @@ private: float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; + bool m_fmCallsignAtLatch; std::string m_fmRFAck; std::string m_fmExtAck; unsigned int m_fmAckSpeed; diff --git a/MMDVM.ini b/MMDVM.ini index d504978..9faaecc 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -150,6 +150,7 @@ CallsignHighLevel=50 CallsignLowLevel=20 CallsignAtStart=1 CallsignAtEnd=1 +CallsignAtLatch=0 RFAck=K ExtAck=N AckSpeed=20 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b9449e0..961d9a2 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1215,6 +1215,7 @@ bool CMMDVMHost::createModem() float callsignLowLevel = m_conf.getFMCallsignLowLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); std::string rfAck = m_conf.getFMRFAck(); std::string extAck = m_conf.getFMExtAck(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); @@ -1244,6 +1245,7 @@ bool CMMDVMHost::createModem() LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); + LogInfo(" Callsign At Latch: %s", callsignAtLatch ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); // LogInfo(" Ext. Ack: %s", extAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); @@ -1263,7 +1265,7 @@ bool CMMDVMHost::createModem() LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); // LogInfo(" Ext. Audio Boost: x%u", extAudioBoost); - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDevLevel); } diff --git a/Modem.cpp b/Modem.cpp index 784aa3e..3041567 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -178,6 +178,7 @@ m_fmCallsignHighLevel(35.0F), m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), +m_fmCallsignAtLatch(true), m_fmRfAck("K"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), @@ -1887,7 +1888,7 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) +void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch) { m_fmCallsign = callsign; m_fmCallsignSpeed = callsignSpeed; @@ -1898,6 +1899,7 @@ void CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls m_fmCallsignLowLevel = callsignLowLevel; m_fmCallsignAtStart = callsignAtStart; m_fmCallsignAtEnd = callsignAtEnd; + m_fmCallsignAtLatch = callsignAtLatch; } void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) @@ -1951,6 +1953,8 @@ bool CModem::setFMCallsignParams() buffer[9U] |= 0x01U; if (m_fmCallsignAtEnd) buffer[9U] |= 0x02U; + if (m_fmCallsignAtLatch) + buffer[9U] |= 0x04U; for (unsigned int i = 0U; i < m_fmCallsign.size(); i++) buffer[10U + i] = m_fmCallsign.at(i); diff --git a/Modem.h b/Modem.h index 0533fa1..edb30ec 100644 --- a/Modem.h +++ b/Modem.h @@ -45,7 +45,7 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); + virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel); @@ -194,6 +194,7 @@ private: float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; + bool m_fmCallsignAtLatch; std::string m_fmRfAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; diff --git a/Version.h b/Version.h index 8e901ee..4b0d9cc 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200428"; +const char* VERSION = "20200504"; #endif From dd2f5fbe26fb03a5195a39ee103daf9870a9b0fe Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 5 May 2020 19:24:29 +0100 Subject: [PATCH 37/50] Update MMDVMHost.cpp --- MMDVMHost.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2134223..1e61600 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1986,6 +1986,17 @@ void CMMDVMHost::remoteControl() } m_pocsag->sendPage(ric, text); } + case RCD_CW: + if (!m_modem->hasTX()){ + std::string cwtext; + for (unsigned int i = 0U; i < m_remoteControl->getArgCount(); i++) { + if (i > 0U) + cwtext += " "; + cwtext += m_remoteControl->getArgString(i); + } + m_display->writeCW(); + m_modem->sendCWId(cwtext); + } default: break; } From 8b2b3d344a3890e37439ca35e8812fc540db74a7 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 5 May 2020 19:26:12 +0100 Subject: [PATCH 38/50] Update RemoteControl.cpp --- RemoteControl.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RemoteControl.cpp b/RemoteControl.cpp index afa1473..2aca7ff 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -26,6 +26,7 @@ const unsigned int SET_MODE_ARGS = 2U; const unsigned int PAGE_ARGS = 3U; +const unsigned int CW_ARGS = 2U; const unsigned int BUFFER_LENGTH = 100U; @@ -89,7 +90,10 @@ REMOTE_COMMAND CRemoteControl::getCommand() } else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) { // Page command is in the form of "page " m_command = RCD_PAGE; - } + } else if (m_args.at(0U) == "cw" && m_args.size() >= CW_ARGS) { + // CW command is in the form of "cw " + m_command = RCD_CW; + } if (m_command == RCD_NONE) { m_args.clear(); @@ -115,6 +119,8 @@ unsigned int CRemoteControl::getArgCount() const return m_args.size() - SET_MODE_ARGS; case RCD_PAGE: return m_args.size() - 1U; + case RCD_CW: + return m_args.size() - 1U; default: return 0U; } @@ -135,6 +141,9 @@ std::string CRemoteControl::getArgString(unsigned int n) const case RCD_PAGE: n += 1U; break; + case RCD_CW: + n += 1U; + break; default: return ""; } From d3f4b1f90c1614666081af1081f7afc972843258 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 5 May 2020 19:27:12 +0100 Subject: [PATCH 39/50] Update RemoteControl.h --- RemoteControl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RemoteControl.h b/RemoteControl.h index 479987a..c5be6ba 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -33,7 +33,8 @@ enum REMOTE_COMMAND { RCD_MODE_YSF, RCD_MODE_P25, RCD_MODE_NXDN, - RCD_PAGE + RCD_PAGE, + RCD_CW }; class CRemoteControl { From ff492a518fb979811070337453430de4ac45e231 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 5 May 2020 19:30:56 +0100 Subject: [PATCH 40/50] Update MMDVMHost.cpp --- MMDVMHost.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 1e61600..c7367ca 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1987,6 +1987,7 @@ void CMMDVMHost::remoteControl() m_pocsag->sendPage(ric, text); } case RCD_CW: + setMode(MODE_IDLE); // Force the modem to go idle so that we can send the CW text. if (!m_modem->hasTX()){ std::string cwtext; for (unsigned int i = 0U; i < m_remoteControl->getArgCount(); i++) { From 5410ca3ce8361789b93e7db14b6c34b24c25c83f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 6 May 2020 11:26:54 +0100 Subject: [PATCH 41/50] Add the COSInvert parameter. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 7 ++++++- Modem.h | 3 ++- Version.h | 2 +- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 23f7596..8c07bc6 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -198,6 +198,7 @@ m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_fmUseCOS(true), +m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F), m_fmExtAudioBoost(1U), @@ -755,6 +756,8 @@ bool CConf::read() m_fmHangTime = (unsigned int)::atoi(value); else if (::strcmp(key, "UseCOS") == 0) m_fmUseCOS = ::atoi(value) == 1; + else if (::strcmp(key, "COSInvert") == 0) + m_fmCOSInvert = ::atoi(value) == 1; else if (::strcmp(key, "RFAudioBoost") == 0) m_fmRFAudioBoost = (unsigned int)::atoi(value); else if (::strcmp(key, "MaxDevLevel") == 0) @@ -1628,6 +1631,11 @@ bool CConf::getFMUseCOS() const return m_fmUseCOS; } +bool CConf::getFMCOSInvert() const +{ + return m_fmCOSInvert; +} + unsigned int CConf::getFMRFAudioBoost() const { return m_fmRFAudioBoost; diff --git a/Conf.h b/Conf.h index 0ba0955..f5a40bd 100644 --- a/Conf.h +++ b/Conf.h @@ -196,6 +196,7 @@ public: unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; bool getFMUseCOS() const; + bool getFMCOSInvert() const; unsigned int getFMRFAudioBoost() const; float getFMMaxDevLevel() const; unsigned int getFMExtAudioBoost() const; @@ -462,6 +463,7 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; + bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; unsigned int m_fmExtAudioBoost; diff --git a/MMDVM.ini b/MMDVM.ini index 9faaecc..5e71a84 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -166,6 +166,7 @@ CTCSSLevel=20 KerchunkTime=0 HangTime=7 UseCOS=1 +COSInvert=0 RFAudioBoost=1 MaxDevLevel=90 ExtAudioBoost=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b3314be..e2a7766 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1231,6 +1231,7 @@ bool CMMDVMHost::createModem() unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); bool useCOS = m_conf.getFMUseCOS(); + bool cosInvert = m_conf.getFMCOSInvert(); unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); float maxDevLevel = m_conf.getFMMaxDevLevel(); unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); @@ -1261,13 +1262,14 @@ bool CMMDVMHost::createModem() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); + LogInfo(" COS Invert: %s", cosInvert ? "yes" : "no"); LogInfo(" RF Audio Boost: x%u", rfAudioBoost); LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); // LogInfo(" Ext. Audio Boost: x%u", extAudioBoost); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 3041567..edbebec 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -193,6 +193,7 @@ m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), m_fmUseCOS(true), +m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F) { @@ -1912,7 +1913,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1925,6 +1926,8 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmHangTime = hangTime; m_fmUseCOS = useCOS; + m_fmCOSInvert = cosInvert; + m_fmRFAudioBoost = rfAudioBoost; m_fmMaxDevLevel = maxDevLevel; } @@ -2065,6 +2068,8 @@ bool CModem::setFMMiscParams() buffer[10U] = 0x00U; if (m_fmUseCOS) buffer[10U] |= 0x01U; + if (m_fmCOSInvert) + buffer[10U] |= 0x02U; buffer[11U] = m_fmRFAudioBoost; diff --git a/Modem.h b/Modem.h index edb30ec..6404d89 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -209,6 +209,7 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; + bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; diff --git a/Version.h b/Version.h index 4b0d9cc..7bf2d5a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200504"; +const char* VERSION = "20200506"; #endif From d6b367b8b5095150b0068010e9e0b734eab30257 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 6 May 2020 17:10:23 +0100 Subject: [PATCH 42/50] Add the P25 and NXDN transmit hang timer settings. --- Conf.cpp | 16 ++++++++++++++++ Conf.h | 4 ++++ MMDVM.ini | 2 ++ MMDVMHost.cpp | 34 +++++++++++++++++++++------------- Modem.cpp | 24 ++++++++++++++++++++---- Modem.h | 4 ++++ Version.h | 2 +- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index e204fa9..0a9cf5a 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -163,12 +163,14 @@ m_p25NAC(0x293U), m_p25SelfOnly(false), m_p25OverrideUID(false), m_p25RemoteGateway(false), +m_p25TXHang(5U), m_p25ModeHang(10U), m_nxdnEnabled(false), m_nxdnId(0U), m_nxdnRAN(1U), m_nxdnSelfOnly(false), m_nxdnRemoteGateway(false), +m_nxdnTXHang(5U), m_nxdnModeHang(10U), m_pocsagEnabled(false), m_pocsagFrequency(0U), @@ -671,6 +673,8 @@ bool CConf::read() m_p25SelfOnly = ::atoi(value) == 1; else if (::strcmp(key, "RemoteGateway") == 0) m_p25RemoteGateway = ::atoi(value) == 1; + else if (::strcmp(key, "TXHang") == 0) + m_p25TXHang = (unsigned int)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_p25ModeHang = (unsigned int)::atoi(value); } else if (section == SECTION_NXDN) { @@ -684,6 +688,8 @@ bool CConf::read() m_nxdnSelfOnly = ::atoi(value) == 1; else if (::strcmp(key, "RemoteGateway") == 0) m_nxdnRemoteGateway = ::atoi(value) == 1; + else if (::strcmp(key, "TXHang") == 0) + m_nxdnTXHang = (unsigned int)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_nxdnModeHang = (unsigned int)::atoi(value); } else if (section == SECTION_POCSAG) { @@ -1450,6 +1456,11 @@ bool CConf::getP25RemoteGateway() const return m_p25RemoteGateway; } +unsigned int CConf::getP25TXHang() const +{ + return m_p25TXHang; +} + unsigned int CConf::getP25ModeHang() const { return m_p25ModeHang; @@ -1480,6 +1491,11 @@ bool CConf::getNXDNRemoteGateway() const return m_nxdnRemoteGateway; } +unsigned int CConf::getNXDNTXHang() const +{ + return m_nxdnTXHang; +} + unsigned int CConf::getNXDNModeHang() const { return m_nxdnModeHang; diff --git a/Conf.h b/Conf.h index 14678e1..66ff4fa 100644 --- a/Conf.h +++ b/Conf.h @@ -155,6 +155,7 @@ public: bool getP25SelfOnly() const; bool getP25OverrideUID() const; bool getP25RemoteGateway() const; + unsigned int getP25TXHang() const; unsigned int getP25ModeHang() const; // The NXDN section @@ -163,6 +164,7 @@ public: unsigned int getNXDNRAN() const; bool getNXDNSelfOnly() const; bool getNXDNRemoteGateway() const; + unsigned int getNXDNTXHang() const; unsigned int getNXDNModeHang() const; // The POCSAG section @@ -423,6 +425,7 @@ private: bool m_p25SelfOnly; bool m_p25OverrideUID; bool m_p25RemoteGateway; + unsigned int m_p25TXHang; unsigned int m_p25ModeHang; bool m_nxdnEnabled; @@ -430,6 +433,7 @@ private: unsigned int m_nxdnRAN; bool m_nxdnSelfOnly; bool m_nxdnRemoteGateway; + unsigned int m_nxdnTXHang; unsigned int m_nxdnModeHang; bool m_pocsagEnabled; diff --git a/MMDVM.ini b/MMDVM.ini index d504978..9774018 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -126,6 +126,7 @@ NAC=293 SelfOnly=0 OverrideUIDCheck=0 RemoteGateway=0 +TXHang=5 # ModeHang=10 [NXDN] @@ -133,6 +134,7 @@ Enable=1 RAN=1 SelfOnly=0 RemoteGateway=0 +TXHang=5 # ModeHang=10 [POCSAG] diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index c7367ca..b688692 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -547,12 +547,13 @@ int CMMDVMHost::run() } if (m_p25Enabled) { - unsigned int id = m_conf.getP25Id(); - unsigned int nac = m_conf.getP25NAC(); - bool uidOverride = m_conf.getP25OverrideUID(); - bool selfOnly = m_conf.getP25SelfOnly(); - bool remoteGateway = m_conf.getP25RemoteGateway(); - m_p25RFModeHang = m_conf.getP25ModeHang(); + unsigned int id = m_conf.getP25Id(); + unsigned int nac = m_conf.getP25NAC(); + unsigned int txHang = m_conf.getP25TXHang(); + bool uidOverride = m_conf.getP25OverrideUID(); + bool selfOnly = m_conf.getP25SelfOnly(); + bool remoteGateway = m_conf.getP25RemoteGateway(); + m_p25RFModeHang = m_conf.getP25ModeHang(); LogInfo("P25 RF Parameters"); LogInfo(" Id: %u", id); @@ -560,6 +561,7 @@ int CMMDVMHost::run() LogInfo(" UID Override: %s", uidOverride ? "yes" : "no"); LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no"); + LogInfo(" TX Hang: %us", txHang); LogInfo(" Mode Hang: %us", m_p25RFModeHang); m_p25 = new CP25Control(nac, id, selfOnly, uidOverride, m_p25Network, m_display, m_timeout, m_duplex, m_dmrLookup, remoteGateway, rssi); @@ -577,17 +579,19 @@ int CMMDVMHost::run() m_nxdnLookup = new CNXDNLookup(lookupFile, reloadTime); m_nxdnLookup->read(); - unsigned int id = m_conf.getNXDNId(); - unsigned int ran = m_conf.getNXDNRAN(); - bool selfOnly = m_conf.getNXDNSelfOnly(); - bool remoteGateway = m_conf.getNXDNRemoteGateway(); - m_nxdnRFModeHang = m_conf.getNXDNModeHang(); + unsigned int id = m_conf.getNXDNId(); + unsigned int ran = m_conf.getNXDNRAN(); + bool selfOnly = m_conf.getNXDNSelfOnly(); + bool remoteGateway = m_conf.getNXDNRemoteGateway(); + unsigned int txHang = m_conf.getNXDNTXHang(); + m_nxdnRFModeHang = m_conf.getNXDNModeHang(); LogInfo("NXDN RF Parameters"); LogInfo(" Id: %u", id); LogInfo(" RAN: %u", ran); LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no"); + LogInfo(" TX Hang: %us", txHang); LogInfo(" Mode Hang: %us", m_nxdnRFModeHang); m_nxdn = new CNXDNControl(ran, id, selfOnly, m_nxdnNetwork, m_display, m_timeout, m_duplex, remoteGateway, m_nxdnLookup, rssi); @@ -1161,7 +1165,9 @@ bool CMMDVMHost::createModem() bool debug = m_conf.getModemDebug(); unsigned int colorCode = m_conf.getDMRColorCode(); bool lowDeviation = m_conf.getFusionLowDeviation(); - unsigned int txHang = m_conf.getFusionTXHang(); + unsigned int ysfTXHang = m_conf.getFusionTXHang(); + unsigned int p25TXHang = m_conf.getP25TXHang(); + unsigned int nxdnTXHang = m_conf.getNXDNTXHang(); unsigned int rxFrequency = m_conf.getRXFrequency(); unsigned int txFrequency = m_conf.getTXFrequency(); unsigned int pocsagFrequency = m_conf.getPOCSAGFrequency(); @@ -1203,7 +1209,9 @@ bool CMMDVMHost::createModem() m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel); m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); m_modem->setDMRParams(colorCode); - m_modem->setYSFParams(lowDeviation, txHang); + m_modem->setYSFParams(lowDeviation, ysfTXHang); + m_modem->setP25Params(p25TXHang); + m_modem->setNXDNParams(nxdnTXHang); if (m_fmEnabled) { std::string callsign = m_conf.getFMCallsign(); diff --git a/Modem.cpp b/Modem.cpp index 729dd59..e6f1ebb 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -104,6 +104,8 @@ m_port(port), m_dmrColorCode(0U), m_ysfLoDev(false), m_ysfTXHang(4U), +m_p25TXHang(5U), +m_nxdnTXHang(5U), m_duplex(duplex), m_rxInvert(rxInvert), m_txInvert(txInvert), @@ -262,6 +264,16 @@ void CModem::setYSFParams(bool loDev, unsigned int txHang) m_ysfTXHang = txHang; } +void CModem::setP25Params(unsigned int txHang) +{ + m_p25TXHang = txHang; +} + +void CModem::setNXDNParams(unsigned int txHang) +{ + m_nxdnTXHang = txHang; +} + void CModem::setTransparentDataParams(unsigned int sendFrameType) { m_sendTransparentDataFrameType = sendFrameType; @@ -1499,7 +1511,7 @@ bool CModem::setConfig() buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 22U; + buffer[1U] = 24U; buffer[2U] = MMDVM_SET_CONFIG; @@ -1563,10 +1575,14 @@ bool CModem::setConfig() buffer[21U] = (unsigned char)(m_fmTXLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 22U); + buffer[22U] = (unsigned char)m_p25TXHang; - int ret = m_serial->write(buffer, 22U); - if (ret != 22) + buffer[23U] = (unsigned char)m_nxdnTXHang; + + // CUtils::dump(1U, "Written", buffer, 24U); + + int ret = m_serial->write(buffer, 24U); + if (ret != 24) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index c12466f..95314f3 100644 --- a/Modem.h +++ b/Modem.h @@ -43,6 +43,8 @@ public: virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel); virtual void setDMRParams(unsigned int colorCode); virtual void setYSFParams(bool loDev, unsigned int txHang); + virtual void setP25Params(unsigned int txHang); + virtual void setNXDNParams(unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); @@ -117,6 +119,8 @@ private: unsigned int m_dmrColorCode; bool m_ysfLoDev; unsigned int m_ysfTXHang; + unsigned int m_p25TXHang; + unsigned int m_nxdnTXHang; bool m_duplex; bool m_rxInvert; bool m_txInvert; diff --git a/Version.h b/Version.h index 8e901ee..7bf2d5a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200428"; +const char* VERSION = "20200506"; #endif From c3efabf56c5b664f6edd0ac7706f413bb8e5030d Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Sat, 9 May 2020 12:11:08 +0200 Subject: [PATCH 43/50] Redirect stderr messages to the log file, as in daemon mode assert() failure are silent and make wrong INI file hard to fix. --- Log.cpp | 20 +++++++++++++++++--- Log.h | 2 +- MMDVMHost.cpp | 3 +-- RemoteCommand.cpp | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Log.cpp b/Log.cpp index fc37ebf..f600b90 100644 --- a/Log.cpp +++ b/Log.cpp @@ -22,6 +22,7 @@ #include #else #include +#include #endif #include @@ -36,6 +37,7 @@ static std::string m_filePath; static std::string m_fileRoot; static FILE* m_fpLog = NULL; +static bool m_daemon = false; static unsigned int m_displayLevel = 2U; @@ -45,6 +47,8 @@ static char LEVELS[] = " DMIWEF"; static bool LogOpen() { + bool status = false; + if (m_fileLevel == 0U) return true; @@ -68,18 +72,28 @@ static bool LogOpen() ::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); #endif - m_fpLog = ::fopen(filename, "a+t"); + if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) + { + status = true; + +#if !defined(_WIN32) && !defined(_WIN64) + if (m_daemon) + dup2(fileno(m_fpLog), fileno(stderr)); +#endif + } + m_tm = *tm; - return m_fpLog != NULL; + return status; } -bool LogInitialise(const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel) +bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel) { m_filePath = filePath; m_fileRoot = fileRoot; m_fileLevel = fileLevel; m_displayLevel = displayLevel; + m_daemon = daemon; return ::LogOpen(); } diff --git a/Log.h b/Log.h index d671ef9..0d00653 100644 --- a/Log.h +++ b/Log.h @@ -30,7 +30,7 @@ extern void Log(unsigned int level, const char* fmt, ...); -extern bool LogInitialise(const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel); +extern bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel); extern void LogFinalise(); #endif diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index e2a7766..00619e8 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -237,7 +237,7 @@ int CMMDVMHost::run() #endif #endif - ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); + ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); return 1; @@ -247,7 +247,6 @@ int CMMDVMHost::run() if (m_daemon) { ::close(STDIN_FILENO); ::close(STDOUT_FILENO); - ::close(STDERR_FILENO); } #endif diff --git a/RemoteCommand.cpp b/RemoteCommand.cpp index bf3fb1e..fd96e46 100644 --- a/RemoteCommand.cpp +++ b/RemoteCommand.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) CRemoteCommand::CRemoteCommand(unsigned int port) : m_port(port) { - ::LogInitialise(".", "RemoteCommand", 2U, 2U); + ::LogInitialise(false, ".", "RemoteCommand", 2U, 2U); } CRemoteCommand::~CRemoteCommand() From 2ae966b7fbb1189ca9f40e75d018bff2b40ef5ba Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 9 May 2020 12:47:26 +0100 Subject: [PATCH 44/50] Fix for Windows compilation. --- MMDVMHost.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 00619e8..6b17c16 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -237,7 +237,11 @@ int CMMDVMHost::run() #endif #endif +#if !defined(_WIN32) && !defined(_WIN64) ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); +#else + ret = ::LogInitialise(false, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); +#endif if (!ret) { ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); return 1; From ce121c59da39884a9b89da105d1427b226806e6c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 12 May 2020 13:43:43 +0100 Subject: [PATCH 45/50] Add the low CTCSS threshold value. --- Conf.cpp | 18 +++++++++++---- Conf.h | 6 +++-- MMDVM.ini | 2 ++ MMDVMHost.cpp | 64 ++++++++++++++++++++++++++------------------------- Modem.cpp | 41 ++++++++++++++++++--------------- Modem.h | 5 ++-- Version.h | 2 +- 7 files changed, 79 insertions(+), 59 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 8c07bc6..fc0c4c0 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -193,7 +193,8 @@ m_fmAckLevel(80.0F), m_fmTimeout(180U), m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), -m_fmCTCSSThreshold(40U), +m_fmCTCSSHighThreshold(30U), +m_fmCTCSSLowThreshold(20U), m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), @@ -747,7 +748,11 @@ bool CConf::read() else if (::strcmp(key, "CTCSSFrequency") == 0) m_fmCTCSSFrequency = float(::atof(value)); else if (::strcmp(key, "CTCSSThreshold") == 0) - m_fmCTCSSThreshold = (unsigned int)::atoi(value); + m_fmCTCSSHighThreshold = m_fmCTCSSLowThreshold = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSHighThreshold") == 0) + m_fmCTCSSHighThreshold = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSLowThreshold") == 0) + m_fmCTCSSLowThreshold = (unsigned int)::atoi(value); else if (::strcmp(key, "CTCSSLevel") == 0) m_fmCTCSSLevel = float(::atof(value)); else if (::strcmp(key, "KerchunkTime") == 0) @@ -1606,9 +1611,14 @@ float CConf::getFMCTCSSFrequency() const return m_fmCTCSSFrequency; } -unsigned int CConf::getFMCTCSSThreshold() const +unsigned int CConf::getFMCTCSSHighThreshold() const { - return m_fmCTCSSThreshold; + return m_fmCTCSSHighThreshold; +} + +unsigned int CConf::getFMCTCSSLowThreshold() const +{ + return m_fmCTCSSLowThreshold; } float CConf::getFMCTCSSLevel() const diff --git a/Conf.h b/Conf.h index f5a40bd..51f7898 100644 --- a/Conf.h +++ b/Conf.h @@ -191,7 +191,8 @@ public: unsigned int getFMTimeout() const; float getFMTimeoutLevel() const; float getFMCTCSSFrequency() const; - unsigned int getFMCTCSSThreshold() const; + unsigned int getFMCTCSSHighThreshold() const; + unsigned int getFMCTCSSLowThreshold() const; float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; @@ -458,7 +459,8 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCTCSSFrequency; - unsigned int m_fmCTCSSThreshold; + unsigned int m_fmCTCSSHighThreshold; + unsigned int m_fmCTCSSLowThreshold; float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/MMDVM.ini b/MMDVM.ini index 5e71a84..8a89cd5 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -162,6 +162,8 @@ AckLevel=50 TimeoutLevel=80 CTCSSFrequency=88.4 CTCSSThreshold=30 +# CTCSSHighThreshold=30 +# CTCSSLowThreshold=20 CTCSSLevel=20 KerchunkTime=0 HangTime=7 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 6b17c16..1c32ad6 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1209,35 +1209,36 @@ bool CMMDVMHost::createModem() m_modem->setYSFParams(lowDeviation, txHang); if (m_fmEnabled) { - std::string callsign = m_conf.getFMCallsign(); - unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); - unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); - unsigned int callsignTime = m_conf.getFMCallsignTime(); - unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - float callsignHighLevel = m_conf.getFMCallsignHighLevel(); - float callsignLowLevel = m_conf.getFMCallsignLowLevel(); - bool callsignAtStart = m_conf.getFMCallsignAtStart(); - bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); - bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); - std::string rfAck = m_conf.getFMRFAck(); - std::string extAck = m_conf.getFMExtAck(); - unsigned int ackSpeed = m_conf.getFMAckSpeed(); - unsigned int ackFrequency = m_conf.getFMAckFrequency(); - unsigned int ackMinTime = m_conf.getFMAckMinTime(); - unsigned int ackDelay = m_conf.getFMAckDelay(); - float ackLevel = m_conf.getFMAckLevel(); - unsigned int timeout = m_conf.getFMTimeout(); - float timeoutLevel = m_conf.getFMTimeoutLevel(); - float ctcssFrequency = m_conf.getFMCTCSSFrequency(); - unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); - float ctcssLevel = m_conf.getFMCTCSSLevel(); - unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); - unsigned int hangTime = m_conf.getFMHangTime(); - bool useCOS = m_conf.getFMUseCOS(); - bool cosInvert = m_conf.getFMCOSInvert(); - unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); - float maxDevLevel = m_conf.getFMMaxDevLevel(); - unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); + std::string callsign = m_conf.getFMCallsign(); + unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); + unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); + unsigned int callsignTime = m_conf.getFMCallsignTime(); + unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); + float callsignHighLevel = m_conf.getFMCallsignHighLevel(); + float callsignLowLevel = m_conf.getFMCallsignLowLevel(); + bool callsignAtStart = m_conf.getFMCallsignAtStart(); + bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); + std::string rfAck = m_conf.getFMRFAck(); + std::string extAck = m_conf.getFMExtAck(); + unsigned int ackSpeed = m_conf.getFMAckSpeed(); + unsigned int ackFrequency = m_conf.getFMAckFrequency(); + unsigned int ackMinTime = m_conf.getFMAckMinTime(); + unsigned int ackDelay = m_conf.getFMAckDelay(); + float ackLevel = m_conf.getFMAckLevel(); + unsigned int timeout = m_conf.getFMTimeout(); + float timeoutLevel = m_conf.getFMTimeoutLevel(); + float ctcssFrequency = m_conf.getFMCTCSSFrequency(); + unsigned int ctcssHighThreshold = m_conf.getFMCTCSSHighThreshold(); + unsigned int ctcssLowThreshold = m_conf.getFMCTCSSLowThreshold(); + float ctcssLevel = m_conf.getFMCTCSSLevel(); + unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); + unsigned int hangTime = m_conf.getFMHangTime(); + bool useCOS = m_conf.getFMUseCOS(); + bool cosInvert = m_conf.getFMCOSInvert(); + unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); + float maxDevLevel = m_conf.getFMMaxDevLevel(); + unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1260,7 +1261,8 @@ bool CMMDVMHost::createModem() LogInfo(" Timeout: %us", timeout); LogInfo(" Timeout Level: %.1f%%", timeoutLevel); LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); - LogInfo(" CTCSS Threshold: %u", ctcssThreshold); + LogInfo(" CTCSS High Threshold: %u", ctcssHighThreshold); + LogInfo(" CTCSS Low Threshold: %u", ctcssLowThreshold); LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); @@ -1272,7 +1274,7 @@ bool CMMDVMHost::createModem() m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssHighThreshold, ctcssLowThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index edbebec..d913c6a 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -188,7 +188,8 @@ m_fmAckLevel(80.0F), m_fmTimeout(120U), m_fmTimeoutLevel(80.0F), m_fmCtcssFrequency(88.4F), -m_fmCtcssThreshold(25U), +m_fmCtcssHighThreshold(30U), +m_fmCtcssLowThreshold(20U), m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), @@ -1913,14 +1914,15 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; - m_fmCtcssFrequency = ctcssFrequency; - m_fmCtcssThreshold = ctcssThreshold; - m_fmCtcssLevel = ctcssLevel; + m_fmCtcssFrequency = ctcssFrequency; + m_fmCtcssHighThreshold = ctcssHighThreshold; + m_fmCtcssLowThreshold = ctcssLowThreshold; + m_fmCtcssLevel = ctcssLevel; m_fmKerchunkTime = kerchunkTime; m_fmHangTime = hangTime; @@ -2052,35 +2054,36 @@ bool CModem::setFMMiscParams() unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 14U; + buffer[1U] = 15U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = m_fmTimeout / 5U; buffer[4U] = (unsigned char)(m_fmTimeoutLevel * 2.55F + 0.5F); buffer[5U] = (unsigned char)m_fmCtcssFrequency; - buffer[6U] = m_fmCtcssThreshold; - buffer[7U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); + buffer[6U] = m_fmCtcssHighThreshold; + buffer[7U] = m_fmCtcssLowThreshold; + buffer[8U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); - buffer[8U] = m_fmKerchunkTime; - buffer[9U] = m_fmHangTime; + buffer[9U] = m_fmKerchunkTime; + buffer[10U] = m_fmHangTime; - buffer[10U] = 0x00U; + buffer[11U] = 0x00U; if (m_fmUseCOS) - buffer[10U] |= 0x01U; + buffer[11U] |= 0x01U; if (m_fmCOSInvert) - buffer[10U] |= 0x02U; + buffer[11U] |= 0x02U; - buffer[11U] = m_fmRFAudioBoost; + buffer[12U] = m_fmRFAudioBoost; - buffer[12U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); + buffer[13U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); - buffer[13U] = (unsigned char)(m_rxLevel * 2.55F + 0.5F); + buffer[14U] = (unsigned char)(m_rxLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 14U); + // CUtils::dump(1U, "Written", buffer, 15U); - int ret = m_serial->write(buffer, 14U); - if (ret != 14) + int ret = m_serial->write(buffer, 15U); + if (ret != 15) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 6404d89..495718f 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -204,7 +204,8 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCtcssFrequency; - unsigned int m_fmCtcssThreshold; + unsigned int m_fmCtcssHighThreshold; + unsigned int m_fmCtcssLowThreshold; float m_fmCtcssLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/Version.h b/Version.h index 7bf2d5a..c48a90e 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200506"; +const char* VERSION = "20200512"; #endif From b5658a6478c088ae507537599b4ada10779ef25d Mon Sep 17 00:00:00 2001 From: Alistair MacDonald Date: Thu, 14 May 2020 15:09:56 +0100 Subject: [PATCH 46/50] Quoted "Listening" for the lcdproc widget_set command Adding quotes increases comparability. Although optional for single words it is unusual not to have it quoted. Previously some here were quoted and some where not. --- LCDproc.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/LCDproc.cpp b/LCDproc.cpp index 96d9487..6e5d142 100644 --- a/LCDproc.cpp +++ b/LCDproc.cpp @@ -311,7 +311,7 @@ void CLCDproc::clearDStarInt() { m_clockDisplayTimer.stop(); // Stop the clock display - socketPrintf(m_socketfd, "widget_set DStar Line2 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set DStar Line2 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set DStar Line3 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set DStar Line4 1 4 15 4 h 3 \"\""); socketPrintf(m_socketfd, "output 8"); // Set LED4 color green @@ -404,7 +404,7 @@ void CLCDproc::clearDMRInt(unsigned int slotNo) socketPrintf(m_socketfd, "widget_set DMR Slot2RSSI %u %u %*.s", (m_cols / 2) + 1, 4, m_cols / 2, " "); } } else { - socketPrintf(m_socketfd, "widget_set DMR Slot1 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set DMR Slot1 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set DMR Slot2 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set DMR Slot2RSSI %u %u %*.s", (m_cols / 2) + 1, 4, m_cols / 2, " "); } @@ -452,7 +452,7 @@ void CLCDproc::clearFusionInt() { m_clockDisplayTimer.stop(); // Stop the clock display - socketPrintf(m_socketfd, "widget_set YSF Line2 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set YSF Line2 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set YSF Line3 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set YSF Line4 1 4 15 4 h 3 \"\""); socketPrintf(m_socketfd, "output 4"); // Set LED3 color green @@ -497,7 +497,7 @@ void CLCDproc::clearP25Int() { m_clockDisplayTimer.stop(); // Stop the clock display - socketPrintf(m_socketfd, "widget_set P25 Line2 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set P25 Line2 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set P25 Line3 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set P25 Line4 1 4 15 4 h 3 \"\""); socketPrintf(m_socketfd, "output 2"); // Set LED2 color green @@ -542,7 +542,7 @@ void CLCDproc::clearNXDNInt() { m_clockDisplayTimer.stop(); // Stop the clock display - socketPrintf(m_socketfd, "widget_set NXDN Line2 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set NXDN Line2 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set NXDN Line3 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set NXDN Line4 1 4 15 4 h 3 \"\""); socketPrintf(m_socketfd, "output 16"); // Set LED5 color green @@ -769,7 +769,7 @@ void CLCDproc::defineScreens() socketPrintf(m_socketfd, "widget_add DStar Line4 scroller"); /* Do we need to pre-populate the values?? - socketPrintf(m_socketfd, "widget_set DStar Line2 1 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set DStar Line2 1 2 15 2 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set DStar Line3 1 3 15 3 h 3 \"\""); socketPrintf(m_socketfd, "widget_set DStar Line4 1 4 15 4 h 3 \"\""); */ @@ -790,8 +790,8 @@ void CLCDproc::defineScreens() /* Do we need to pre-populate the values?? socketPrintf(m_socketfd, "widget_set DMR Slot1_ 1 %u 1", m_rows / 2); socketPrintf(m_socketfd, "widget_set DMR Slot2_ 1 %u 2", m_rows / 2 + 1); - socketPrintf(m_socketfd, "widget_set DMR Slot1 3 1 15 1 h 3 Listening"); - socketPrintf(m_socketfd, "widget_set DMR Slot2 3 2 15 2 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set DMR Slot1 3 1 15 1 h 3 \"Listening\""); + socketPrintf(m_socketfd, "widget_set DMR Slot2 3 2 15 2 h 3 \"Listening\""); */ // The YSF Screen @@ -805,7 +805,7 @@ void CLCDproc::defineScreens() socketPrintf(m_socketfd, "widget_add YSF Line4 scroller"); /* Do we need to pre-populate the values?? - socketPrintf(m_socketfd, "widget_set YSF Line2 2 1 15 1 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set YSF Line2 2 1 15 1 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set YSF Line3 3 1 15 1 h 3 \" \""); socketPrintf(m_socketfd, "widget_set YSF Line4 4 2 15 2 h 3 \" \""); */ @@ -821,7 +821,7 @@ void CLCDproc::defineScreens() socketPrintf(m_socketfd, "widget_add P25 Line4 scroller"); /* Do we need to pre-populate the values?? - socketPrintf(m_socketfd, "widget_set P25 Line3 2 1 15 1 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set P25 Line3 2 1 15 1 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set P25 Line3 3 1 15 1 h 3 \" \""); socketPrintf(m_socketfd, "widget_set P25 Line4 4 2 15 2 h 3 \" \""); */ @@ -837,7 +837,7 @@ void CLCDproc::defineScreens() socketPrintf(m_socketfd, "widget_add NXDN Line4 scroller"); /* Do we need to pre-populate the values?? - socketPrintf(m_socketfd, "widget_set NXDN Line3 2 1 15 1 h 3 Listening"); + socketPrintf(m_socketfd, "widget_set NXDN Line3 2 1 15 1 h 3 \"Listening\""); socketPrintf(m_socketfd, "widget_set NXDN Line3 3 1 15 1 h 3 \" \""); socketPrintf(m_socketfd, "widget_set NXDN Line4 4 2 15 2 h 3 \" \""); */ From 953530c23bd23838d3cf8342bff41e26f4937d57 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Mon, 18 May 2020 13:28:55 +0800 Subject: [PATCH 47/50] Update NullModem code to sycn with FM changes --- NullModem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NullModem.h b/NullModem.h index 2698f47..a7ec68f 100644 --- a/NullModem.h +++ b/NullModem.h @@ -32,8 +32,8 @@ public: virtual void setSerialParams(const std::string& protocol, unsigned int address){}; virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency){}; - virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled){}; - virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel){}; + virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled){}; + virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel){}; virtual void setDMRParams(unsigned int colorCode){}; virtual void setYSFParams(bool loDev, unsigned int txHang){}; virtual void setTransparentDataParams(unsigned int sendFrameType){}; From 4eb534aab6287013f2f8159ae02929a4fa29993e Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 18 May 2020 11:20:44 +0100 Subject: [PATCH 48/50] Remove extraneous logging message. --- MMDVMHost.cpp | 2 -- Version.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index f4967f3..40f954c 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1773,7 +1773,6 @@ void CMMDVMHost::setMode(unsigned char mode) break; case MODE_FM: - LogMessage("Mode set to FM"); if (m_dstarNetwork != NULL) m_dstarNetwork->enable(false); if (m_dmrNetwork != NULL) @@ -1812,7 +1811,6 @@ void CMMDVMHost::setMode(unsigned char mode) break; case MODE_LOCKOUT: - LogMessage("Mode set to Lockout"); if (m_dstarNetwork != NULL) m_dstarNetwork->enable(false); if (m_dmrNetwork != NULL) diff --git a/Version.h b/Version.h index c48a90e..19a3d8e 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200512"; +const char* VERSION = "20200518"; #endif From 0dbfe896bbe6f48cc5cf58bb347a7d4cffac7045 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 21 May 2020 11:17:02 +0100 Subject: [PATCH 49/50] Update README. --- README.md | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 953e4ce..813e945 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,21 @@ -These are the source files for building the MMDVMHost, the program that interfaces to the MMDVM or DVMega on the one side, and a suitable network on the other. It supports D-Star, DMR, P25 Phase 1, NXDN, System Fusion, and POCSAG paging on the MMDVM, and D-Star, DMR, and System Fusion on the DVMega. +These are the source files for building the MMDVMHost, the program that +interfaces to the MMDVM or DVMega on the one side, and a suitable network on +the other. It supports D-Star, DMR, P25 Phase 1, NXDN, System Fusion, +POCSAG, and FM on the MMDVM, and D-Star, DMR, and System Fusion on the DVMega. -On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it can connect to BrandMeister, DMR+, HB Link, XLX or [DMRGateway](https://github.com/g4klx/DMRGateway) (to connect to multiple DMR networks at once) on System Fusion it connects to the YSF Gateway to allow access to the FCS and YSF networks. On P25 it connects to the P25 Gateway. On NXDN it connects to the NXDN Gateway which provides access to the NXDN and NXCore talk groups. Finally it uses the DAPNET Gateway to access DAPNET to receive paging messages. +On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it +can connect to BrandMeister, DMR+, TGIF, HB Link, XLX or +[DMRGateway](https://github.com/g4klx/DMRGateway) (to connect to multiple DMR +networks at once) on System Fusion it connects to the YSF Gateway to allow +access to the FCS and YSF networks. On P25 it connects to the P25 Gateway. On +NXDN it connects to the NXDN Gateway which provides access to the NXDN and +NXCore talk groups. It uses the DAPNET Gateway to access DAPNET to receive +paging messages. Finally it uses the FM Gateway to interface to existing FM +networks. -It builds on 32-bit and 64-bit Linux as well as on Windows using Visual Studio 2017 on x86 and x64. It can optionally control various Displays. Currently these are: +It builds on 32-bit and 64-bit Linux as well as on Windows using Visual Studio +2019 on x86 and x64. It can optionally control various Displays. Currently +these are: - HD44780 (sizes 2x16, 2x40, 4x16, 4x20) - Support for HD44780 via 4 bit GPIO connection (user selectable pins) @@ -13,14 +26,23 @@ It builds on 32-bit and 64-bit Linux as well as on Windows using Visual Studio 2 - OLED 128x64 (SSD1306) - LCDproc -The Nextion displays can connect to the UART on the Raspberry Pi, or via a USB to TTL serial converter like the FT-232RL. It may also be connected to the UART output of the MMDVM modem (Arduino Due, STM32, Teensy), or to the UART output on the UMP. +The Nextion displays can connect to the UART on the Raspberry Pi, or via a USB +to TTL serial converter like the FT-232RL. It may also be connected to the UART +output of the MMDVM modem (Arduino Due, STM32, Teensy), or to the UART output +on the UMP. -The HD44780 displays are integrated with wiringPi for Raspberry Pi based platforms. +The HD44780 displays are integrated with wiringPi for Raspberry Pi based +platforms. -The Hobbytronics TFT Display, which is a Pi-Hat, connects to the UART on the Raspbery Pi. +The Hobbytronics TFT Display, which is a Pi-Hat, connects to the UART on the +Raspbery Pi. -The OLED display needs a extra library see OLED.md +The OLED display needs an extra library see OLED.md -The LCDproc support enables the use of a multitude of other LCD screens. See the [supported devices](http://lcdproc.omnipotent.net/hardware.php3) page on the LCDproc website for more info. +The LCDproc support enables the use of a multitude of other LCD screens. See +the [supported devices](http://lcdproc.omnipotent.net/hardware.php3) page on +the LCDproc website for more info. -This software is licenced under the GPL v2 and is intended for amateur and educational use only. Use of this software for commercial purposes is strictly forbidden. +This software is licenced under the GPL v2 and is intended for amateur and +educational use only. Use of this software for commercial purposes is strictly +forbidden. From 933b9ef01422e49d58dcac17c4d3a7e7021a5124 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 8 Jun 2020 14:34:29 +0100 Subject: [PATCH 50/50] Fix crash with POCSAG and no network. --- MMDVMHost.cpp | 3 ++- Version.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 40f954c..924d4a9 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -610,7 +610,8 @@ int CMMDVMHost::run() m_pocsag = new CPOCSAGControl(m_pocsagNetwork, m_display); - pocsagTimer.start(); + if (m_pocsagNetwork != NULL) + pocsagTimer.start(); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); diff --git a/Version.h b/Version.h index 19a3d8e..101ca94 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200518"; +const char* VERSION = "20200608"; #endif