GithubHelp home page GithubHelp logo

crisis-lab-2024's Introduction

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.

Setup

These instructions assume that you're in a clone of this repo and that Nix is installed.

Android app

Install

  1. Download the APK here.
  2. Open the APK from your preferred file browser on android
  3. Tap install app

Build/Develop

  1. Open androidapp/Crisislab in Android Studio
  2. Change any code needed
  3. Build using the inbuilt "Build Signed APK"

Backend

  1. 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=
    
  2. Enter a dev shell with packages you'll need for the rest of this process:

    nix develop
    
  3. Go to backend/mqtt-broker and generate a password file for the sensor and server users:

    mosquitto_passwd -c passwords.txt sensor
    mosquitto_passwd passwords.txt server
  4. Start the broker:

    mosquitto -c mosquitto.conf
  5. Go to backend/alerts, install dependencies and start the social alerts:

    bun install
    bun src/index.ts
    
  6. 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.

Frontend

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).

Embedded

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:

  1. Compile: arduino-cli compile --fqbn <FQBN> <DIR_TO_COMPILE>
  2. 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.

Sensor + WiFi

  1. 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
    
  2. 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
    
  3. Change the WiFi SSID and password; the MQTT username and password; and the Server IP address and port variables in /embedded/wifi.ino

  4. Compile and upload embedded/sensor using the steps from earlier, with SparkFun:avr:RedBoard as the FQBN, and embedded/wifi with esp8266:esp8266:generic

Physical Alert

Inside the embedded/physical-alert directory.

  1. Install dependencies:

    arduino-cli lib install --git-url https://github.com/adafruit/Adafruit_TiCoServo https://github.com/adafruit/Adafruit_NeoPixel
    
  2. Compile and upload embedded/physical-alerts/alert-arduino using the steps from earlier, with arduino:avr:uno as the FQBN.

  3. Navigate to the embedded/physical-alerts/alert-client directory.

  4. Install nodejs dependencies.

    npm install
    
  5. Change the serialport path to whichever port you are using to communicate with the Arduino, and change the WebSocket IP adress and port, in client.js

  6. Run node client.js, this will not work without an internet connection. THIS WILL ALSO NOT RUN WITH BUN.

crisis-lab-2024's People

Contributors

chunkybanana avatar alexberry0 avatar tobyck avatar aketon08 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

crisis-lab-2024's Issues

Comments

Adding this because it needs to be fixed before NCEA turn in.

The standard/amount of comments in each file is inconsistant, in some it is far too many, and many need some comments at all. We need to fix both of these issues, before NCEA turnin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.