CRISiSLab Challenge 2024
Created by me, chunkybanana, Alex Berry, and aketon08.
This repository contains all the code for our CRISiSLab 2024 project.
To set it up, clone this repo and refer to the instructions in each section below.
Sometimes some more information is contained in READMEs in each section folder.
These instructions assume that you're in a clone of this repo and that Nix is installed.
- Download the APK here.
- Open the APK from your preferred file browser on android
- Tap install app
- Open
androidapp/Crisislab
in Android Studio - Change any code needed
- Build using the inbuilt "Build Signed APK"
-
Make a
.env
file in the root directory of the project which specifies the following:# Social media credentials IG_USERNAME= IG_PASSWORD= EMAIL= EMAIL_PASSWORD= # Password for the social alerts endpoint ALERT_PASSWORD= # These are for the MQTT broker. Make sure they match what you set when you set up Mosquitto. MQTT_USERNAME= MQTT_PASSWORD= # Port for the relay server's WebSocket to run on WS_PORT=8443 # Paths to files for TLS CERT_PATH= KEY_PATH=
-
Enter a dev shell with packages you'll need for the rest of this process:
nix develop
-
Go to
backend/mqtt-broker
and generate a password file for thesensor
andserver
users:mosquitto_passwd -c passwords.txt sensor mosquitto_passwd passwords.txt server
-
Start the broker:
mosquitto -c mosquitto.conf
-
Go to
backend/alerts
, install dependencies and start the social alerts:bun install bun src/index.ts
-
Start the relay server by running a Nix derivation:
RUST_LOG=info SOCIAL_ALERTS=1 nix run .#relay
Don't set
SOCIAL_ALERTS
if you don't want to trigger social media alerts.
Inside the frontend
directory run:
bun install
bun run build
This will output a dist
folder with the bundled site in it. In our case we're hosting it on the same server as the backend which can be done with:
sudo bun server.ts
(Hosts on 80/443 by default so sudo is required).
All of these instructions will use the Arduino CLI. If you haven't already, install that first.
After any setup that may need to be done first (this will be explained soon), the main steps for each component are:
- Compile:
arduino-cli compile --fqbn <FQBN> <DIR_TO_COMPILE>
- Upload:
arduino-cli upload -p <PORT> --fqbn <FQBN> <DIR_TO_UPLOAD>
FQBN stands for Fully Qualified Board Name, and the instructions below will tell you what to use. The port is where you've plugged in the board. This can be found by running arduino-cli board list
.
-
Install board definitions for the SparkFun RedBoard (an Arduino UNO) and the ESP8266:
arduino-cli core install arduino:avr arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/main/IDE_Board_Manager/package_sparkfun_index.json https://arduino.esp8266.com/stable/package_esp8266com_index.json arduino-cli core install SparkFun:avr:RedBoard arduino-cli core install esp8266:esp8266
-
Install dependencies:
If you don't already have this option set, you'll need to enable installing libraries from git repositories:
arduino-cli config set library.enable_unsafe_install true
Then you can install them with:
arduino-cli lib install --git-url https://github.com/sparkfun/SparkFun_LPS28DF_Arduino_Library https://github.com/arduino-libraries/ArduinoMqttClient.git
-
Change the WiFi SSID and password; the MQTT username and password; and the Server IP address and port variables in
/embedded/wifi.ino
-
Compile and upload
embedded/sensor
using the steps from earlier, withSparkFun:avr:RedBoard
as the FQBN, andembedded/wifi
withesp8266:esp8266:generic
Inside the embedded/physical-alert
directory.
-
Install dependencies:
arduino-cli lib install --git-url https://github.com/adafruit/Adafruit_TiCoServo https://github.com/adafruit/Adafruit_NeoPixel
-
Compile and upload
embedded/physical-alerts/alert-arduino
using the steps from earlier, witharduino:avr:uno
as the FQBN. -
Navigate to the
embedded/physical-alerts/alert-client
directory. -
Install nodejs dependencies.
npm install
-
Change the
serialport
path to whichever port you are using to communicate with the Arduino, and change the WebSocket IP adress and port, inclient.js
-
Run
node client.js
, this will not work without an internet connection. THIS WILL ALSO NOT RUN WITH BUN.