Skip to content

About

Encode blog posts and weather requests for transmission via InReach or Winlink

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Signal K Offshore Blogging Plugin

A Signal K plugin for encoding blog posts and weather requests for low-bandwidth satellite transmission via InReach or Winlink. Requires a "cloud server" component running somewhere online for catching and responding to the requests.

Features

  • Blog Post Encoding: Compress Jekyll markdown blog posts into InReach messages

    • Text compression using zlib with optional custom dictionary
    • Image compression to WebP with auto-tuning for message budget
    • CRC-16 checksums for integrity verification
    • Three transmission modes: Text-only (InReach), Text+Image (InReach), Winlink (signed)
  • Weather Request Generator: Generate Saildocs-formatted weather requests

    • Presets for common weather scenarios
    • Message count estimation
  • Chunk Reassembly: Decode received InReach message chunks

    • Verify completeness and CRC integrity
    • Decompress text and display images
    • Support for partial image reception

Installation

Install as a Signal K server plugin:

cd /usr/local/lib/node_modules/signalk-server
npm install ../offshore-blogging-system

Or in development:

cd /path/to/offshore-blogging-system
npm link
cd /usr/local/lib/node_modules/signalk-server
npm link @meri-imperiumi/signalk-offshore-blogging

Configuration

Configure the plugin in Signal K Server settings:

  • Enable blog post encoding: Off by default. Turn on to use the blog post encoding feature (requires a blog directory to be configured). Most users only need the weather/decode tools.
  • Blog sync path: Path where blog posts are synced from mobile devices (used only when blog encoding is enabled)
  • Custom dictionary path: Path to custom compression dictionary file (optional)
  • Default image message budget: Default number of InReach messages for images (1-99)
  • Reticulum identity path: Path to a stored Reticulum identity file for Winlink signing (optional; falls back to the signalk-reticulum plugin's identity)
  • GRIB storage path: Where to persist assembled GRIB files (optional; defaults to <Signal K data dir>/signalk-offshore-blogging/gribs)
  • GRIB source name: Subdirectory name for GRIB files (default: inreach). Configure signalk-grib-weather-provider's rootDirectory to this same path to enable GRIB querying

Cloud Server Environment Variables

The cloud server (node scripts/cloud-server.js running graphs/cloud-server.fbp) reads all deployment config from environment variables via core/ReadEnv nodes — the graph carries no secrets. The mailbox.org IMAP/SMTP hosts and ports are fixed by SPEC.md and wired as literals in the graph, so IMAP_HOST, IMAP_PORT, SMTP_HOST, and SMTP_PORT are not used by the production graph (only the live test runners below read them).

Required — cloud-server.js refuses to start if any is missing:

# Mailbox credentials (IMAP for receiving InReach/Saildocs emails,
# SMTP for sending replies and Saildocs requests)
export IMAP_USERNAME=boat@lille-oe.de
export IMAP_PASSWORD={{ YOUR_PASSWORD }}
export SMTP_USERNAME=boat@lille-oe.de
export SMTP_PASSWORD={{ YOUR_PASSWORD }}

# Paths
export CLOUD_DB_PATH=/home/boat/.offshore-blogging/cloud.db # shared SQLite file
export REPO_PATH=/home/boat/blog-repo                       # local clone of the blog repo
export LOG_PATH=/home/boat/.offshore-blogging/errors.log    # ErrorLogger log file

# InReach reply configuration
export INREACH_REPLY_ADDRESS=cloud@boat.example.com

# Operator alerting (SMTP email for failures)
# Sent via SmtpResponder, NOT through InReachSender (prevents circular failure)
# Fail-open design: alerts on ANY failure that isn't explicitly transient.
#   Known InReach codes: SESSION_EXPIRED, BAD_URL, NOT_CONFIGURED, BAD_RESPONSE → [InReach Alert]
#   Auth/security:       AUTH_DENIED                                        → [AUTH ALERT]
#   Unknown codes:       anything not listed below                          → [UNKNOWN ALERT]
#   No error code:      error with no .code property                        → [ALERT] UNCLASSIFIED
# Suppressed (transient, self-healing): RATE_LIMITED, NETWORK_ERROR, API_FAILURE
# To add a new alert type: set err.code in the source component, wire to AlertComposer
# To suppress a new transient: add its code to TRANSIENT_CODES in AlertComposer.js
# Rate limited: max 1 alert per error code per hour (configurable)
export ALERT_ADDRESS=operator@example.com

Optional:

# Dacar authorization store (operator bootstraps with the `dacar` CLI),
# defaults to ~/.dacar when unset
export DACAR_HOME=~/.dacar
# Explicit path to the `dacar` binary if not on PATH
# export DACAR_BIN=/usr/local/bin/dacar
# Override the graph path (default: graphs/cloud-server.fbp)
# export CLOUD_GRAPH=./graphs/cloud-server.fbp

Live test runners only (scripts/*-runner.js, ignored by the production graph):

# Connection overrides
export IMAP_HOST=imap.mailbox.org
export IMAP_PORT=993
export IMAP_MAILBOX=INBOX
export SMTP_HOST=smtp.mailbox.org
export SMTP_PORT=465

# Device mapping (ping-pong testing only; AuthVerifier uses these instead
# of the inreach_devices SQLite table)
export TEST_DEVICE_ID={{ DEVICE_ID }}
export TEST_IMEI={{ DEVICE_IMEI }}
export TEST_IDENTITY_HASH={{ IDENTITY_HASH }}

Before first boot, the operator must bootstrap the Dacar authorization store on the cloud host. Dacar is decentralized (see work doc #5 §7 for the full model), so two things must be shared out-of-band across every node that will dacar sync together — they cannot be inferred over the network:

  1. The Privacy Salt (Dacar spec §3.3). Object and relation labels are HMAC-SHA256-hashed with this 32-byte salt before they are stored or transmitted, so every node MUST use the same salt or a grant issued on one node won't match a dacar check on another. (dacar init with no --salt generates a fresh random salt per node — fine for a single isolated node, but it makes grants opaque to every other node.) Generate it once and copy it to every node (USB, QR code, LXMF, …):

    openssl rand -hex 32 > dacar-salt.hex           # run ONCE, then distribute
  2. The Root Trust Anchor. dacar init creates the node's own Reticulum identity and records it as a root trust anchor (aliased self). On the node that issues grants, print the anchor so other nodes can trust it:

    dacar identity show                              # prints this node's identity hash

    On every other node that should honor admin-issued grants, trust the anchor before syncing:

    dacar anchor add <admin-identity-hash>

Then, on the cloud host, initialize with the shared salt and bootstrap the grants the cloud server evaluates (DacarAuthorizer shells out to dacar check <identityHash> execute <permission> per inbound message):

dacar init --salt "$(cat dacar-salt.hex)"          # create the store + root trust anchor
dacar grant <identityHash> execute blog:publish
dacar grant <identityHash> execute grib:request
dacar grant <identityHash> execute sys:command

Grants made this way are picked up on the next inbound message — no server restart needed. To converge this node's state with other nodes over Reticulum: dacar sync (and dacar publish --all to flush locally-granted deltas).

These can also be set in a .env file (not committed to git). Minimal set for the production cloud server:

# .env (NOT committed to git) — full annotated version: .env.example
IMAP_USERNAME=boat@lille-oe.de
IMAP_PASSWORD=
SMTP_USERNAME=boat@lille-oe.de
SMTP_PASSWORD=
CLOUD_DB_PATH=/home/boat/.offshore-blogging/cloud.db
REPO_PATH=/home/boat/blog-repo
LOG_PATH=/home/boat/.offshore-blogging/errors.log
INREACH_REPLY_ADDRESS=cloud@boat.example.com
ALERT_ADDRESS=operator@example.com
DACAR_HOME=/home/boat/.dacar

Runner-only variables (IMAP_HOST, SMTP_PORT, TEST_*, SAILDOCS_*, …) can be added to the same file; see .env.example.

Usage

GRIB File Storage and signalk-grib-weather-provider Integration

GRIB files received via InReach are automatically stored in a directory structure compatible with signalk-grib-weather-provider.

  • Default location: <Signal K data dir>/signalk-offshore-blogging/gribs/inreach/
  • Source name: inreach (configurable via plugin settings)
  • File format: <transmissionId>.grb (raw binary GRIB)

To enable weather data querying via the Signal K weather API:

  1. Install signalk-grib-weather-plugin on the same Signal K server
  2. Configure its Root directory to point to the GRIB storage path:
    • Default: ~/.signalk/signalk-offshore-blogging/gribs/
  3. The plugin will automatically discover GRIBs in the inreach/ subdirectory
  4. GRIBs will be indexed and cached for efficient querying

The weather plugin will:

  • Scan the directory periodically (default: every 5 minutes)
  • Ingest new GRIB files into .gribcache format for fast position queries
  • Make weather data available via Signal K's /resources/weather API
  • Support point, daily, and hourly forecast queries

Note: The offshore blogging plugin handles downlink GRIBs (cloud→boat) received via InReach. The weather plugin handles querying those GRIBs at specific positions for display in chart plotters and other applications.

To change the source name or storage location, configure these plugin settings:

  • GRIB storage path: Base directory for GRIB storage
  • GRIB source name: Subdirectory name (becomes the provider ID in weather plugin)

Web Interface

Access the plugin at http://localhost:3000/plugins/signalk-offshore-blogging/

Blog Post Tab

  1. Enter a filename (e.g., "2026-08-07" for 2026-08-07.md)
  2. Optionally set a Post ID (4 characters like MMDD, defaults to today's date)
  3. Set the image message budget (how many messages to spend on each photo)
  4. Click "Encode Post"
  5. The plugin will automatically find images referenced in the markdown
  6. Choose the transmission version:
    • Text Only (InReach): Copy messages to Garmin Messenger. Markdown image tags are stripped from the body to save message budget.
    • Text + Image (InReach): Includes compressed photo(s). The full body (with image markdown retained so the server knows where to place images) is sent alongside the image chunks.
    • Winlink (Signed): Attach markdown to Winlink message

Copied chunks are marked with a green accent and a ✓ so you can keep track of what you have already sent. You can still copy an already-copied chunk again (e.g. if the server requests it again), and a "Reset copied markers" button clears the markers for the visible messages.

Images are automatically detected from markdown ![alt](path) syntax and resolved relative to the blog directory.

Weather Request Tab

  1. Select a preset or enter a custom Saildocs request
  2. Click "Generate Request"
  3. Copy and send via InReach

Format: model:lat1,lat2,lon1,lon2|grid|hours|parameters

Example: gfs:24n,34n,72w,60w|2,2|12,24,36,48|wind

Decode GRIB Tab

  1. Paste received InReach messages one at a time
  2. Click "Add Chunk" for each message
  3. Click "Reassemble" to decode the complete transmission

Message Format

The plugin uses the same message format as the Python reference implementation:

<postid:4><type:1><idx:2><total:2><crc:4>:<base64 data>
  • postid: 4-character post identifier (e.g., "0805")
  • type: "T" for text, "I" for image
  • idx: Chunk index (01-99)
  • total: Total chunks (01-99)
  • crc: 16-bit CRC of the original data (hex)
  • data: Base64-encoded compressed data

Message limit: 155 characters (to stay under Garmin's ~160 char limit)

Note on Encoding: The plugin uses base64 encoding instead of the denser base85. This is because Garmin's character counting rules penalize certain characters (backtick, ^, {, |, }, ~) that appear in base85's alphabet. Using base64 (A-Za-z0-9+/=) ensures all characters are confirmed 1-char-safe by Garmin's published tables, avoiding unpredictable message costs.

Development

Running Tests

npm test

Live E2E Test Scripts

The scripts/ directory contains end-to-end test runners that communicate with real services over IMAP/SMTP. They require the cloud-server environment variables (see above) and should be run from the project root.

Ping-Pong Runner (InReach)

node scripts/ping-pong-runner.js

Polls IMAP for a PING message from an InReach device and replies with PONG via the InReach HTTP API.

Saildocs Runner (Weather GRIB)

node scripts/saildocs-runner.js

Sends a real weather-GRIB request to Saildocs (query@saildocs.com) via SMTP, then polls IMAP for the response. Validates the reply — a GRIB file attachment (binary, magic bytes GRIB) or an error/text message. Override the default query and timing with environment variables:

# Small Baltic wind request (default)
SAILDOCS_QUERY="gfs:58n,60n,018e,022e|2,2|0,12|wind" \
  POLL_INTERVAL=30000 TIMEOUT=600000 \
  node scripts/saildocs-runner.js
Variable Default Description
SAILDOCS_QUERY gfs:58n,60n,018e,022e|2,2|0,12|wind Saildocs query string
SAILDOCS_EMAIL query@saildocs.com Saildocs query address
POLL_INTERVAL 30000 IMAP poll interval (ms)
TIMEOUT 600000 Overall timeout (ms, default 10 min)

Project Structure

.
├── plugin/
│   └── index.js          # Main plugin code with encoding/decoding
├── public/
│   ├── index.html        # Web interface
│   └── app.js            # Frontend logic
├── components/            # NoFlo flow-based components
│   ├── GribFetcher.js     # Saildocs GRIB request builder
│   ├── ImapFetcher.js     # IMAP polling for incoming emails
│   ├── SmtpResponder.js   # SMTP sender for replies & Saildocs requests
│   └── ...                # Auth, routing, InReach, etc.
├── lib/
│   ├── SmtpClient.js      # Minimal SMTP client (TLS, STARTTLS, AUTH PLAIN)
│   └── DbHelper.js        # SQLite state management
├── scripts/
│   ├── ping-pong-runner.js  # InReach PING→PONG live test
│   └── saildocs-runner.js   # Saildocs GRIB live test
├── test/                  # Unit and integration tests
└── package.json

Dependencies

  • @reticulum/core: Reticulum Ed25519 signing (for Winlink)
  • sharp: Image compression to WebP
  • node:zlib: Built-in zlib for compression
  • base64: Built-in Node.js base64 encoding (Garmin-safe)

License

EUPL-1.2

References

Scripts

generate-dictionary

Generate a zlib dictionary from Markdown blog posts:

node scripts/generate-dictionary.js <blog-directory> [output-file]

Examples:

  • Output to stdout: node scripts/generate-dictionary.js ./blogposts
  • Write to file: node scripts/generate-dictionary.js ./blogposts custom-dict.txt

This script creates a dictionary containing:

  • Front matter from all posts (title, date, tags, slug, etc.)
  • Body content from all posts
  • Common sailing/weather vocabulary

The dictionary is optional for BlogDecoder - it only improves compression when used.

About

Encode blog posts and weather requests for transmission via InReach or Winlink

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages