.. _receiver: Setting up an AIS receiver ========================== Requirements ------------ - Raspberry Pi or some other computer with internetworking capability - 162MHz receiver, such as `Wegmatt dAISy 2 Channel Receiver `__ - An antenna in the VHF frequency band (30MHz - 300MHz) Example: `Shakespeare QC-4 VHF Antenna `__ - Optionally, you may want - Antenna mount - A filtered preamp, such as `this one sold by Uputronics `__, to improve signal range and quality Hardware Setup -------------- - When setting up your antenna, be sure to place it as high as possible and as far away from obstructions and other equipment as is practical. - Connect the antenna to the receiver. If using a preamp filter, this should be connected in between the antenna and the receiver. - Connect the receiver to your linux device via USB cable. If using a preamp filter, power this with a USB cable also - Validate the hardware configuration - When connected via USB, The AIS receiver is usually located under /dev/ with a name beginning with ttyACM, for example /dev/ttyACM0. Ensure that a device is present here - To test the receiver, use ``sudo cat /dev/ttyACM0`` to display its output. If all is working as intended, you should see some streams of bytes appearing on the screen. :: $ sudo cat /dev/ttyACM0 !AIVDM,1,1,,A,B4eIh>@0oAeDVHIfm87wh7kP06,0*20 Software Setup -------------- Quick Start +++++++++++ Connect the receiver to the raspberry pi via USB port, and then run the ``configure_rpi.sh`` script. This will install the rust toolchain, AISDB dispatcher, and AISDB systemd service (described below), allowing the receiver to start at boot. .. code-block:: bash curl --proto '=https' --tlsv1.2 https://git-dev.cs.dal.ca/meridian/aisdb/-/raw/master/configure_rpi.sh | bash Custom Install ++++++++++++++ #. Install Raspberry Pi OS with SSH enabled https://www.raspberrypi.com/software/ . If using the RPi imager, be sure to run it as an administrator. #. Connect the receiver to the raspberry pi using the USB cable. Login to the pi and update the system ``sudo apt-get update`` #. Install the rust toolchain on the raspberry pi ``curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`` #. Log out and log back in to add rust and cargo to the system path #. Install the network client and dispatcher from crates.io ``cargo install mproxy-client`` * To install from source, use the local path instead e.g. ``cargo install --path ./dispatcher/client`` #. Install new systemd services to run the AIS receiver and dispatcher, replacing ``User=ais`` and ``/home/ais`` with the name selected in step 1. Create a new text file ``./ais_rcv.service`` with contents: .. code-block:: :caption: ./ais_rcv.service [Unit] Description="AISDB Receiver" After=network-online.target Documentation=https://aisdb.meridian.cs.dal.ca/doc/receiver.html [Service] Type=simple User=ais ExecStart=/home/ais/.cargo/bin/mproxy-client --path /dev/ttyACM0 --server-addr 'aisdb.meridian.cs.dal.ca:9921' Restart=always RestartSec=30 [Install] WantedBy=default.target This service will broadcast receiver input downstream to aisdb.meridian.cs.dal.ca via UDP. Additional endpoints can be added at this step, for more info see ``mproxy-client --help``, as well as additional AIS networking tools ``mproxy-forward``, ``mproxy-server``, and ``mproxy-reverse`` located in the ``./dispatcher`` source directory. Next, link and enable the service on the rpi. This will start the receiver at boot .. code-block:: bash sudo systemctl enable systemd-networkd-wait-online.service sudo systemctl link ./ais_rcv.service sudo systemctl daemon-reload sudo systemctl enable ais_rcv sudo systemctl start ais_rcv See more examples in ``docker-compose.yml``