Merge branch 'master' into mqtt

This commit is contained in:
Jonathan Naylor
2024-02-09 15:58:11 +00:00
8 changed files with 59 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018,2020,2021,2024 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
@@ -72,6 +72,9 @@ m_beacon(false)
assert(id > 1000U);
assert(!password.empty());
if (CUDPSocket::lookup(m_address, m_port, m_addr, m_addrLen) != 0)
m_addrLen = 0U;
m_buffer = new unsigned char[BUFFER_LENGTH];
m_salt = new unsigned char[sizeof(uint32_t)];
m_id = new uint8_t[4U];
@@ -121,18 +124,18 @@ void CDMRDirectNetwork::setConfig(const std::string& callsign, unsigned int rxFr
bool CDMRDirectNetwork::open()
{
if (CUDPSocket::lookup(m_address, m_port, m_addr, m_addrLen) != 0) {
if (m_addrLen == 0U) {
LogError("DMR, Could not lookup the address of the DMR Network");
return false;
}
LogMessage("Opening DMR Network");
LogMessage("DMR, Opening DMR Network");
m_status = WAITING_CONNECT;
m_timeoutTimer.stop();
m_retryTimer.start();
return true;
return m_socket.open(m_addr);
}
void CDMRDirectNetwork::enable(bool enabled)
@@ -323,7 +326,7 @@ bool CDMRDirectNetwork::isConnected() const
void CDMRDirectNetwork::close(bool sayGoodbye)
{
LogMessage("Closing DMR Network");
LogMessage("DMR, Closing DMR Network");
if (sayGoodbye && (m_status == RUNNING)) {
unsigned char buffer[9U];
@@ -344,11 +347,8 @@ void CDMRDirectNetwork::clock(unsigned int ms)
if (m_retryTimer.isRunning() && m_retryTimer.hasExpired()) {
switch (m_status) {
case WAITING_CONNECT:
if (m_socket.open(m_addr)) {
if (writeLogin()) {
m_status = WAITING_LOGIN;
}
}
writeLogin();
m_status = WAITING_LOGIN;
break;
case WAITING_LOGIN:
writeLogin();

View File

@@ -105,7 +105,7 @@ void CDMRGatewayNetwork::setOptions(const std::string& options)
bool CDMRGatewayNetwork::open()
{
if (m_addrLen == 0U) {
LogError("Unable to resolve the address of the DMR Network");
LogError("DMR, Unable to resolve the address of the DMR Network");
return false;
}

View File

@@ -387,7 +387,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
// Regenerate NID
m_nid.encode(data + 2U, P25_DUID_LDU2);
// Add the dummy LDU2 data
// Add the LDU2 data
m_rfData.encodeLDU2(data + 2U);
// Regenerate the Low Speed Data
@@ -997,7 +997,7 @@ void CP25Control::createRFHeader()
// Add the NID
m_nid.encode(buffer + 2U, P25_DUID_HEADER);
// Add the dummy header
// Add the header
m_rfData.encodeHeader(buffer + 2U);
// Add busy bits, inbound busy
@@ -1032,18 +1032,18 @@ void CP25Control::createNetHeader()
unsigned int dstId = (m_netLDU1[76U] << 16) + (m_netLDU1[77U] << 8) + m_netLDU1[78U];
unsigned int srcId = (m_netLDU1[101U] << 16) + (m_netLDU1[102U] << 8) + m_netLDU1[103U];
unsigned char algId = m_netLDU2[126U];
unsigned int kId = (m_netLDU2[127U] << 8) + m_netLDU2[128U];
// unsigned char algId = m_netLDU2[126U];
// unsigned int kId = (m_netLDU2[127U] << 8) + m_netLDU2[128U];
unsigned char mi[P25_MI_LENGTH_BYTES];
::memcpy(mi + 0U, m_netLDU2 + 51U, 3U);
::memcpy(mi + 3U, m_netLDU2 + 76U, 3U);
::memcpy(mi + 6U, m_netLDU2 + 101U, 3U);
// unsigned char mi[P25_MI_LENGTH_BYTES];
// ::memcpy(mi + 0U, m_netLDU2 + 51U, 3U);
// ::memcpy(mi + 3U, m_netLDU2 + 76U, 3U);
// ::memcpy(mi + 6U, m_netLDU2 + 101U, 3U);
m_netData.reset();
m_netData.setMI(mi);
m_netData.setAlgId(algId);
m_netData.setKId(kId);
// m_netData.setMI(mi);
// m_netData.setAlgId(algId);
// m_netData.setKId(kId);
m_netData.setLCF(lcf);
m_netData.setMFId(mfId);
m_netData.setSrcId(srcId);
@@ -1072,7 +1072,7 @@ void CP25Control::createNetHeader()
// Add the NID
m_nid.encode(buffer + 2U, P25_DUID_HEADER);
// Add the dummy header
// Add the header
m_netData.encodeHeader(buffer + 2U);
// Add busy bits
@@ -1158,7 +1158,7 @@ void CP25Control::createNetLDU2()
// Add the NID
m_nid.encode(buffer + 2U, P25_DUID_LDU2);
// Add the dummy LDU2 data
// Add the LDU2 data
m_netData.encodeLDU2(buffer + 2U);
// Add the Audio

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com> N2PLL
*
* This program is free software; you can redistribute it and/or modify
@@ -38,7 +38,7 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
CP25Data::CP25Data() :
m_mi(NULL),
m_mfId(0U),
m_algId(0x80U),
m_algId(P25_ALGO_UNENCRYPT),
m_kId(0U),
m_lcf(0x00U),
m_emergency(false),
@@ -48,6 +48,7 @@ m_rs241213(),
m_trellis()
{
m_mi = new unsigned char[P25_MI_LENGTH_BYTES];
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES);
}
CP25Data::~CP25Data()
@@ -66,7 +67,7 @@ CP25Data& CP25Data::operator=(const CP25Data& data)
m_emergency = data.m_emergency;
m_algId = data.m_algId;
m_kId = data.m_kId;
m_kId = data.m_kId;
::memcpy(m_mi, data.m_mi, P25_MI_LENGTH_BYTES);
}
@@ -97,20 +98,19 @@ bool CP25Data::decodeHeader(const unsigned char* data)
}
m_mfId = rs[9U]; // Mfg Id.
/*
m_algId = rs[10U]; // Algorithm ID
if (m_algId != P25_ALGO_UNENCRYPT) {
m_mi = new unsigned char[P25_MI_LENGTH_BYTES];
::memcpy(m_mi, rs, P25_MI_LENGTH_BYTES); // Message Indicator
m_kId = (rs[11U] << 8) + rs[12U]; // Key ID
m_kId = (rs[11U] << 8) | (rs[12U] << 0); // Key ID
} else {
m_mi = new unsigned char[P25_MI_LENGTH_BYTES];
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES);
m_kId = 0x0000U;
}
*/
return true;
}
@@ -291,21 +291,20 @@ bool CP25Data::decodeLDU2(const unsigned char* data)
CUtils::dump(2U, "P25, RS crashed with input data", rs, 18U);
return false;
}
/*
m_algId = rs[9U]; // Algorithm ID
m_algId = rs[9U]; // Algorithm ID
if (m_algId != P25_ALGO_UNENCRYPT) {
m_mi = new unsigned char[P25_MI_LENGTH_BYTES];
::memcpy(m_mi, rs, P25_MI_LENGTH_BYTES); // Message Indicator
::memcpy(m_mi, rs, P25_MI_LENGTH_BYTES); // Message Indicator
m_kId = (rs[10U] << 8) + rs[11U]; // Key ID
m_kId = (rs[10U] << 8) + rs[11U]; // Key ID
}
else {
m_mi = new unsigned char[P25_MI_LENGTH_BYTES];
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES);
m_kId = 0x0000U;
}
*/
return true;
}
@@ -318,11 +317,11 @@ void CP25Data::encodeLDU2(unsigned char* data)
::memset(rs, 0x00U, 18U);
for (unsigned int i = 0; i < P25_MI_LENGTH_BYTES; i++)
rs[i] = m_mi[i]; // Message Indicator
rs[i] = m_mi[i]; // Message Indicator
rs[9U] = m_algId; // Algorithm ID
rs[10U] = (m_kId >> 8) & 0xFFU; // Key ID MSB
rs[11U] = (m_kId >> 0) & 0xFFU; // Key ID LSB
rs[9U] = m_algId; // Algorithm ID
rs[10U] = (m_kId >> 8) & 0xFFU; // Key ID MSB
rs[11U] = (m_kId >> 0) & 0xFFU; // Key ID LSB
// encode RS (24,16,9) FEC
m_rs241213.encode24169(rs);
@@ -370,7 +369,7 @@ bool CP25Data::decodeTSDU(const unsigned char* data)
return false;
}
m_lcf = tsbk[0U] & 0x3F;
m_lcf = tsbk[0U] & 0x3F;
m_mfId = tsbk[1U];
unsigned long long tsbkValue = 0U;
@@ -556,7 +555,7 @@ void CP25Data::reset()
{
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES);
m_algId = 0x80U;
m_algId = P25_ALGO_UNENCRYPT;
m_kId = 0x0000U;
m_lcf = P25_LCF_GROUP;
m_mfId = 0x00U;

