Skip to content

Commit

Permalink
Allow DMR/P25 and NXDN Id reload with a SIGUSR1 or via a remote command.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 1, 2021
1 parent 4ec33c8 commit a209c00
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 25 deletions.
14 changes: 12 additions & 2 deletions DMRLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ CThread(),
m_filename(filename),
m_reloadTime(reloadTime),
m_table(),
m_stop(false)
m_stop(false),
m_reload(false)
{
}

Expand All @@ -48,6 +49,14 @@ bool CDMRLookup::read()
return ret;
}

void CDMRLookup::reload()
{
if (m_reloadTime == 0U)
m_table.load(m_filename);
else
m_reload = true;
}

void CDMRLookup::entry()
{
LogInfo("Started the DMR Id lookup reload thread");
Expand All @@ -59,9 +68,10 @@ void CDMRLookup::entry()
sleep(1000U);

timer.clock();
if (timer.hasExpired()) {
if (timer.hasExpired() || m_reload) {
m_table.load(m_filename);
timer.start();
m_reload = false;
}
}

Expand Down
5 changes: 4 additions & 1 deletion DMRLookup.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2021 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
Expand Down Expand Up @@ -31,6 +31,8 @@ class CDMRLookup : public CThread {

bool read();

void reload();

virtual void entry();

std::string find(unsigned int id);
Expand All @@ -45,6 +47,7 @@ class CDMRLookup : public CThread {
unsigned int m_reloadTime;
class CUserDB m_table;
bool m_stop;
bool m_reload;
};

#endif
52 changes: 37 additions & 15 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021 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
Expand Down Expand Up @@ -51,13 +51,19 @@ const char* DEFAULT_INI_FILE = "/etc/MMDVM.ini";

static bool m_killed = false;
static int m_signal = 0;
static bool m_reload = false;

#if !defined(_WIN32) && !defined(_WIN64)
static void sigHandler(int signum)
static void sigHandler1(int signum)
{
m_killed = true;
m_signal = signum;
}

static void sigHandler2(int signum)
{
m_reload = true;
}
#endif

const char* HEADER1 = "This software is for use on amateur radio networks only,";
Expand All @@ -84,9 +90,10 @@ int main(int argc, char** argv)
}

#if !defined(_WIN32) && !defined(_WIN64)
::signal(SIGINT, sigHandler);
::signal(SIGTERM, sigHandler);
::signal(SIGHUP, sigHandler);
::signal(SIGINT, sigHandler1);
::signal(SIGTERM, sigHandler1);
::signal(SIGHUP, sigHandler1);
::signal(SIGUSR1, sigHandler2);
#endif

int ret = 0;
Expand Down Expand Up @@ -982,6 +989,16 @@ int CMMDVMHost::run()
if (!m_fixedMode)
m_modeTimer.clock(ms);

if (m_reload) {
if (m_dmrLookup != NULL)
m_dmrLookup->reload();

if (m_nxdnLookup != NULL)
m_nxdnLookup->reload();

m_reload = false;
}

if (m_dstar != NULL)
m_dstar->clock();
if (m_dmr != NULL)
Expand Down Expand Up @@ -2074,18 +2091,23 @@ void CMMDVMHost::remoteControl()
}
m_pocsag->sendPage(ric, text);
}
break;
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++) {
if (i > 0U)
cwtext += " ";
cwtext += m_remoteControl->getArgString(i);
}
m_display->writeCW();
m_modem->sendCWId(cwtext);
}
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);
}
break;
case RCD_RELOAD:
m_reload = true;
break;
default:
break;
}
Expand Down
16 changes: 13 additions & 3 deletions NXDNLookup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2021 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
Expand Down Expand Up @@ -30,7 +30,8 @@ CThread(),
m_filename(filename),
m_reloadTime(reloadTime),
m_table(),
m_stop(false)
m_stop(false),
m_reload(false)
{
}

Expand All @@ -48,6 +49,14 @@ bool CNXDNLookup::read()
return ret;
}

void CNXDNLookup::reload()
{
if (m_reloadTime == 0U)
m_table.load(m_filename);
else
m_reload = true;
}

void CNXDNLookup::entry()
{
LogInfo("Started the NXDN Id lookup reload thread");
Expand All @@ -59,9 +68,10 @@ void CNXDNLookup::entry()
sleep(1000U);

timer.clock();
if (timer.hasExpired()) {
if (timer.hasExpired() || m_reload) {
m_table.load(m_filename);
timer.start();
m_reload = false;
}
}

Expand Down
3 changes: 3 additions & 0 deletions NXDNLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class CNXDNLookup : public CThread {

bool read();

void reload();

virtual void entry();

std::string find(unsigned int id);
Expand All @@ -45,6 +47,7 @@ class CNXDNLookup : public CThread {
unsigned int m_reloadTime;
class CUserDB m_table;
bool m_stop;
bool m_reload;
};

#endif
5 changes: 4 additions & 1 deletion RemoteControl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Jonathan Naylor G4KLX
* Copyright (C) 2019,2021 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
Expand Down Expand Up @@ -121,6 +121,9 @@ REMOTE_COMMAND CRemoteControl::getCommand()
} else if (m_args.at(0U) == "cw" && m_args.size() >= CW_ARGS) {
// CW command is in the form of "cw <message>"
m_command = RCD_CW;
} else if (m_args.at(0U) == "reload") {
// Reload command is in the form of "reload"
m_command = RCD_RELOAD;
}

if (m_command == RCD_NONE) {
Expand Down
5 changes: 3 additions & 2 deletions RemoteControl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 by Jonathan Naylor G4KLX
* Copyright (C) 2019,2021 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
Expand Down Expand Up @@ -47,7 +47,8 @@ enum REMOTE_COMMAND {
RCD_DISABLE_NXDN,
RCD_DISABLE_FM,
RCD_PAGE,
RCD_CW
RCD_CW,
RCD_RELOAD
};

class CRemoteControl {
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H

const char* VERSION = "20201215";
const char* VERSION = "20210101";

#endif

0 comments on commit a209c00

Please sign in to comment.