# This file is part of Lanradio.
#
# Lanradio is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Lanradio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Lanradio.  If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
# Florian Klingler <klingler@ccs-labs.org>


= Dependencies =
  ensure that package dependencies of following software is installed:
  -- Lede: https://lede-project.org/
  -- OpenC2X: http://www.ccs-labs.org/software/openc2x/
  -- Veins: http://veins.car2x.org/

  The current version of Lanradio was tested using Veins 4.6, OMNeT++ 5.1.1, Lede 17.01.2.
  For compilation gcc 4.8.5 was used.
  For best compatibility, use asn1c from "https://github.com/zhanglei002/asn1c", commit 34e88d2


= Prepare Lede Application =
  -- in 'lede-application/lanradio/src/pstreams/' add the file 'pstream.h' from "https://downloads.sourceforge.net/project/pstreams/pstreams/Release%201.0/pstreams-1.0.1.tar.gz"
  -- in 'lede-application/lanradio/src/zmq/' add the file 'zmq.hpp' from https://github.com/zeromq/cppzmq/raw/v4.2.2/zmq.hpp


= Build Lede Firmware ==
  -- update 'feeds.conf.default' in 'lede-firmware' and change the lanradio feed to point to the lede-application folder
  -- the available configuration was already tested to run on PCEngines APU Platform using WLE200NX wireless cards
     To modify the default IP addresses, see 'files/etc' within 'lede-firmware'
     The build process takes several minutes, downloads files from the internet, and needs more than 6 Gbyte storage.
  -- ensure that 'lanradio-firmware/files/etc/rc.local' containts the correct MAC address of the device
  -- execute 'build_firmware.sh' within the 'lede-firmware' directory to build the firmware

= Build Veins =
  -- in 'veins/src/veins/modules/lanradio/asn1/' download following files
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftrunk%2FCDD_TS102894-2%2FITS-Container.asn&rev=18&peg=18
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftrunk%2FCAM_EN302637-2%2FCAM.asn&rev=2&peg=2
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftrunk%2FDENM_EN302637-3%2FDENM.asn&rev=5&peg=5
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftags%2FMAP_SPAT_SAEJ2735%2F20141020%2FDSRC_REG_D.asn&rev=9&peg=9
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftags%2FMAP_SPAT_SAEJ2735%2F20141020%2FMAP_SPAT_ETSI.asn&rev=9&peg=9
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.ITS_ASN1&path=%2Ftags%2FMAP_SPAT_SAEJ2735%2F20141020%2FMAP_SPAT_REG_D.asn&rev=9&peg=9
  -- update 'generate.sh' in 'veins/src/veins/modules/lanradio/asn1/' such that it includes the path to your asn1c installation; execute the script
  -- similar for 'veins/src/veins/modules/lanradio/protobuf/'
  -- (option 1) compile veins by executing './configure && make MODE=release' in folder 'veins/'
  -- (option 2) import veins project as omnetpp project by using the IDE, and compile the project

= Run Lanradio =
  -- download and extract 'https://www.kernel.org/pub/linux/utils/boot/syslinux/6.xx/syslinux-6.03.tar.gz' and copy the file 'syslinux-6.03/bios/core/pxelinux.0' to 'lede-firmware/pxe_boot_server/'.
  -- create a symlink 'images' in 'lede-firmware/pxe_boot_server/' pointing to the compiled firmware folder, e.g., '../bin/targets/x86/generic/'.
  -- when the firmware is compiled, you can run 'start_dnsmasq.sh' within 'lanradio-firmware/pxe_boot_server/' to start a dhcp and tftp server. Update the interfacename in start_dnsmasq.sh accordingly.
  -- power on compatible hardware such that it boots the firmware over pxe
  -- connect to lanradio by executing 'veins/examples/lanradio/connect_lanradio.sh'.
  -- run the veins simulation example in 'veins/examples/lanradio'.

= Debugging =
  -- there exist dissectors of ETSI ITS G5 CAM/DENM/SPAT for wireshark:
    -- http://oldforge.etsi.org/websvn/dl.php?repname=ITS.WIRESHARK_ITS_PLUGINS&path=%2Freleases%2Fwireshark-2.2.x%2FLinux%2F64bits%2F&isdir=1&rev=65&peg=65
    -- copy the extracted files to '~/.config/wireshark/plugins/'
  -- modify and execute 'veins/examples/lanradio/receiver_wireshark.sh' to connect to a second device to show received Messages sent by Lanradio.
