Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
LOG_DISCONNECTS_ONCE
New configuration variable in svxlink.conf for remote transmitters and
receivers, LOG_DISCONNECTS_ONCE, that can be set to 1 to not log
reconnect attempts.  This may be of use if a RemoteTrx is missing for a
long time or if it's only used from time to time.
  • Loading branch information
sm0svx committed Oct 17, 2015
1 parent 202c057 commit 3fc46bf
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
14 changes: 14 additions & 0 deletions src/doc/man/svxlink.conf.5
Expand Up @@ -1452,6 +1452,13 @@ The hostname or IP address of the remote receiver host.
.B TCP_PORT
The TCP port that RemoteTrx listen on. The default is 5210.
.TP
.B LOG_DISCONNECTS_ONCE
Set this configuration variable to 1 to suppress logging of multiple disconnect
messages in a row, like when there is no RemoteTrx running on the other side.
Thus, failed reconnect attempts will not be logged at all. This may be of use
if a RemoteTrx is missing for a long time or if it's only used from time to
time. The default is 0 which means that all reconnect attempts will be logged.
.TP
.B AUTH_KEY
This is the authentication key (password) to use to connect to the RemoteTrx
server. The same key have to be specified in the RemoteTrx configuration.
Expand Down Expand Up @@ -1740,6 +1747,13 @@ The hostname or IP address of the remote transmitter host.
.B TCP_PORT
The TCP port that RemoteTrx listen on. The default is 5210.
.TP
.B LOG_DISCONNECTS_ONCE
Set this configuration variable to 1 to suppress logging of multiple disconnect
messages in a row, like when there is no RemoteTrx running on the other side.
Thus, failed reconnect attempts will not be logged at all. This may be of use
if a RemoteTrx is missing for a long time or if it's only used from time to
time. The default is 0 which means that all reconnect attempts will be logged.
.TP
.B AUTH_KEY
This is the authentication key (password) to use to connect to the RemoteTrx
server. The same key have to be specified in the RemoteTrx configuration.
Expand Down
5 changes: 5 additions & 0 deletions src/svxlink/ChangeLog
Expand Up @@ -88,6 +88,11 @@
configuration variable and let SvxLink determine what to use.
The old LIB_SUFFIX CMake variable is not used anymore.

* New configuration variable in svxlink.conf for remote transmitters and
receivers, LOG_DISCONNECTS_ONCE, that can be set to 1 to not log reconnect
attempts. This may be of use if a RemoteTrx is missing for a long time or if
it's only used from time to time.



1.4.2 -- 06 jun 2015
Expand Down
2 changes: 2 additions & 0 deletions src/svxlink/svxlink/svxlink.conf.in
Expand Up @@ -117,6 +117,7 @@ TRANSMITTERS=Tx1,Tx2,Tx3
TYPE=Net
HOST=remote.rx.host
TCP_PORT=5210
#LOG_DISCONNECTS_ONCE=0
AUTH_KEY="Change this key now!"
CODEC=S16
#SPEEX_ENC_FRAMES_PER_PACKET=4
Expand All @@ -136,6 +137,7 @@ CODEC=S16
TYPE=Net
HOST=remote.tx.host
TCP_PORT=5210
#LOG_DISCONNECTS_ONCE=0
AUTH_KEY="Change this key now!"
CODEC=S16
#SPEEX_ENC_FRAMES_PER_PACKET=4
Expand Down
18 changes: 14 additions & 4 deletions src/svxlink/trx/NetRx.cpp
Expand Up @@ -132,6 +132,7 @@ class ToneDet

