diff --git a/build b/build index 0e84521..b3d81b8 100755 --- a/build +++ b/build @@ -46,6 +46,7 @@ if [[ "$#" -lt 1 ]]; then echo -e " ${CACTION}client-watch${RS}${LC} - Auto-rebuild the client-side code on modification."; echo -e " ${CACTION}render-initial${RS}${LC} - Render the initial report"; echo -e " ${CACTION}render-final${RS}${LC} - Render the final report"; + echo -e " ${CACTION}render-manuals${RS}${LC} - Render the user manuals"; echo -e " ${CACTION}geojson-debug${RS}${LC} - Generate some GeoJSON from the raw readings for debugging purposes (paste into geojson.io)"; echo -e ""; @@ -92,6 +93,8 @@ task_setup() { if [[ "$?" -ne "0" ]]; then echo "${HC}pdflatex${RS} is required to render the reports."; fi check_command bibtex true optional; if [[ "$?" -ne "0" ]]; then echo "${HC}bibtex${RS} is required to render the reports."; fi + check_command weasyprint true optional; + if [[ "$?" -ne "0" ]]; then echo "${HC}weasyprint${RS} is required to render the user manuals."; fi task_end $?; task_begin "Initialising submodules"; @@ -238,13 +241,47 @@ task_geojson-debug() { # ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ # ██ ██ ███████ ██ ██████ ██ ██ ██ ███████ +task_render-manuals() { + task_begin "Rendering README"; + _render-markdown-pdf "README.md" "README.pdf" "LoRaWAN Signal Mapping - User Manual"; + task_end "$?"; + + task_begin "Rendering HARDWARE"; + _render-markdown-pdf "HARDWARE.md" "HARDWARE.pdf" "LoRaWAN Signal Mapping - Hardware Guide"; + task_end "$?"; +} + task_render-initial() { _render-latex-pdf "Reports/Initial-Report/Initial-Report.tex"; } task_render-final() { + tasks_run render-manuals; _render-latex-pdf "Reports/Final-Report/Final-Report.tex"; } +# $1 - Source file +# $2 - Destination file +# $3 - Title +_render-markdown-pdf() { + source="${1}"; + dest="${2}"; + title="${3}"; + + tmpfile="$(mktemp msc-project-md-pdf.XXXXXXX)"; + + subtask_begin "Markdown -> HTML"; + pandoc -s "${source}" -o "${tmpfile}" --metadata "title=${title}"; + task_end "$?"; + + subtask_begin "HTML -> PDF"; + weasyprint "${tmpfile}" "${dest}" --stylesheet print.css; + task_end "$?"; + + subtask_begin "Cleanup"; + rm "${tmpfile}"; + task_end "$?"; +} + # $1 - Location of top-level LaTeX file _render-latex-pdf() { if [[ ! -f "$1" ]]; then diff --git a/msc-project-md-pdf.ikopCXS b/msc-project-md-pdf.ikopCXS new file mode 100644 index 0000000..8895a9f --- /dev/null +++ b/msc-project-md-pdf.ikopCXS @@ -0,0 +1,203 @@ + + + + + + + LoRaWAN Signal Mapping - User Manual + + + + +
+

LoRaWAN Signal Mapping - User Manual

+
+

Msc-Summer-Project

+
+

My Msc Summer Project

+
+

This repository contains my Masters-level summer project. The title is LoRaWAN Signal Mapping. The software contained here provides a complete system for mapping and visualising the signal coverage of The Things Network.

+

Structure

+

The system is split up into 2 primary parts:

+
    +
  1. An Arduino program that collects the data.
  2. +
  3. A Node.js program that stores and analyses the data
  4. +
+

It’s best explained with the aid of a diagram or two:

+

+

The above flowchart describes the workflow when using the system:

+
    +
  1. First, the IoT device is turned on and the TTN Listener is launched.
  2. +
  3. Then, the IoT device is taken around the target area that needs mapping. This can be done by anyone - the device does not require operation beyond turning it on and off once provisioned.
  4. +
  5. Once the device has been carried around the target area, the DATA.TSV file on the IoT device’s microSD card is copied off and placed on the server.
  6. +
  7. The server data processor is then run to fold the data into the database.
  8. +
  9. The AI trainer is now run on the collected data
  10. +
  11. The data is displayed in a web browser, with the help of a web server
  12. +
+

The flow of data during use can be shown using a diagram:

+

+

System requirements

+

This software has a number of requirements in order to function properly:

+ +

Getting Started

+

Step 0: Initial setup

+

Before doing anything, clone this git repository to both the server (for the TTN listener etc.) and your local machine (for programming the IoT device):

+
git clone https://git.starbeamrainbowlabs.com/sbrl/Msc-Summer-Project.git
+

If you have somehow obtained a static copy of the code (e.g. through the University’s marking system), then skip the above and use that instead.

+

Next, cd to the root of the repository and then run the setup task of the build script:

+
./build setup
+

On Windows, this should be run in Git Bash (accessible from the start menu when Git is installed - don’t forget to cd to the root of the repository).

+

Step 1: Build a device

+

First, a device must be built and provisioned. See HARDWARE.md in this repository for detailed instructions on how to do this.

+

Once built, copy iot/main/settings.custom.cpp.example to iot/main/settings.custom.cpp and follow the instructions fill in the fields there. To do this, you’ll need to register the device using ABP (Activation By Personalisation) on The Things Network. This guide tells you how to do this.

+

It is suggested that the following Bash one-liner be used to generate a new encryption key in the right formats:

+
head -c16 /dev/urandom | od -tx1 | awk '{ gsub(/^0+\s+/, "", $0); toml=$0; gsub(/\s+/, "", toml); print("settings.toml format: " toml); arduino=toupper($0); gsub(/\s+/, ", 0x", arduino); print("settings.custom.cpp format: 0x" arduino); exit }'
+

(Paste it into a terminal and hit enter)

+

Then, review iot/main/settings.h to make sure it matches your setup (e.g. all the pin numbers are correct)

+

Next, copy the folders in iot/libraries to your Arduino IDE libraries folder.

+

Finally, open iot/main/main.ino in the Arduino IDE and program the IoT device itself.

+

Step 2: The Things Network Setup

+

This step should be completed on the server.

+

Once a device has been constructed, running the The Things Network listener is next. This requires giving the system the The Things Network credentials.

+

Edit the file called settings.toml in the root of this repository (or create it if it doesn’t exist), and make sure it contains the following:

+
[ttn]
+app_id = "{APPLICATION_ID}"
+access_key = "{TTN_ACCESS_ID}"
+
+encryption_key = "{ENCRYPTION_KEY_FROM_STEP_1}"
+
+port = 8883
+tls = true
+
+devices = [ "{DEVICE_NAME_FROM_TTN}" ]
+

The app_id and access_key can be obtained from The Things Network Console:

+

+

The device name can be obtained from step #1, when you registered the device with The Things Network. Alternatively, if the device is already registered, it can be obtained from the device list if you click the “X registered devices” text.

+

With settings.toml filled in, you can now start TTN Listener:

+
./build ttn-listener
+

….it will display an error message if you forgot a value.

+

Now that the TTN listener is running, the IoT device can be carried around and data collected.

+

Step 3: Processing the data

+

This step should be completed on the server.

+

Once data has been collected by the IoT device, it can then be processed by the Node.js server application.

+

Copy the DATA.TSV file from the IoT device’s microSD card to the root of the repository on the server. It is suggested that scp (Linux) or WinSCP be used to do this.

+

Next, fold DATA.TSV into the database like so:

+
./build process-data
+

Then, train the AIs on the collected data like this:

+
./build train-ai
+

The architecture of the neural networks trained can be customised by editing settings.toml. Check server/settings.default.toml for a guide on the different options available.

+

Step 4: Viewing the AI output

+

With the AIs trained, the browser-based web interface can be used to display the output as a map. Any static web server will do, but the build script has one built-in (if PHP is installed) for convenience:

+
./build server
+

If an alternative server is to be used, it should serve the app/ directory that can be found in the root of this repository.

+

Credits

+ +

IoT Device

+ +

Node.js Server

+ +

Web Interface

+ + + + + diff --git a/print.css b/print.css new file mode 100644 index 0000000..84a0319 --- /dev/null +++ b/print.css @@ -0,0 +1,115 @@ +/* Base CSS */ + +/* + * This CSS file contains (for me) logical style defaults that are easy to read. + * + * This file is quite often used as a starting point for other projects. + * The original version of this stylesheet lives at https://starbeamrainbowlabs.com/theme/basic.css + * Proof that I wrote this is, as always, available upon request. + * + * Todo: + *