4.- Installation and adjustment of the remoteSwitch

Finally, in this fourth part we will explain how to load the remoteSwitch program, its configuration and how to leave it as a service and do it in a simple way that starts or stops. And of course, the most important thing is that when the Raspberry Pi restarts, the remoteSwitch starts automatically.

As already indicated, we will need an instance of the remoteSwitch that acts as a web server and as many as computers to control are needed. If for example we want to control:

  • 1 RemoteBox 2×6
  • 3 StackMain (stacks for 10, 15 and 20m)
  • 1 RemoteBox 1×4 for a 4 Vcal phased antennas on 80m

We will have to have 6 configuration files:

  • WEB server
  • RemoteBox 2×6 server
  • One for each StackMain (there are 3 files)
  • RemoteBox 1×4 server for vertical phased controller

And logically run as many instances – each with its configuration file – as necessary. It is normal to add each instance as a service and be able to start / stop each one of them

remoteSwitch program

We can download the program from the EA4TX server:

https://ea4tx.com/wp-content/uploads/files/rspi/remoteSwitch

Note: remember that this binary is for Raspberry Pi.

We have many ways to put the remoteSwitch binary in the RsPi. In our case we will download it and copy it to the folder where we want it to be. We execute therefore:

wget https://ea4tx.com/wp-content/uploads/files/rspi/remoteSwitch

With this we already have the binary in the RsPi although surely in the root folder or /home/pi. We will now copy the program to the folder /usr/local/sbin which is where it would normally be left, for this we can use the program mc (midnight commander that we had already installed in step 2) or by using the command:

sudo cp remoteSwitch /usr/local/sbin/

Or the two commands in a single instruction, giving information of the path where you have to download it:

wget https://ea4tx.com/wp-content/uploads/files/rspi/remoteSwitch -P /usr/local/sbin/

With this we have already downloaded the file but we have to mark the execution attributes. You can do it using the chmod command or use the mc program to make this change

sudo chmod 755 /usr/local/sbin/remoteSwitch

Configuration File as Equipment Server: rbm1

In this section we will configure one of the services that we will call RBM1 (we can give it any name) and that will be responsible for supporting and treating a RemoteBox or StackMain. This module is the one that will process the commands that you receive from the computer and that will interpret and notify the web server and that we will see later.

The remoteSwitch program can be executed by means of a command line with all the options but surely it is more practical to have a configuration file and execute the program indicating the location of the configuration file. You can see all available options using the help command -h for example:

/usr/local/sbin/remoteSwitch -h

Although as I said before, it is more practical to have a configuration file with all its parameterized options, than to execute the program with all the options per command line. I have left a model configuration file on the EA4TX server and can be downloaded using the command:

wget https://ea4tx.com/wp-content/uploads/files/rspi/rbm1.toml

And since the usual thing is that the configuration files are usually in the /etc folder, we copy it to that folder.

sudo cp rbm1.toml /etc/

If we edit the file (we can use the nano editor or through the Midnight Commander – mc command) we will customize some of the configuration parameters.

sudo nano /etc/rbm1.toml

rbm1.service file

On the one hand it indicates how to connect to the NATS server, it indicates what type of device will be “ea4tx_remotebox“, the name of the device “remotebox_1x6” and that it will connect to the device via TCP / IP connection (Connection = 1) where the address will be : “127.0.0.1” and the port “7011“.

Note: Just the port that was defined in the ser2net service to access the RemoteBox.

If your configuration is correct, run the program using the command:

/usr/local/sbin/remoteSwitch server nats --config /etc/rbm1.toml

If it has not given you any error, go on to configure the web server file to start another instance with this service.

Configuration File as WEB Server: rbw

Now we will configure the service to start as a web server. We will use the file rbw.toml

We have another template available in EA4TX then you can download it using the command:

wget https://ea4tx.com/wp-content/uploads/files/rspi/rbw.toml

And we will also copy it to /etc.

sudo cp rbw.toml /etc/

Edit the file:

sudo nano /etc/rbw.toml

In this case it also indicates how to connect to the NATS server and also tells the web server on which port to listen. If your configuration is correct, run the program using the command:

/usr/local/sbin/remoteSwitch web --config /etc/rbw.toml

After less than 1 minute and if it has not given you any error, you can open a browser pointing to

http://192.168.10.97:7072

Start System

To leave these 2 automated services at startup, we will again use SystemD. For this we will leave in the folder /etc/systemd/system the files that we have available in EA4TX:

  • rbm1.system
  • rbw.system.

Puedes bajar estos ficheros mediante el comando:

sudo wget https://ea4tx.com/wp-content/uploads/files/rspi/rbm1.service

and

sudo wget https://ea4tx.com/wp-content/uploads/files/rspi/rbw.service

And copy them to the /etc/systemd/system folder. The commands will be:

sudo cp rbm1.service /etc/systemd/system/

and

sudo cp rbw.service /etc/systemd/system/

rbm1.service file

In principle, these files that you have downloaded and copied to the /etc/systemd/system folder can be left as is without having to change anything in them. Now we would only have to activate the rbm1 and rbw services in the systemd manager. We therefore execute the commands:

sudo systemctl enable rbm1.service

and

sudo systemctl enable rbw.service

With this already restarting the RsPi, these services will be executed automatically. You can also start or stop them manually, for this the start command would be:

sudo service rbm1 start

sudo service rbw start

or to stop:

sudo service rbm1 stop

sudo service rbw stop

With all this, we should already have the remoteSwitch program running, then we could start a browser on our PC and connect to the URL of the Raspberry Pi with port 7072 (it is the default port defined in the file rbm1.toml for the Web)

Or open the RBM program and configure that the rotor is “Remote TCP/IP” and in its configuration indicate the IP and TCP port used by the Raspberry Pi (defined in the ser2net service)