Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Simon 2016-06-10 09:58:31 +01:00
commit 139f62f57e
10 changed files with 81 additions and 61 deletions

View file

@ -111,8 +111,10 @@ m_dmrNetworkDebug(false),
m_dmrNetworkSlot1(true),
m_dmrNetworkSlot2(true),
m_fusionNetworkEnabled(false),
m_fusionNetworkAddress(),
m_fusionNetworkPort(0U),
m_fusionNetworkMyAddress(),
m_fusionNetworkMyPort(0U),
m_fusionNetworkGwyAddress(),
m_fusionNetworkGwyPort(0U),
m_fusionNetworkDebug(false),
m_tftSerialPort("/dev/ttyAMA0"),
m_tftSerialBrightness(50U),
@ -386,10 +388,14 @@ bool CConf::read()
} else if (section == SECTION_FUSION_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_fusionNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)
m_fusionNetworkAddress = value;
else if (::strcmp(key, "Port") == 0)
m_fusionNetworkPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_fusionNetworkMyAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_fusionNetworkMyPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "GwyAddress") == 0)
m_fusionNetworkGwyAddress = value;
else if (::strcmp(key, "GwyPort") == 0)
m_fusionNetworkGwyPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_fusionNetworkDebug = ::atoi(value) == 1;
} else if (section == SECTION_TFTSERIAL) {
@ -756,14 +762,24 @@ bool CConf::getFusionNetworkEnabled() const
return m_fusionNetworkEnabled;
}
std::string CConf::getFusionNetworkAddress() const
std::string CConf::getFusionNetworkMyAddress() const
{
return m_fusionNetworkAddress;
return m_fusionNetworkMyAddress;
}
unsigned int CConf::getFusionNetworkPort() const
unsigned int CConf::getFusionNetworkMyPort() const
{
return m_fusionNetworkPort;
return m_fusionNetworkMyPort;
}
std::string CConf::getFusionNetworkGwyAddress() const
{
return m_fusionNetworkGwyAddress;
}
unsigned int CConf::getFusionNetworkGwyPort() const
{
return m_fusionNetworkGwyPort;
}
bool CConf::getFusionNetworkDebug() const

12
Conf.h
View file

@ -114,8 +114,10 @@ public:
// The System Fusion Network section
bool getFusionNetworkEnabled() const;
std::string getFusionNetworkAddress() const;
unsigned int getFusionNetworkPort() const;
std::string getFusionNetworkMyAddress() const;
unsigned int getFusionNetworkMyPort() const;
std::string getFusionNetworkGwyAddress() const;
unsigned int getFusionNetworkGwyPort() const;
bool getFusionNetworkDebug() const;
// The TFTSERIAL section
@ -219,8 +221,10 @@ private:
bool m_dmrNetworkSlot2;
bool m_fusionNetworkEnabled;
std::string m_fusionNetworkAddress;
unsigned int m_fusionNetworkPort;
std::string m_fusionNetworkMyAddress;
unsigned int m_fusionNetworkMyPort;
std::string m_fusionNetworkGwyAddress;
unsigned int m_fusionNetworkGwyPort;
bool m_fusionNetworkDebug;
std::string m_tftSerialPort;

View file

@ -84,8 +84,10 @@ Debug=0
[System Fusion Network]
Enable=1
Address=c4fm.duckdns.org
Port=42000
LocalAddress=127.0.0.1
LocalPort=3200
GwyAddress=c4fm.duckdns.org
GwyPort=4200
Debug=0
[TFT Serial]

View file

