Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DSTAR radio mode for use with DSTAR2PCM #647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ m_umpPort(),
m_dstarEnabled(false),
m_dstarModule("C"),
m_dstarSelfOnly(false),
m_dstarRadioMode(false),
m_dstarBlackList(),
m_dstarAckReply(true),
m_dstarAckTime(750U),
Expand Down Expand Up @@ -555,6 +556,8 @@ bool CConf::read()
m_dstarModule = value;
} else if (::strcmp(key, "SelfOnly") == 0)
m_dstarSelfOnly = ::atoi(value) == 1;
else if (::strcmp(key, "RadioMode") == 0)
m_dstarRadioMode = ::atoi(value) == 1;
else if (::strcmp(key, "BlackList") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
Expand Down Expand Up @@ -1289,6 +1292,11 @@ bool CConf::getDStarSelfOnly() const
return m_dstarSelfOnly;
}

bool CConf::getDStarRadioMode() const
{
return m_dstarRadioMode;
}

std::vector<std::string> CConf::getDStarBlackList() const
{
return m_dstarBlackList;
Expand Down
2 changes: 2 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class CConf
bool getDStarEnabled() const;
std::string getDStarModule() const;
bool getDStarSelfOnly() const;
bool getDStarRadioMode() const;
std::vector<std::string> getDStarBlackList() const;
bool getDStarAckReply() const;
unsigned int getDStarAckTime() const;
Expand Down Expand Up @@ -387,6 +388,7 @@ class CConf
bool m_dstarEnabled;
std::string m_dstarModule;
bool m_dstarSelfOnly;
bool m_dstarRadioMode;
std::vector<std::string> m_dstarBlackList;
bool m_dstarAckReply;
unsigned int m_dstarAckTime;
Expand Down
24 changes: 18 additions & 6 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)

// #define DUMP_DSTAR

CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool dstarRadioMode, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL),
m_gateway(NULL),
m_selfOnly(selfOnly),
m_dstarRadioMode(dstarRadioMode),
m_ackReply(ackReply),
m_ackMessage(ackMessage),
m_errorReply(errorReply),
Expand Down Expand Up @@ -214,8 +215,8 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
header.getMyCall1(my1);

// Is this a transmission destined for a repeater?
if (!header.isRepeater()) {
// Is this a transmission destined for a repeater? If we are in radio mode we want it anyway
if (!header.isRepeater() && !m_dstarRadioMode) {
LogMessage("D-Star, non repeater RF header received from %8.8s", my1);
m_rfState = RS_RF_INVALID;
return false;
Expand All @@ -224,8 +225,8 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
unsigned char callsign[DSTAR_LONG_CALLSIGN_LENGTH];
header.getRPTCall1(callsign);

// Is it for us?
if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) {
// Is it for us? If we are in radio mode, then its all for us!
if ((::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) && !m_dstarRadioMode) {
LogMessage("D-Star, received RF header for wrong repeater (%8.8s) from %8.8s", callsign, my1);
m_rfState = RS_RF_INVALID;
return false;
Expand All @@ -252,7 +253,13 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
header.getYourCall(your);

m_net = ::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0;
if((::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0) || m_dstarRadioMode){
m_net = true;
}
else{
m_net = false;
}
//m_net = ::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0;

// Only start the timeout if not already running
if (!m_rfTimeoutTimer.isRunning())
Expand Down Expand Up @@ -675,6 +682,11 @@ void CDStarControl::writeNetwork()
m_netBits = 1U;
m_netErrs = 0U;

if (m_dstarRadioMode) {
header.setRepeater(true);
header.get(data + 1U);
}

if (m_remoteGateway) {
header.setRepeater(true);
header.setRPTCall1(m_callsign);
Expand Down
3 changes: 2 additions & 1 deletion DStarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class CDStarControl {
public:
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool dstarRadioMode, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
~CDStarControl();

bool writeModem(unsigned char* data, unsigned int len);
Expand All @@ -54,6 +54,7 @@ class CDStarControl {
unsigned char* m_callsign;
unsigned char* m_gateway;
bool m_selfOnly;
bool m_dstarRadioMode;
bool m_ackReply;
bool m_ackMessage;
bool m_errorReply;
Expand Down
1 change: 1 addition & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Port=/dev/ttyACM1
Enable=1
Module=C
SelfOnly=0
RadioMode=0
AckReply=1
AckTime=750
AckMessage=0
Expand Down
3 changes: 2 additions & 1 deletion MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ int CMMDVMHost::run()
if (m_dstarEnabled) {
std::string module = m_conf.getDStarModule();
bool selfOnly = m_conf.getDStarSelfOnly();
bool dstarRadioMode = m_conf.getDStarRadioMode();
std::vector<std::string> blackList = m_conf.getDStarBlackList();
bool ackReply = m_conf.getDStarAckReply();
unsigned int ackTime = m_conf.getDStarAckTime();
Expand All @@ -430,7 +431,7 @@ int CMMDVMHost::run()
if (blackList.size() > 0U)
LogInfo(" Black List: %u", blackList.size());

m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
m_dstar = new CDStarControl(m_callsign, module, selfOnly, dstarRadioMode, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
}

DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;
Expand Down