Skip to content

OsloMet-OceanLab/aneris-webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aneris-webserver

This app works as the web server for the aneris prototype

Hardware

This server is meant to work on a Raspberry Pi 5, although a Raspberry Pi 4b will also work. The camera used is a blue robotics low light camera

Streaming

The streaming is done via ffmpeg and mediamtx. Although mediamtx is not strictly necessary, it is highly recommended to install as it simplifies managing multiple streams and protocols (such as rtsp and rtmp). Mediamtx must be compiled and installed from source. Once done, the streaming can be done by appending this lines to mediamtx.yml:

paths:
  stream-raw:
    runOnInit: ffmpeg -fflags +genpts -f v4l2 -input_format h264 -video_size 1920x1080 -framerate 30 -i /dev/video2 -c copy -f rtsp -rtsp_transport udp rtsp://127.0.0.1/$MTX_PATH
    runOnInitRestart: yes
  stream:
    runOnInit: ffmpeg -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 30 -i /dev/video0 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf:text='SMARTBAY - ANERIS %{localtime}':x=10:y=10:fontsize=28:fontcolor=white:borderw=2:bordercolor=black,drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf:textfile=/var/aneris-webapp/overlay.txt:reload=1:x=w-tw-10:y=h-th-10:fontsize=28:fontcolor=white:borderw=2:bordercolor=black" -c:v libx264 -preset veryfast -f rtsp -rtsp_transport udp rtsp://127.0.0.1/$MTX_PATH
    runOnInitRestart: yes

Installation

git pull to /opt, then install requirements, then run python -m src before starting mediamtx, the /var/aneris-webapp/overlay.txt file must both exist and be readable/writeable

This application requires a db to store its sensor reads. although the driver for mysql is already present in the requirements.txt file, any SQL dialect can be used so long as its driver is installed, and the DB_URL string in the .env is updated correctly.

The password in install_mysql.sh MUST be changed before running the script, and it must also be added to the .env file's DB_URL string.

a default_config.json file is provided. This file can be modified as necessary, and must be imported using the init_db.py script before the program is first run. to reload these settings, its absolute path can be provided as an environment variable ANERIS_LOAD_CONF. Note that this operation will overwrite the settings stored within the database.

An additional example.env file is provided under the config folder. This must also be configured before the app can be run.

Web interface

A gui is created to allow the user to easily interact with the device once deployed. It is accessible from the device's WAN IP address.

GET /

Renders the index page, showing a video stream, app logs, a chart displaying the last 10 sensor readings, and this README.

GET /video

Allow the user to select a desired video feed, with or without an overlay. The video is shown in a new window.

GET /sensors

Displays recorded sensor data (temperature, pressure, depth) as line graphs. Only the last 10 readings are shown, and the page must be refreshed for the graph to be updated.

GET /docs

Displays the project's README file (i.e. this file) as rendered HTML.

GET /logs

Displays application logs. Can return the full file, the last n lines, or stream logs in real time.

Query Parameters

  • mode (all | tail | follow, default: tail)
  • n (number of lines for tail, default: 50)

Examples

  • /logs?mode=all → streams the entire log file
  • /logs?mode=tail&n=100 → returns the last 100 lines
  • /logs?mode=follow → streams logs as they are appended

Response

  • Plaintext log output.

API

This project exposes a REST API for accessing sensor data, UVC LED control, and logs.

Its base url is http://<host>/api

GET /api

This method returns a JSON of all available endpoints, with their description.

Response

{
  "description": "Aneris Web App API",
  "version": "1.0",
  "endpoints": {
    ...
  }
}

GET /api/temperature

This endpoint returns the current temperature read by the sensor.

Response

{
  "temperature": 12.5
}

GET /api/pressure

This endpoint returns the current pressure read by the sensor.

Response

{
  "pressure": 1.01325
}

GET /api/depth

This endpoint returns the current depth read by the sensor.

Response

{
  "depth": 22.7
}

GET /api/uvc

Returns a boolean indicating whether the UVC LED is enabled.

Response

{
  "status": true
}

POST /api/uvc

Allows to enable or disable the UVC LED service (persists on reboot).

Request Body

{
  "enable": true
}

Response

{
  "success": true,
  "msg": "UVC led enabled"
}

GET /api/logs

This endpoint returns logs in a JSON/JSONL format. By default, the last 50 lines of logs are returned. When streaming the logs (i.e. mode follow), they are returned as JSONL format.

Query Parameters

  • mode (all | tail | follow, default: tail)
  • n (number of lines for tail, default: 50)

Examples

  • /api/logs?mode=all → returns all logs
  • /api/logs?mode=tail&n=100 → returns last 100 lines
  • /api/logs?mode=follow → streams logs (NDJSON format, server-sent)

Response (tail example)

{
  "logs": [
    "2025-09-17 12:00:01 Sensor reading OK",
    "2025-09-17 12:00:02 UVC LED enabled"
  ]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors