[info_box style=”attention”]Warning: This is an advanced topic. You will need to have a decent understanding of the Linux command line and file system, how SVXLink it’s self works and is configured, as well as understanding of the PHP programming language. If you don’t feel comfortable with these areas, then do not proceed with these instructions. [/info_box]

So you want to make ORP do more that what it can out of the box and you are OK with doing some coding? Perhaps you have specialized needs that are not built into ORP yet or are more niche to your setup. This article will help point you in the right direction. If won’t go into what those SVXLink configurations are, but rather it will point you to where to make the modifications.

Some Background First

Firstly, it is important to understand how OpenRepeater is structured and how it works. If you don’t already know the OpenRepeater Project combines a number of elements into a prepackaged setup to run on single board computers like the Raspberry Pi. These elements include the base OS (Debian), the SVXLink program which is our core logic, a web server and other components that make the ORP Web Front end function. This web front end its part of the ORP project that helps with configuring some of the most common setting for the basic operation of a repeater.

When you log into the web front end and make changes they will immediately get saved into a database. At this point no changes are made to the SVXLink configuration. You will notice that a prompt appears at the top of the page prompting you to “rebuild & restart”. When changes are made, a flag is set to make this prompt appear. Once you are done making changes, you can click on the “rebuild & restart” button. What this does is runs a PHP build script that reads all the settings from the database and performs some conditional logic and writes out multiple configuration files including the main SVXLink configuration file, some other configuration and override files (like custom TCL logics) to modify the behavior of features such as identification & courtesy tones, GPIO setting to initialize the GPIO pins with the OS, and then it will restart SVXLink to read in the new configurations.

The main SVXLink configuration file is located here:

/etc/openrepeater/svxlink/svxlink.conf

This is an example of what that code might look like.

[GLOBAL]
MODULE_PATH=/usr/lib/arm-linux-gnueabihf/svxlink
LOGICS=RepeaterLogic
CFG_DIR=svxlink.d
TIMESTAMP_FORMAT="%c"
CARD_SAMPLE_RATE=16000
#LOCATION_INFO=LocationInfo
#LINKS=LinkToR4

[RepeaterLogic]
TYPE=Repeater
RX=Rx1
TX=Tx1
MODULES=ModuleHelp,ModuleParrot
CALLSIGN=A0AAA
SHORT_IDENT_INTERVAL=1
LONG_IDENT_INTERVAL=5
EVENT_HANDLER=/usr/share/svxlink/events.tcl
DEFAULT_LANG=en_US
RGR_SOUND_DELAY=1
REPORT_CTCSS=
TX_CTCSS=ALWAYS
MACROS=Macros
FX_GAIN_NORMAL=0
FX_GAIN_LOW=-12
IDLE_TIMEOUT=1
OPEN_ON_SQL=1
OPEN_SQL_FLANK=OPEN
IDLE_SOUND_INTERVAL=0

[Rx1]
TYPE=Local
AUDIO_DEV=alsa:plughw:0
AUDIO_CHANNEL=0
SQL_DET=GPIO
GPIO_SQL_PIN=gpio27
SQL_HANGTIME=10
SQL_START_DELAY=1
SQL_DELAY=10
SIGLEV_SLOPE=1
SIGLEV_OFFSET=0
SIGLEV_OPEN_THRESH=30
SIGLEV_CLOSE_THRESH=10
DEEMPHASIS=1
PEAK_METER=0
DTMF_DEC_TYPE=INTERNAL
DTMF_MUTING=1
DTMF_HANGTIME=100
DTMF_SERIAL=/dev/ttyS0

[Tx1]
TYPE=Local
AUDIO_DEV=alsa:plughw:0
AUDIO_CHANNEL=1
PTT_TYPE=GPIO
PTT_PORT=GPIO
PTT_PIN=gpio22
PTT_HANGTIME=3000
TIMEOUT=300
TX_DELAY=500
PREEMPHASIS=0
DTMF_TONE_LENGTH=100
DTMF_TONE_SPACING=50
DTMF_TONE_PWR=-18

If you want to see what your file looks like after you makes changes you can CAT the contents of the file with the following command:

cat /etc/openrepeater/svxlink/svxlink.conf

This uses some of the most common settings and sections required to run a repeater. This is the main file that SVXLink will read in upon startup or restarting. To see what additional features that the SVXLink core program supports, view the SVXLink manpages.

Where to Make the Modifications

As you can probably figure out by reading above, you can certain make changes to the SVXLink.conf file and other config files that are written to by ORP, but if you make changes within the web interface and “rebuild & restart” then those changes are going to be over written. The way around this is to modify the svxlink_update.php file or it’s included files.

The SVXLink_update.php file is located here:

/var/www/openrepeater/functions/svxlink_update.php

At The Top of the File…

You will see where the files are called in that read from the database.

// Get Settings from SQLite
include_once("../includes/get_settings.php");

// Get Port Settings from SQLite
include_once("../includes/get_ports.php");

At The Bottom of the File…

Where it writes out the configuration files.

/* WRITE CONFIGURATION & TCL FILES */

file_put_contents('/etc/openrepeater/svxlink/svxlink.conf', $svx_global . $svx_repeaterLogic . $svx_ports);
if (isset($moduleEchoLink)) { file_put_contents('/etc/openrepeater/svxlink/svxlink.d/ModuleEchoLink.conf', $moduleEchoLink); }
file_put_contents('/etc/openrepeater/svxlink/local-events.d/CustomLogic.tcl', $tclOverride);
file_put_contents('/etc/openrepeater/svxlink/svxlink_gpio.conf', $gpioConfigFile);

…and clears the flag and restarts SVXLink…

/* CLEAR SETTINGS UPDATE FLAG TO CLEAR BANNER AT TOP OF PAGE */
$memcache_obj = new Memcache;
$memcache_obj->connect('localhost', 11211);
$memcache_obj->set('update_settings_flag', 0, false, 0);

$shellout = shell_exec('sudo /usr/bin/openrepeater_svxlink_restart');

All the Magic Happens in the Middle…

Here is an example of one section of code. The example sets some EchoLink settings.

/* MODULE: ECHOLINK CONFIGURATION SETTINGS */

if ($settings['echolink_enabled'] == "True") {

	$echolink_clean_desc = preg_replace('/\r\n?/', "\\n", $settings['echolink_desc']);

	$moduleEchoLink = '[ModuleEchoLink]
	NAME=EchoLink
	ID=2
	TIMEOUT=60
	SERVERS=servers.echolink.org
	CALLSIGN='.$settings['echolink_callSign'].'
	PASSWORD='.$settings['echolink_password'].'
	SYSOPNAME='.$settings['echolink_sysop'].'
	LOCATION='.$settings['echolink_location'].'
	MAX_QSOS=4
	MAX_CONNECTIONS=4
	LINK_IDLE_TIMEOUT=300
	DESCRIPTION="'.$echolink_clean_desc.'"
	USE_GSM_ONLY=1

	';
}

It goes without saying…make a backup copy of this file before you start making changes to it. As you can see, SVXLink expects things grouped into sections. Some of these settings are hard coded (which you could change here if you’d like) and other have the variables inserted. In some cases some additional PHP logic is added, or things are grouped into functions, or external files are called to help keep things more organized. Knowing this, it should give you a good understanding of how to reverse engineer this for your own needs. It’s probably best to make small changes at a time. When done, save the file and go to the web gui, initiate a change to invoke the “Rebuild & Restart” bar. When you run that this file will be called. If all goes well, you changes will be applied to the SVXLink configuration file and be loaded. If you see a white screen or an error message, then that is usually a good indicator that you have improperly formatted code.

Happy Modding!

in Advanced / Command Line
Did this article answer your question?