View File

@@ -53,7 +53,7 @@ bool CPOCSAGNetwork::open()
LogMessage("Opening POCSAG network connection");
return m_socket.open();
return m_socket.open(m_addr);
}
void CPOCSAGNetwork::clock(unsigned int ms)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2019,2020,2021,2024 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
@@ -36,10 +36,15 @@ const unsigned int BUFFER_LENGTH = 100U;
CRemoteControl::CRemoteControl(CMMDVMHost *host, const std::string address, unsigned int port) :
m_host(host),
m_socket(address, port),
m_addr(),
m_addrLen(0U),
m_command(RCD_NONE),
m_args()
{
assert(port > 0U);
if (CUDPSocket::lookup(address, port, m_addr, m_addrLen) != 0)
m_addrLen = 0U;
}
CRemoteControl::~CRemoteControl()
@@ -48,7 +53,12 @@ CRemoteControl::~CRemoteControl()
bool CRemoteControl::open()
{
return m_socket.open();
if (m_addrLen == 0U) {
LogError("Unable to resolve the address of the remote control port");
return false;
}
return m_socket.open(m_addr);
}
REMOTE_COMMAND CRemoteControl::getCommand()

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2019,2020,2021,2024 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
@@ -83,6 +83,8 @@ public:
private:
CMMDVMHost* m_host;
CUDPSocket m_socket;
sockaddr_storage m_addr;
unsigned int m_addrLen;
REMOTE_COMMAND m_command;
std::vector<std::string> m_args;
};

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20240129";
const char* VERSION = "20240207";
#endif