mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 15:09:23 +08:00
Add the IAX configuration options.
This commit is contained in:
26
Conf.cpp
26
Conf.cpp
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2023 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015-2024 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
|
||||
@@ -290,6 +290,9 @@ m_pocsagNetworkModeHang(3U),
|
||||
m_pocsagNetworkDebug(false),
|
||||
m_fmNetworkEnabled(false),
|
||||
m_fmNetworkProtocol("USRP"),
|
||||
m_fmNetworkUsername("Dave"),
|
||||
m_fmNetworkPassword("PASSWORD"),
|
||||
m_fmNetworkNode("Node1"),
|
||||
m_fmNetworkSampleRate(48000U),
|
||||
m_fmNetworkSquelchFile(),
|
||||
m_fmGatewayAddress(),
|
||||
@@ -1036,6 +1039,12 @@ bool CConf::read()
|
||||
m_fmNetworkEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Protocol") == 0)
|
||||
m_fmNetworkProtocol = value;
|
||||
else if (::strcmp(key, "Username") == 0)
|
||||
m_fmNetworkUsername = value;
|
||||
else if (::strcmp(key, "Password") == 0)
|
||||
m_fmNetworkPassword = value;
|
||||
else if (::strcmp(key, "Node") == 0)
|
||||
m_fmNetworkNode = value;
|
||||
else if (::strcmp(key, "SampleRate") == 0)
|
||||
m_fmNetworkSampleRate = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "SquelchFile") == 0)
|
||||
@@ -2282,6 +2291,21 @@ std::string CConf::getFMNetworkProtocol() const
|
||||
return m_fmNetworkProtocol;
|
||||
}
|
||||
|
||||
std::string CConf::getFMNetworkUsername() const
|
||||
{
|
||||
return m_fmNetworkUsername;
|
||||
}
|
||||
|
||||
std::string CConf::getFMNetworkPassword() const
|
||||
{
|
||||
return m_fmNetworkPassword;
|
||||
}
|
||||
|
||||
std::string CConf::getFMNetworkNode() const
|
||||
{
|
||||
return m_fmNetworkNode;
|
||||
}
|
||||
|
||||
unsigned int CConf::getFMNetworkSampleRate() const
|
||||
{
|
||||
return m_fmNetworkSampleRate;
|
||||
|
||||
8
Conf.h
8
Conf.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2023 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015-2024 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
|
||||
@@ -303,6 +303,9 @@ public:
|
||||
// The FM Network section
|
||||
bool getFMNetworkEnabled() const;
|
||||
std::string getFMNetworkProtocol() const;
|
||||
std::string getFMNetworkUsername() const;
|
||||
std::string getFMNetworkPassword() const;
|
||||
std::string getFMNetworkNode() const;
|
||||
unsigned int getFMNetworkSampleRate() const;
|
||||
std::string getFMNetworkSquelchFile() const;
|
||||
std::string getFMGatewayAddress() const;
|
||||
@@ -623,6 +626,9 @@ private:
|
||||
|
||||
bool m_fmNetworkEnabled;
|
||||
std::string m_fmNetworkProtocol;
|
||||
std::string m_fmNetworkUsername;
|
||||
std::string m_fmNetworkPassword;
|
||||
std::string m_fmNetworkNode;
|
||||
unsigned int m_fmNetworkSampleRate;
|
||||
std::string m_fmNetworkSquelchFile;
|
||||
std::string m_fmGatewayAddress;
|
||||
|
||||
@@ -97,11 +97,11 @@ const unsigned char IAX_IE_RR_OOO = 51U;
|
||||
|
||||
const unsigned int BUFFER_LENGTH = 1500U;
|
||||
|
||||
CFMIAXNetwork::CFMIAXNetwork(const std::string& callsign, const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) :
|
||||
CFMIAXNetwork::CFMIAXNetwork(const std::string& callsign, const std::string& username, const std::string& password, const std::string& node, const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) :
|
||||
m_callsign(callsign),
|
||||
m_username(),
|
||||
m_password(),
|
||||
m_node(),
|
||||
m_username(username),
|
||||
m_password(password),
|
||||
m_node(node),
|
||||
m_socket(localAddress, localPort),
|
||||
m_addr(),
|
||||
m_addrLen(0U),
|
||||
@@ -121,6 +121,9 @@ m_rxDropped(0U),
|
||||
m_rxOOO(0U)
|
||||
{
|
||||
assert(!callsign.empty());
|
||||
assert(!username.empty());
|
||||
assert(!password.empty());
|
||||
assert(!node.empty());
|
||||
assert(gatewayPort > 0U);
|
||||
assert(!gatewayAddress.empty());
|
||||
|
||||
@@ -153,17 +156,19 @@ bool CFMIAXNetwork::writeData(const float* data, unsigned int nSamples)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(nSamples > 0U);
|
||||
|
||||
if (m_seqNo == 0U) {
|
||||
/*
|
||||
if (m_iSeqNo == 0U) {
|
||||
bool ret = writeStart();
|
||||
if (!ret)
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFMIAXNetwork::writeEnd()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFMIAXNetwork::clock(unsigned int ms)
|
||||
@@ -529,6 +534,8 @@ bool CFMIAXNetwork::writeAck(unsigned short sCallNo, unsigned short dCallNo, uns
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FM IAX Network Data Sent", buffer, 12U);
|
||||
|
||||
m_oSeqNo++;
|
||||
|
||||
return m_socket.write(buffer, 12U, m_addr, m_addrLen);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
class CFMIAXNetwork : public IFMNetwork {
|
||||
public:
|
||||
CFMIAXNetwork(const std::string& callsign, const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug);
|
||||
CFMIAXNetwork(const std::string& callsign, const std::string& username, const std::string& password, const std::string& node, const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug);
|
||||
virtual ~CFMIAXNetwork();
|
||||
|
||||
virtual bool open();
|
||||
|
||||
12
MMDVM.ini
12
MMDVM.ini
@@ -289,10 +289,6 @@ Debug=0
|
||||
Enable=1
|
||||
# Protocol may be USRP, RAW, or IAX
|
||||
Protocol=USRP
|
||||
# SampleRate is only used in RAW mode
|
||||
SampleRate=48000
|
||||
# The squelch file is optional and only used in RAW mode
|
||||
SquelchFile=/tmp/sql
|
||||
LocalAddress=127.0.0.1
|
||||
LocalPort=3810
|
||||
GatewayAddress=127.0.0.1
|
||||
@@ -303,6 +299,14 @@ TXAudioGain=1.0
|
||||
RXAudioGain=1.0
|
||||
# ModeHang=3
|
||||
Debug=0
|
||||
# SampleRate and SquelchFile are RAW mode only options
|
||||
SampleRate=48000
|
||||
# The squelch file is optional
|
||||
SquelchFile=/tmp/sql
|
||||
# Username, Password, and Node are IAX only options
|
||||
Username=Dave
|
||||
Password=PASSWORD
|
||||
Node=Node1
|
||||
|
||||
[AX.25 Network]
|
||||
Enable=1
|
||||
|
||||
@@ -1888,6 +1888,9 @@ bool CMMDVMHost::createPOCSAGNetwork()
|
||||
bool CMMDVMHost::createFMNetwork()
|
||||
{
|
||||
std::string callsign = m_conf.getFMCallsign();
|
||||
std::string username = m_conf.getFMNetworkUsername();
|
||||
std::string password = m_conf.getFMNetworkPassword();
|
||||
std::string node = m_conf.getFMNetworkNode();
|
||||
std::string protocol = m_conf.getFMNetworkProtocol();
|
||||
unsigned int sampleRate = m_conf.getFMNetworkSampleRate();
|
||||
std::string squelchFile = m_conf.getFMNetworkSquelchFile();
|
||||
@@ -1904,10 +1907,6 @@ bool CMMDVMHost::createFMNetwork()
|
||||
|
||||
LogInfo("FM Network Parameters");
|
||||
LogInfo(" Protocol: %s", protocol.c_str());
|
||||
if (protocol == "RAW") {
|
||||
LogInfo(" Sample Rate: %u", sampleRate);
|
||||
LogInfo(" Squelch File: %s", squelchFile.empty() ? "(none)" : squelchFile.c_str());
|
||||
}
|
||||
LogInfo(" Gateway Address: %s", gatewayAddress.c_str());
|
||||
LogInfo(" Gateway Port: %hu", gatewayPort);
|
||||
LogInfo(" Local Address: %s", localAddress.c_str());
|
||||
@@ -1918,12 +1917,22 @@ bool CMMDVMHost::createFMNetwork()
|
||||
LogInfo(" RX Audio Gain: %.2f", rxAudioGain);
|
||||
LogInfo(" Mode Hang: %us", m_fmNetModeHang);
|
||||
|
||||
if (protocol == "RAW") {
|
||||
LogInfo(" Sample Rate: %u", sampleRate);
|
||||
LogInfo(" Squelch File: %s", squelchFile.empty() ? "(none)" : squelchFile.c_str());
|
||||
}
|
||||
|
||||
if (protocol == "IAX") {
|
||||
LogInfo(" Username: %s", username.c_str());
|
||||
LogInfo(" Node: %s", node.c_str());
|
||||
}
|
||||
|
||||
if (protocol == "USRP") {
|
||||
m_fmNetwork = new CFMUSRPNetwork(callsign, localAddress, localPort, gatewayAddress, gatewayPort, debug);
|
||||
} else if (protocol == "RAW") {
|
||||
m_fmNetwork = new CFMRAWNetwork(localAddress, localPort, gatewayAddress, gatewayPort, sampleRate, squelchFile, debug);
|
||||
} else if (protocol == "IAX") {
|
||||
m_fmNetwork = new CFMIAXNetwork(callsign, localAddress, localPort, gatewayAddress, gatewayPort, debug);
|
||||
m_fmNetwork = new CFMIAXNetwork(callsign, username, password, node, localAddress, localPort, gatewayAddress, gatewayPort, debug);
|
||||
} else {
|
||||
LogError("Invalid FM network protocol specified - %s", protocol.c_str());
|
||||
return false;
|
||||
|
||||
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -I/usr/local/include
|
||||
LIBS = -lpthread -lutil -lsamplerate
|
||||
LIBS = -lpthread -lutil -lsamplerate -lmd
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate -lmd
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DHD44780 -I/usr/local/include
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate -lmd
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DRASPBERRY_PI -I/usr/local/include
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate -lmd
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DOLED -I/usr/local/include
|
||||
LIBS = -lArduiPi_OLED -lpthread -lutil -lsamplerate
|
||||
LIBS = -lArduiPi_OLED -lpthread -lutil -lsamplerate -lmd
|
||||
|
||||
# If you use NetBSD, add following CFLAGS
|
||||
#CFLAGS += -L/usr/local/lib -Wl,-rpath=/usr/local/lib
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
CC = cc
|
||||
CXX = c++
|
||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHAVE_LOG_H -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate
|
||||
LIBS = -lwiringPi -lwiringPiDev -lpthread -lutil -lsamplerate -lmd
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
|
||||
Reference in New Issue
Block a user