NetRx::NetRx(Config &cfg, const string& name)
: Rx(cfg, name), cfg(cfg), mute_state(Rx::MUTE_ALL), tcp_con(0),
log_disconnects_once(false), log_disconnect(true),
last_signal_strength(0.0), last_sql_rx_id(0), unflushed_samples(false),
sql_is_open(false), audio_dec(0)
{
Expand Down Expand Up @@ -174,6 +175,8 @@ bool NetRx::initialize(void)

string udp_port(NET_TRX_DEFAULT_UDP_PORT);
cfg.getValue(name(), "UDP_PORT", udp_port);

cfg.getValue(name(), "LOG_DISCONNECTS_ONCE", log_disconnects_once);

string audio_dec_name;
cfg.getValue(name(), "CODEC", audio_dec_name);
Expand Down Expand Up @@ -336,6 +339,8 @@ void NetRx::connectionReady(bool is_ready)
cout << name() << ": Connected to remote receiver at "
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << "\n";

log_disconnect = true;

if (mute_state != Rx::MUTE_ALL)
{
MsgSetMuteState *msg = new MsgSetMuteState(mute_state);
Expand Down Expand Up @@ -371,10 +376,15 @@ void NetRx::connectionReady(bool is_ready)
}
else
{
cout << name() << ": Disconnected from remote receiver "
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << ": "
<< TcpConnection::disconnectReasonStr(tcp_con->disconnectReason())
<< "\n";
if (log_disconnect)
{
cout << name() << ": Disconnected from remote receiver "
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << ": "
<< TcpConnection::disconnectReasonStr(tcp_con->disconnectReason())
<< "\n";
}

log_disconnect = !log_disconnects_once;

sql_is_open = false;
if (unflushed_samples)
Expand Down
2 changes: 2 additions & 0 deletions src/svxlink/trx/NetRx.h
Expand Up @@ -195,6 +195,8 @@ class NetRx : public Rx
Async::Config &cfg;
Rx::MuteState mute_state;
NetTrxTcpClient *tcp_con;
bool log_disconnects_once;
bool log_disconnect;
float last_signal_strength;
int last_sql_rx_id;
std::list<ToneDet*> tone_detectors;
Expand Down
22 changes: 15 additions & 7 deletions src/svxlink/trx/NetTx.cpp
Expand Up @@ -119,9 +119,10 @@ using namespace NetTrxMsg;
****************************************************************************/

NetTx::NetTx(Config &cfg, const string& name)
: cfg(cfg), name(name), tcp_con(0), is_transmitting(false),
mode(Tx::TX_OFF), ctcss_enable(false), pacer(0), is_connected(false),
pending_flush(false), unflushed_samples(false), audio_enc(0)
: cfg(cfg), name(name), tcp_con(0), log_disconnects_once(false),
log_disconnect(true), is_transmitting(false), mode(Tx::TX_OFF),
ctcss_enable(false), pacer(0), is_connected(false), pending_flush(false),
unflushed_samples(false), audio_enc(0)
{
} /* NetTx::NetTx */

Expand Down Expand Up @@ -150,6 +151,8 @@ bool NetTx::initialize(void)
string udp_port(NET_TRX_DEFAULT_UDP_PORT);
cfg.getValue(name, "UDP_PORT", udp_port);

cfg.getValue(name, "LOG_DISCONNECTS_ONCE", log_disconnects_once);

string audio_enc_name;
cfg.getValue(name, "CODEC", audio_enc_name);
if (audio_enc_name.empty())
Expand Down Expand Up @@ -276,6 +279,7 @@ void NetTx::connectionReady(bool is_ready)
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << "\n";

is_connected = true;
log_disconnect = true;

MsgSetTxCtrlMode *mode_msg = new MsgSetTxCtrlMode(mode);
sendMsg(mode_msg);
Expand Down Expand Up @@ -303,12 +307,16 @@ void NetTx::connectionReady(bool is_ready)
}
else
{
cout << name << ": Disconnected from remote transmitter at "
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << ": "
<< TcpConnection::disconnectReasonStr(tcp_con->disconnectReason())
<< "\n";
if (log_disconnect)
{
cout << name << ": Disconnected from remote transmitter at "
<< tcp_con->remoteHost() << ":" << tcp_con->remotePort() << ": "
<< TcpConnection::disconnectReasonStr(tcp_con->disconnectReason())
<< "\n";
}

is_connected = false;
log_disconnect = !log_disconnects_once;

if (pending_flush)
{
Expand Down
2 changes: 2 additions & 0 deletions src/svxlink/trx/NetTx.h
Expand Up @@ -180,6 +180,8 @@ class NetTx : public Tx
Async::Config &cfg;
std::string name;
NetTrxTcpClient *tcp_con;
bool log_disconnects_once;
bool log_disconnect;
bool is_transmitting;
Tx::TxCtrlMode mode;
bool ctcss_enable;
Expand Down
2 changes: 1 addition & 1 deletion src/versions
Expand Up @@ -8,7 +8,7 @@ LIBECHOLIB=1.3.1.99.0
LIBASYNC=1.3.99.11

# SvxLink versions
SVXLINK=1.4.99.28
SVXLINK=1.4.99.29
MODULE_HELP=1.0.0
MODULE_PARROT=1.1.0.99.0
MODULE_ECHOLINK=1.3.1.99.1
Expand Down

0 comments on commit 3fc46bf

Please sign in to comment.