mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-23 00:35:53 +08:00
Merge branch 'YSFRefactor'
This commit is contained in:
8
Conf.cpp
8
Conf.cpp
@@ -122,6 +122,7 @@ m_dmrTXHang(4U),
|
|||||||
m_fusionEnabled(false),
|
m_fusionEnabled(false),
|
||||||
m_fusionLowDeviation(false),
|
m_fusionLowDeviation(false),
|
||||||
m_fusionRemoteGateway(false),
|
m_fusionRemoteGateway(false),
|
||||||
|
m_fusionSelfOnly(false),
|
||||||
m_fusionSQLEnabled(false),
|
m_fusionSQLEnabled(false),
|
||||||
m_fusionSQL(0U),
|
m_fusionSQL(0U),
|
||||||
m_p25Enabled(false),
|
m_p25Enabled(false),
|
||||||
@@ -460,6 +461,8 @@ bool CConf::read()
|
|||||||
m_fusionSQL = (unsigned int)::atoi(value);
|
m_fusionSQL = (unsigned int)::atoi(value);
|
||||||
} else if (::strcmp(key, "RemoteGateway") == 0)
|
} else if (::strcmp(key, "RemoteGateway") == 0)
|
||||||
m_fusionRemoteGateway = ::atoi(value) == 1;
|
m_fusionRemoteGateway = ::atoi(value) == 1;
|
||||||
|
else if (::strcmp(key, "SelfOnly") == 0)
|
||||||
|
m_fusionSelfOnly = ::atoi(value) == 1;
|
||||||
} else if (section == SECTION_P25) {
|
} else if (section == SECTION_P25) {
|
||||||
if (::strcmp(key, "Enable") == 0)
|
if (::strcmp(key, "Enable") == 0)
|
||||||
m_p25Enabled = ::atoi(value) == 1;
|
m_p25Enabled = ::atoi(value) == 1;
|
||||||
@@ -938,6 +941,11 @@ bool CConf::getFusionRemoteGateway() const
|
|||||||
return m_fusionRemoteGateway;
|
return m_fusionRemoteGateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CConf::getFusionSelfOnly() const
|
||||||
|
{
|
||||||
|
return m_fusionSelfOnly;
|
||||||
|
}
|
||||||
|
|
||||||
bool CConf::getFusionSQLEnabled() const
|
bool CConf::getFusionSQLEnabled() const
|
||||||
{
|
{
|
||||||
return m_fusionSQLEnabled;
|
return m_fusionSQLEnabled;
|
||||||
|
|||||||
2
Conf.h
2
Conf.h
@@ -117,6 +117,7 @@ public:
|
|||||||
bool getFusionEnabled() const;
|
bool getFusionEnabled() const;
|
||||||
bool getFusionLowDeviation() const;
|
bool getFusionLowDeviation() const;
|
||||||
bool getFusionRemoteGateway() const;
|
bool getFusionRemoteGateway() const;
|
||||||
|
bool getFusionSelfOnly() const;
|
||||||
bool getFusionSQLEnabled() const;
|
bool getFusionSQLEnabled() const;
|
||||||
unsigned char getFusionSQL() const;
|
unsigned char getFusionSQL() const;
|
||||||
|
|
||||||
@@ -276,6 +277,7 @@ private:
|
|||||||
bool m_fusionEnabled;
|
bool m_fusionEnabled;
|
||||||
bool m_fusionLowDeviation;
|
bool m_fusionLowDeviation;
|
||||||
bool m_fusionRemoteGateway;
|
bool m_fusionRemoteGateway;
|
||||||
|
bool m_fusionSelfOnly;
|
||||||
bool m_fusionSQLEnabled;
|
bool m_fusionSQLEnabled;
|
||||||
unsigned char m_fusionSQL;
|
unsigned char m_fusionSQL;
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ TXHang=4
|
|||||||
[System Fusion]
|
[System Fusion]
|
||||||
Enable=1
|
Enable=1
|
||||||
LowDeviation=0
|
LowDeviation=0
|
||||||
|
SelfOnly=0
|
||||||
#DSQ=1
|
#DSQ=1
|
||||||
RemoteGateway=0
|
RemoteGateway=0
|
||||||
|
|
||||||
|
|||||||
@@ -408,17 +408,19 @@ int CMMDVMHost::run()
|
|||||||
if (m_ysfEnabled) {
|
if (m_ysfEnabled) {
|
||||||
bool lowDeviation = m_conf.getFusionLowDeviation();
|
bool lowDeviation = m_conf.getFusionLowDeviation();
|
||||||
bool remoteGateway = m_conf.getFusionRemoteGateway();
|
bool remoteGateway = m_conf.getFusionRemoteGateway();
|
||||||
|
bool selfOnly = m_conf.getFusionSelfOnly();
|
||||||
bool sqlEnabled = m_conf.getFusionSQLEnabled();
|
bool sqlEnabled = m_conf.getFusionSQLEnabled();
|
||||||
unsigned char sql = m_conf.getFusionSQL();
|
unsigned char sql = m_conf.getFusionSQL();
|
||||||
|
|
||||||
LogInfo("YSF Parameters");
|
LogInfo("YSF Parameters");
|
||||||
LogInfo(" Low Deviation: %s", lowDeviation ? "yes" : "no");
|
LogInfo(" Low Deviation: %s", lowDeviation ? "yes" : "no");
|
||||||
LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no");
|
LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no");
|
||||||
|
LogInfo(" Self Only: %s", selfOnly ? "yes" : "no");
|
||||||
LogInfo(" DSQ: %s", sqlEnabled ? "yes" : "no");
|
LogInfo(" DSQ: %s", sqlEnabled ? "yes" : "no");
|
||||||
if (sqlEnabled)
|
if (sqlEnabled)
|
||||||
LogInfo(" DSQ Value: %u", sql);
|
LogInfo(" DSQ Value: %u", sql);
|
||||||
|
|
||||||
ysf = new CYSFControl(m_callsign, m_ysfNetwork, m_display, m_timeout, m_duplex, lowDeviation, remoteGateway, rssi);
|
ysf = new CYSFControl(m_callsign, selfOnly, m_ysfNetwork, m_display, m_timeout, m_duplex, lowDeviation, remoteGateway, rssi);
|
||||||
ysf->setSQL(sqlEnabled, sql);
|
ysf->setSQL(sqlEnabled, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
858
YSFControl.cpp
858
YSFControl.cpp
File diff suppressed because it is too large
Load Diff
19
YSFControl.h
19
YSFControl.h
@@ -25,6 +25,7 @@
|
|||||||
#include "YSFPayload.h"
|
#include "YSFPayload.h"
|
||||||
#include "RingBuffer.h"
|
#include "RingBuffer.h"
|
||||||
#include "StopWatch.h"
|
#include "StopWatch.h"
|
||||||
|
#include "YSFFICH.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
|
|
||||||
class CYSFControl {
|
class CYSFControl {
|
||||||
public:
|
public:
|
||||||
CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper);
|
CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper);
|
||||||
~CYSFControl();
|
~CYSFControl();
|
||||||
|
|
||||||
void setSQL(bool on, unsigned char value);
|
void setSQL(bool on, unsigned char value);
|
||||||
@@ -47,6 +48,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char* m_callsign;
|
unsigned char* m_callsign;
|
||||||
|
unsigned char* m_selfCallsign;
|
||||||
|
bool m_selfOnly;
|
||||||
CYSFNetwork* m_network;
|
CYSFNetwork* m_network;
|
||||||
CDisplay* m_display;
|
CDisplay* m_display;
|
||||||
bool m_duplex;
|
bool m_duplex;
|
||||||
@@ -73,12 +76,7 @@ private:
|
|||||||
unsigned char* m_rfDest;
|
unsigned char* m_rfDest;
|
||||||
unsigned char* m_netSource;
|
unsigned char* m_netSource;
|
||||||
unsigned char* m_netDest;
|
unsigned char* m_netDest;
|
||||||
unsigned char* m_lastFrame;
|
CYSFFICH m_lastFICH;
|
||||||
bool m_lastFrameValid;
|
|
||||||
bool m_lastSQL;
|
|
||||||
unsigned char m_lastSQ;
|
|
||||||
unsigned char m_lastMode;
|
|
||||||
unsigned char m_lastMR;
|
|
||||||
unsigned char m_netN;
|
unsigned char m_netN;
|
||||||
CYSFPayload m_rfPayload;
|
CYSFPayload m_rfPayload;
|
||||||
CYSFPayload m_netPayload;
|
CYSFPayload m_netPayload;
|
||||||
@@ -90,6 +88,10 @@ private:
|
|||||||
unsigned int m_rssiCount;
|
unsigned int m_rssiCount;
|
||||||
FILE* m_fp;
|
FILE* m_fp;
|
||||||
|
|
||||||
|
bool processVWData(bool valid, unsigned char *data);
|
||||||
|
bool processDNData(bool valid, unsigned char *data);
|
||||||
|
bool processFRData(bool valid, unsigned char *data);
|
||||||
|
|
||||||
void writeQueueRF(const unsigned char* data);
|
void writeQueueRF(const unsigned char* data);
|
||||||
void writeQueueNet(const unsigned char* data);
|
void writeQueueNet(const unsigned char* data);
|
||||||
void writeNetwork(const unsigned char* data, unsigned int count);
|
void writeNetwork(const unsigned char* data, unsigned int count);
|
||||||
@@ -102,8 +104,7 @@ private:
|
|||||||
bool writeFile(const unsigned char* data);
|
bool writeFile(const unsigned char* data);
|
||||||
void closeFile();
|
void closeFile();
|
||||||
|
|
||||||
bool insertSilence(const unsigned char* data, unsigned char n);
|
bool checkCallsign(const unsigned char* callsign) const;
|
||||||
void insertSilence(unsigned int count);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
36
YSFFICH.cpp
36
YSFFICH.cpp
@@ -54,10 +54,20 @@ const unsigned int INTERLEAVE_TABLE[] = {
|
|||||||
36U, 76U, 116U, 156U, 196U,
|
36U, 76U, 116U, 156U, 196U,
|
||||||
38U, 78U, 118U, 158U, 198U};
|
38U, 78U, 118U, 158U, 198U};
|
||||||
|
|
||||||
|
CYSFFICH::CYSFFICH(const CYSFFICH& fich) :
|
||||||
|
m_fich(NULL)
|
||||||
|
{
|
||||||
|
m_fich = new unsigned char[6U];
|
||||||
|
|
||||||
|
::memcpy(m_fich, fich.m_fich, 6U);
|
||||||
|
}
|
||||||
|
|
||||||
CYSFFICH::CYSFFICH() :
|
CYSFFICH::CYSFFICH() :
|
||||||
m_fich(NULL)
|
m_fich(NULL)
|
||||||
{
|
{
|
||||||
m_fich = new unsigned char[6U];
|
m_fich = new unsigned char[6U];
|
||||||
|
|
||||||
|
memset(m_fich, 0x00U, 6U);
|
||||||
}
|
}
|
||||||
|
|
||||||
CYSFFICH::~CYSFFICH()
|
CYSFFICH::~CYSFFICH()
|
||||||
@@ -214,6 +224,24 @@ unsigned char CYSFFICH::getSQ() const
|
|||||||
return m_fich[3U] & 0x7FU;
|
return m_fich[3U] & 0x7FU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setFI(unsigned char fi)
|
||||||
|
{
|
||||||
|
m_fich[0U] &= 0x3FU;
|
||||||
|
m_fich[0U] |= (fi << 6) & 0xC0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setFN(unsigned char fn)
|
||||||
|
{
|
||||||
|
m_fich[1U] &= 0xC7U;
|
||||||
|
m_fich[1U] |= (fn << 3) & 0x38U;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setFT(unsigned char ft)
|
||||||
|
{
|
||||||
|
m_fich[1U] &= 0xF8U;
|
||||||
|
m_fich[1U] |= ft & 0x07U;
|
||||||
|
}
|
||||||
|
|
||||||
void CYSFFICH::setMR(unsigned char mr)
|
void CYSFFICH::setMR(unsigned char mr)
|
||||||
{
|
{
|
||||||
m_fich[2U] &= 0xC7U;
|
m_fich[2U] &= 0xC7U;
|
||||||
@@ -249,3 +277,11 @@ void CYSFFICH::setSQ(unsigned char sq)
|
|||||||
m_fich[3U] &= 0x80U;
|
m_fich[3U] &= 0x80U;
|
||||||
m_fich[3U] |= sq & 0x7FU;
|
m_fich[3U] |= sq & 0x7FU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CYSFFICH& CYSFFICH::operator=(const CYSFFICH& fich)
|
||||||
|
{
|
||||||
|
if (&fich != this)
|
||||||
|
::memcpy(m_fich, fich.m_fich, 6U);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
class CYSFFICH {
|
class CYSFFICH {
|
||||||
public:
|
public:
|
||||||
|
CYSFFICH(const CYSFFICH& fich);
|
||||||
CYSFFICH();
|
CYSFFICH();
|
||||||
~CYSFFICH();
|
~CYSFFICH();
|
||||||
|
|
||||||
@@ -40,12 +41,17 @@ public:
|
|||||||
bool getSQL() const;
|
bool getSQL() const;
|
||||||
unsigned char getSQ() const;
|
unsigned char getSQ() const;
|
||||||
|
|
||||||
|
void setFI(unsigned char fi);
|
||||||
|
void setFN(unsigned char fn);
|
||||||
|
void setFT(unsigned char ft);
|
||||||
void setMR(unsigned char mr);
|
void setMR(unsigned char mr);
|
||||||
void setVoIP(bool set);
|
void setVoIP(bool set);
|
||||||
void setDev(bool set);
|
void setDev(bool set);
|
||||||
void setSQL(bool set);
|
void setSQL(bool set);
|
||||||
void setSQ(unsigned char sq);
|
void setSQ(unsigned char sq);
|
||||||
|
|
||||||
|
CYSFFICH& operator=(const CYSFFICH& fich);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char* m_fich;
|
unsigned char* m_fich;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -816,6 +816,105 @@ unsigned int CYSFPayload::processVoiceFRModeAudio(unsigned char* data)
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFPayload::writeHeader(unsigned char* data, const unsigned char* csd1, const unsigned char* csd2)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
assert(csd1 != NULL);
|
||||||
|
assert(csd2 != NULL);
|
||||||
|
|
||||||
|
writeDataFRModeData1(csd1, data);
|
||||||
|
|
||||||
|
writeDataFRModeData2(csd2, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* data)
|
||||||
|
{
|
||||||
|
assert(dt != NULL);
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
|
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
|
||||||
|
|
||||||
|
unsigned char output[25U];
|
||||||
|
for (unsigned int i = 0U; i < 20U; i++)
|
||||||
|
output[i] = dt[i] ^ WHITENING_DATA[i];
|
||||||
|
|
||||||
|
CCRC::addCCITT162(output, 22U);
|
||||||
|
output[22U] = 0x00U;
|
||||||
|
|
||||||
|
unsigned char convolved[45U];
|
||||||
|
|
||||||
|
CYSFConvolution conv;
|
||||||
|
conv.encode(output, convolved, 180U);
|
||||||
|
|
||||||
|
unsigned char bytes[45U];
|
||||||
|
unsigned int j = 0U;
|
||||||
|
for (unsigned int i = 0U; i < 180U; i++) {
|
||||||
|
unsigned int n = INTERLEAVE_TABLE_9_20[i];
|
||||||
|
|
||||||
|
bool s0 = READ_BIT1(convolved, j) != 0U;
|
||||||
|
j++;
|
||||||
|
|
||||||
|
bool s1 = READ_BIT1(convolved, j) != 0U;
|
||||||
|
j++;
|
||||||
|
|
||||||
|
WRITE_BIT1(bytes, n, s0);
|
||||||
|
|
||||||
|
n++;
|
||||||
|
WRITE_BIT1(bytes, n, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* p1 = data;
|
||||||
|
unsigned char* p2 = bytes;
|
||||||
|
for (unsigned int i = 0U; i < 5U; i++) {
|
||||||
|
::memcpy(p1, p2, 9U);
|
||||||
|
p1 += 18U; p2 += 9U;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data)
|
||||||
|
{
|
||||||
|
assert(dt != NULL);
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
|
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
|
||||||
|
|
||||||
|
unsigned char output[25U];
|
||||||
|
for (unsigned int i = 0U; i < 20U; i++)
|
||||||
|
output[i] = dt[i] ^ WHITENING_DATA[i];
|
||||||
|
|
||||||
|
CCRC::addCCITT162(output, 22U);
|
||||||
|
output[22U] = 0x00U;
|
||||||
|
|
||||||
|
unsigned char convolved[45U];
|
||||||
|
|
||||||
|
CYSFConvolution conv;
|
||||||
|
conv.encode(output, convolved, 180U);
|
||||||
|
|
||||||
|
unsigned char bytes[45U];
|
||||||
|
unsigned int j = 0U;
|
||||||
|
for (unsigned int i = 0U; i < 180U; i++) {
|
||||||
|
unsigned int n = INTERLEAVE_TABLE_9_20[i];
|
||||||
|
|
||||||
|
bool s0 = READ_BIT1(convolved, j) != 0U;
|
||||||
|
j++;
|
||||||
|
|
||||||
|
bool s1 = READ_BIT1(convolved, j) != 0U;
|
||||||
|
j++;
|
||||||
|
|
||||||
|
WRITE_BIT1(bytes, n, s0);
|
||||||
|
|
||||||
|
n++;
|
||||||
|
WRITE_BIT1(bytes, n, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* p1 = data + 9U;
|
||||||
|
unsigned char* p2 = bytes;
|
||||||
|
for (unsigned int i = 0U; i < 5U; i++) {
|
||||||
|
::memcpy(p1, p2, 9U);
|
||||||
|
p1 += 18U; p2 += 9U;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CYSFPayload::setUplink(const std::string& callsign)
|
void CYSFPayload::setUplink(const std::string& callsign)
|
||||||
{
|
{
|
||||||
m_uplink = new unsigned char[YSF_CALLSIGN_LENGTH];
|
m_uplink = new unsigned char[YSF_CALLSIGN_LENGTH];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -40,6 +40,11 @@ public:
|
|||||||
|
|
||||||
unsigned int processVoiceFRModeAudio(unsigned char* bytes);
|
unsigned int processVoiceFRModeAudio(unsigned char* bytes);
|
||||||
|
|
||||||
|
void writeHeader(unsigned char* data, const unsigned char* csd1, const unsigned char* csd2);
|
||||||
|
|
||||||
|
void writeDataFRModeData1(const unsigned char* dt, unsigned char* data);
|
||||||
|
void writeDataFRModeData2(const unsigned char* dt, unsigned char* data);
|
||||||
|
|
||||||
unsigned char* getSource();
|
unsigned char* getSource();
|
||||||
unsigned char* getDest();
|
unsigned char* getDest();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user