Using a Raspberry Pi (3) as DML trx controller

Info about the hardware setup

  • Raspberry Pi 3 model B+
  • Connected to a niceRF SA818 VHF module
  • USB audio card for audio in and out
  • PTT connected to GPIO3
  • DCD connected to GPIO2
  • USB serial converter (Raspberry Pi 3 serial port seems to have timing issues)

    Info about the software setup

  • freedv_eth Controlling the Radio, audio input and output and making it available on a network device called 'vhf'
  • dml_trx Connecting to the network device and to the DML network (via dmld) making links with other DML nodes possible.
  • dmld Providing access to the rest of the DML network.

    Example usage:

  • Personal access point to the DML network using your handset around the house.
  • Controlling a repeater (needs a fullduplex radio and freedv_eth set to fullduplex mode)
  • vhf.pe1rxq.ampr.org use this setup with a small modification (tx_mode set to none) to link the VHF repeater PI3EHV to the UHF repeater PI2EHV each Sunday during the local net.
  • Installation steps:

    Start with a basic install on the Raspberry Pi.
    The rest of this page assumes a fresh Slackware install from http://sarpi.co.uk
    Install codec2, hamlib, libwebsockets, flite, eth_ar and dml:
    Note commands used, such as 'installpkg' for installing flite, may vary on based on distribution.
    cd
    wget https://hobbes1069.fedorapeople.org/freetel/codec2/codec2-0.8.tar.xz
    tar -xvf codec2-0.8.tar.xz
    cd codec2-0.8
    mkdir build
    cd build
    cmake ..
    make
    make install
    
    cd
    git clone https://github.com/JeroenVreeken/Hamlib.git
    cd Hamlib
    ./bootstrap
    ./configure --prefix=/usr
    make
    make install
    
    cd
    git clone https://github.com/warmcat/libwebsockets.git
    cd libwebsockets
    mkdir build
    cd build
    cmake ..
    make
    make install
    
    cd
    git clone http://dmlinking.net/~pe1rxq/eth_ar.git/
    cd eth_ar
    ./bootstrap
    ./configure --prefix=/usr
    make
    make install
    
    cd
    wget https://slackbuilds.org/slackbuilds/14.2/development/texi2html.tar.gz
    tar -xvf texi2html.tar.gz
    cd texi2html
    wget http://download.savannah.gnu.org/releases/texi2html/texi2html-5.0.tar.bz2
    ./texi2html.SlackBuild 
    installpkg /tmp/texi2html-5.0-arm-1_SBo.tgz 
    
    cd
    wget https://slackbuilds.org/slackbuilds/14.2/accessibility/flite.tar.gz
    tar -xvf flite.tar.gz
    cd flite
    http://festvox.org/flite/packed/flite-2.0/flite-2.0.0-release.tar.bz2
    ./flite.SlackBuild
    installpkg /tmp/flite-2.0.0-arm-2_SBo.tgz 
    
    cd
    git clone http://dmlinking.net/~pe1rxq/dml.git/
    cd dml
    ./bootstrap
    ./configure --prefix=/usr
    make
    make install
    
    mkdir /usr/share/flite
    cd /usr/share/flite
    wget "http://festvox.org/flite/packed/latest/voices/cmu_us_ljm.flitevox"
    
    chmod a+x /etc/rc.d/rc.alsa
    
    ldconfig
    
    RPi configuration: Add the following to /boot/config.txt to make the serial port usable:
    dtoverlay=pi3-disable-bt
    
    On my setup I could not get the connection between the Raspberry Pi and the TRX module stable. I ended up using a USB to serial converter and used /dev/ttyUSB0 for radio control instead.
    Software configuration:
    mkdir /etc/dml
    cd
    cd dml
    cp -r audio /etc/dml
    mkdir /etc/dml/ca
    mkdir /etc/dml/cert
    
    Copy your private key (k.pem) and certificate (trx.pirate.ampr.org.cert.pem) to /etc/dml/cert.
    Copy the certificates you accept to /etc/dml/ca and complete the step by creating hashes in the directory:
    c_rehash /etc/dml/ca/
    
    Create /etc/dml/dmld.conf with:
    echo "server=dmlinking.net" >/etc/dml/dmld.conf
    
    And /etc/dml/dml_trx.conf: (beware that some values will need editing)
    echo "
    # stream details
    name = trx.pirate.ampr.org
    alias = 12345678
    
    dv_device = trx
    
    # Our own certificate and private key
    certificate = /etc/dml/cert/trx.pirate.ampr.org.cert.pem
    key = /etc/dml/cert/k.pem
    
    # Who do we trust?
    ca = /etc/dml/ca/
    
    latitude = 85.1234
    longitude = 30.0000
    fprs_text = VHF FM hotspot 12345678
    
    ## Is it a fullduplex trx
    fullduplex = 0
    ## May we respond to on-air commands?
    allow_commands = 1
    ## Optional prefix used for searching aliasses
    command_prefix = 204
    ## Open command pipe
    command_pipe_name = /tmp/pirate.command
    
    
    aprsis_host = euro.aprs2.net
    aprsis_port = 14580
    
    soundlib_connect = /etc/dml/audio/connect.alaw
    soundlib_disconnect = /etc/dml/audio/disconnect.alaw
    soundlib_remote_disc = /etc/dml/audio/remote_disconnected.alaw
    soundlib_notfound = /etc/dml/audio/notfound.alaw
    soundlib_notallowed = /etc/dml/audio/notallowed.alaw
    
    ## DML header
    soundlib_header = /etc/dml/audio/pirate.alaw
    
    soundlib_voice = /usr/share/flite/cmu_us_ljm.flitevox
    " >/etc/dml/dml_trx.conf
    
    The freedv_eth config:
    echo "
    ## freedv_eth config
    ##
    ## More output?  
    #verbose = 0
    
    ## NMEA device to use for location information
    #nmea_device = /dev/gps
    
    
    ## Sound device to transceiver
    #sound_device = default
    #sound_device = hw:2
    sound_device = hw:0
    sound_rate = 48000
    
    ## Valid values: left, right, 0, 1
    ## (left == 0, right == 1)
    freedv_rx_sound_channel = right
    analog_rx_sound_channel = left
    
    ## Name to use for new network device
    network_device = vhf
    
    ## Callsign to use for network device address
    callsign = pe1rxq-4
    
    
    ## TX delay and tail in msec
    #tx_delay = 100
    #tx_tail = 100
    ## TX mode, valid options: freedv, analog
    #tx_mode = freedv
    tx_mode = analog
    #tx_mode = none
    
    ## RX mode, valid options: none, freedv, analog, mixed
    rx_mode = mixed
    
    ## Fullduplex or not?
    fullduplex = 0
    
    ## Freedv Mode
    freedv_mode 2400B
    
    ## Rig
    rig_model = 3101
    rig_file = /dev/ttyUSB0
    rig_ptt_file = 3
    rig_ptt_type = GPION
    rig_dcd_file = 2
    rig_dcd_type = GPION
    
    # needed for CD generation in ft817 interface
    # rig_conf_set = dtr_state ON
    #rig_conf_set = rts_state OFF
    rig_freq_rx = 145700000
    rig_ctcss_sql = 719
    
    ## Control text
    ## Use VC bits for control (1=VC bits, 0=data frames)
    #control_vc = 0
    
    analog_rx_short = 0
    
    ## CTCSS
    #analog_tx_ctcss_frequency = 0.0
    # amp: 1.0 == full deviation (assuming 3kHz)
    #      0.17 = about 500Hz
    #analog_tx_ctcss_amp = 0.17
    ## Morse beacon
    #analog_tx_beacon_interval = 300
    #analog_tx_beacon_message = Pirate
    ## Pre-emphasis on or off
    analog_tx_emphasis = off
    
    analog_rx_gain = 2.0
    analog_rx_dcd_threshold = 2
    #analog_rx_ctcss_frequency = 0.0
    
    ## Output baseband on second audio channel (without ctcss, emphasis, beacon)
    analog_tx_baseband = 0
    ## Output CTCSS tone on second audio channel
    analog_tx_tone = 0
    
    ## Mute samples when DTMF is detected
    analog_dtmf_mute = 1
    
    
    
    " >/etc/dml/freedv_eth.conf
    
    Add to /etc/rc.d/rc.local:
    echo "
    export HOME=/root
    
    /usr/bin/screen -dmS dmld /usr/bin/dmld /etc/dml/dmld.conf
    /usr/bin/screen -dmS freedv_eth /usr/bin/freedv_eth /etc/dml/freedv_eth.conf
    /usr/bin/screen -dmS dml_trx /usr/bin/dml_trx /etc/dml/dml_trx.conf
    " >>/etc.rc.d/rc.local
    
    Don't forget to create the header audio file identifying your station in /etc/dml/audio Als don't forget to check the audio levels of your setup. Once you are sattified you can store them using 'alsactl store'

    Example automatic linking

    For example if you wish to link to another node a certain fixed times you can add this to the file /var/spool/cron/crontabs/root
    # Connect PI3EHV stream to PI2EHV
    # Sunday 10:45 till 13:00
    45 10 * * sun /usr/bin/echo "204568" >/tmp/pi3ehv.command 2>/dev/null
    0 13 * * sun /usr/bin/echo "73" >/tmp/pi3ehv.command 2>/dev/null