@ -751,15 +751,19 @@ bool CMMDVMHost::createDMRNetwork()
bool CMMDVMHost::createYSFNetwork()
{
std::string address = m_conf.getFusionNetworkAddress();
unsigned int port = m_conf.getFusionNetworkPort();
bool debug = m_conf.getFusionNetworkDebug();
std::string myAddress = m_conf.getFusionNetworkMyAddress();
unsigned int myPort = m_conf.getFusionNetworkMyPort();
std::string gwyAddress = m_conf.getFusionNetworkGwyAddress();
unsigned int gwyPort = m_conf.getFusionNetworkGwyPort();
bool debug = m_conf.getFusionNetworkDebug();
LogInfo("System Fusion Network Parameters");
LogInfo(" Reflector Address: %s", address.c_str());
LogInfo(" Reflector Port: %u", port);
LogInfo(" Local Address: %s", myAddress.c_str());
LogInfo(" Local Port: %u", myPort);
LogInfo(" Gateway Address: %s", gwyAddress.c_str());
LogInfo(" Gateway Port: %u", gwyPort);
m_ysfNetwork = new CYSFNetwork(address, port, m_callsign, debug);
m_ysfNetwork = new CYSFNetwork(myAddress, myPort, gwyAddress, gwyPort, m_callsign, debug);
bool ret = m_ysfNetwork->open();
if (!ret) {

View file

@ -197,18 +197,10 @@ void CModem::clock(unsigned int ms)
LogError("No reply from the modem for some time, resetting it");
m_error = true;
close();
#if defined(_WIN32) || defined(_WIN64)
::Sleep(2000UL); // 2s
#else
::sleep(2UL); // 2s
#endif
while (!open()) {
#if defined(_WIN32) || defined(_WIN64)
::Sleep(5000UL); // 5s
#else
::sleep(5UL); // 5s
#endif
}
CThread::sleep(2000U); // 2s
while (!open())
CThread::sleep(5000U); // 5s
}
RESP_TYPE_MMDVM type = getResponse();
@ -376,6 +368,10 @@ void CModem::clock(unsigned int ms)
m_lockout = (m_buffer[5U] & 0x10U) == 0x10U;
bool dacOverflow = (m_buffer[5U] & 0x20U) == 0x20U;
if (dacOverflow)
LogError("MMDVM DAC levels have overflowed");
m_dstarSpace = m_buffer[6U];
m_dmrSpace1 = m_buffer[7U];
m_dmrSpace2 = m_buffer[8U];
@ -698,11 +694,7 @@ bool CModem::writeYSFData(const unsigned char* data, unsigned int length)
bool CModem::readVersion()
{
#if defined(_WIN32) || defined(_WIN64)
::Sleep(2000UL); // 2s
#else
::sleep(2); // 2s
#endif
CThread::sleep(2000U); // 2s
for (unsigned int i = 0U; i < 6U; i++) {
unsigned char buffer[3U];

View file

@ -362,6 +362,8 @@ void CYSFControl::writeNetwork()
m_networkWatchdog.start();
bool gateway = ::memcmp(data + 4U, "GATEWAY ", YSF_CALLSIGN_LENGTH) == 0;
if (!m_netTimeoutTimer.isRunning()) {
if (::memcmp(data + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
::memcpy(m_netSource, data + 14U, YSF_CALLSIGN_LENGTH);
@ -403,7 +405,7 @@ void CYSFControl::writeNetwork()
m_netFrames++;
bool end = data[34U] == 0x01U;
bool end = (data[34U] & 0x01U) == 0x01U;
data[33U] = end ? TAG_EOT : TAG_DATA;
data[34U] = 0x00U;
@ -426,19 +428,19 @@ void CYSFControl::writeNetwork()
case YSF_FI_COMMUNICATIONS:
switch (dt) {
case YSF_DT_VD_MODE1:
m_netPayload.processVDMode1Data(data + 35U, fn);
m_netPayload.processVDMode1Data(data + 35U, fn, gateway);
m_netErrs += m_netPayload.processVDMode1Audio(data + 35U);
m_netBits += 235U;
break;
case YSF_DT_VD_MODE2:
m_netPayload.processVDMode2Data(data + 35U, fn);
m_netPayload.processVDMode2Data(data + 35U, fn, gateway);
m_netErrs += m_netPayload.processVDMode2Audio(data + 35U);
m_netBits += 135U;
break;
case YSF_DT_DATA_FR_MODE:
m_netPayload.processDataFRModeData(data + 35U, fn);
m_netPayload.processDataFRModeData(data + 35U, fn, gateway);
break;
case YSF_DT_VOICE_FR_MODE:

View file

@ -28,10 +28,10 @@
const unsigned int BUFFER_LENGTH = 200U;
CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) :
m_socket(),
CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gwyAddress, unsigned int gwyPort, const std::string& callsign, bool debug) :
m_socket(myAddress, myPort),
m_address(),
m_port(port),
m_port(gwyPort),
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(address);
m_address = CUDPSocket::lookup(gwyAddress);
m_tag = new unsigned char[YSF_CALLSIGN_LENGTH];
::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH);
@ -160,7 +160,7 @@ void CYSFNetwork::clock(unsigned int ms)
return;
}
bool end = buffer[34U] == 0x01U;
bool end = (buffer[34U] & 0x01U) == 0x01U;
if (end)
::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH);

View file

@ -29,7 +29,7 @@
class CYSFNetwork {
public:
CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug);
CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gwyAddress, unsigned int gwyPort, const std::string& callsign, bool debug);
~CYSFNetwork();
bool open();

View file

@ -268,7 +268,7 @@ unsigned int CYSFPayload::processVDMode1Audio(unsigned char* data)
return errors;
}
bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn)
bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool gateway)
{
assert(data != NULL);
@ -319,10 +319,10 @@ bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn)
break;
case 1U:
if (m_downlink != NULL)
if (m_downlink != NULL && !gateway)
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
if (m_uplink != NULL)
if (m_uplink != NULL && !gateway)
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
break;
@ -450,7 +450,7 @@ unsigned int CYSFPayload::processVDMode2Audio(unsigned char* data)
return errors;
}
bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn)
bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn, bool gateway)
{
assert(data != NULL);
@ -502,12 +502,12 @@ bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn)
break;
case 2U:
if (m_downlink != NULL)
if (m_downlink != NULL && !gateway)
::memcpy(output, m_downlink, YSF_CALLSIGN_LENGTH);
break;
case 3U:
if (m_uplink != NULL)
if (m_uplink != NULL && !gateway)
::memcpy(output, m_uplink, YSF_CALLSIGN_LENGTH);
break;
@ -560,7 +560,7 @@ bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn)
return ret && (fn == 0U || fn == 1U);
}
bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn)
bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, bool gateway)
{
assert(data != NULL);
@ -708,10 +708,10 @@ bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn)
case 0U:
CUtils::dump(1U, "FR Mode Data, CSD2", output, 20U);
if (m_downlink != NULL)
if (m_downlink != NULL && !gateway)
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
if (m_uplink != NULL)
if (m_uplink != NULL && !gateway)
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
break;

View file

@ -30,13 +30,13 @@ public:
bool processHeaderData(unsigned char* bytes);
bool processVDMode1Data(unsigned char* bytes, unsigned char fn);
bool processVDMode1Data(unsigned char* bytes, unsigned char fn, bool gateway = false);
unsigned int processVDMode1Audio(unsigned char* bytes);
bool processVDMode2Data(unsigned char* bytes, unsigned char fn);
bool processVDMode2Data(unsigned char* bytes, unsigned char fn, bool gateway = false);
unsigned int processVDMode2Audio(unsigned char* bytes);
bool processDataFRModeData(unsigned char* bytes, unsigned char fn);
bool processDataFRModeData(unsigned char* bytes, unsigned char fn, bool gateway = false);
unsigned int processVoiceFRModeAudio(unsigned char* bytes);