The folder contains the relay client
It has three files
1. The rtkrcv.conf used by rtkrcv. The configuration file specifies that rtkrcv publish the received information over a tcp port (specified in the conf file)
2. The python code to relay the received information to an mqtt broker
3. The requirements.txt used to create the python environment. 

## RTKRCV Installation

Please place the rtkrcv binary in this folder. The steps for creating the binary are as follows.

- Download the source repository of rtklib at https://github.com/tomojitakasu/RTKLIB
  + This code has been tested with RTKLIB version 2.4.3 b33 
  + https://github.com/tomojitakasu/RTKLIB/archive/v2.4.3-b33.tar.gz

- Extract the tar ball. This should create a folder named in RTKLIB-2.4.3-b33
- Perform the following steps to create the rtkrcv binary. 
```
cd RTKLIB-2.4.3-b33/app
make
cd -
```
- Note that the above steps requires build-essential packages (if it is not previously installed). Also you will notice some warning during the compilation phase. 
- Create a link to the binary in this directory. This is done to avoid specifying the path of the rtkrcv.conf 
```
ln -s RTKLIB-2.4.3-b33/app/rtkrcv/gcc/rtkrcv .
```

## Mosquitto Broker Installation

Install the mosquitto broker and disable the mosquitto service if we want to run it on a specifi port. 
```
apt install mosquitto 
systemctl disable mosquitto
```

## Python environment for rtcm3\_relay

Create a python environment where paho-mqtt is installed. This code was tested using python 3.8

Create a venv folder in this directory. 
```
python3.8 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
- You might see some errors about bdist\_wheel which can be ignored. 


Now open three terminals (as persistent screen [https://www.gnu.org/software/screen/] ) on the server.
- On one screen start the 
./rtkrcv
> start - use this command if you want to start the rtkrcv
> stop  - for stopping the rtkrcv
> shutdown - for quitting

- On the second screen start mosquitto -p <portnumber>. We use 8883 because that port is open on our server for incoming connections

```
mosquitto -p 8883
```

- On the third screen run rtcm\_relay.py 
```
#> python rtcm_relay.py -r localhost -p 11235 -h localhost -b localhost -m 8883 
```