Plugins for the Inmarsat Decoder – developer guide

Plugin API version 1 · script language Rhai (https://rhai.rs/book/)

A plugin gets every decoded Inmarsat message (STD-C, Classic Aero) and every position taken from them. It can show text and tables in the 🔌 Plugins tab, put markers on the map, write files into its own folder and send data to internet addresses. What it may do is declared in plugin.json; the user confirms these permissions when switching the plugin on.

Examples to learn from: plugins/examples/ (CSV export, webhook, distress alarm). The app installs them with ⚙ Settings → 🔌 Plugins → 📦 Install example plugins. (The code examples below use German names – they work exactly as shown.)


1. Layout

mein-plugin/
├── plugin.json   Beschreibung, Berechtigungen, Einstellungen   (Pflicht)
├── main.rhai     der Code                                      (Pflicht)
├── README.md     wird in der App unter „📄 Beschreibung“ gezeigt (optional)
└── data/         legt die App an: Dateien und Speicher des Plugins

A plugin is passed on as an .inmplugin – a ZIP file with these files (directly or in a single sub-folder). At most 20 MB.

plugin.json

{
  "id": "de.beispiel.mein-plugin",
  "name": "Mein Plugin",
  "version": "1.0.0",
  "author": "Name",
  "description": "Ein Satz, was es tut – steht im Bestätigungsfenster.",
  "api": 1,
  "events": ["message", "position", "status"],
  "permissions": ["files"],
  "timer": 0,
  "settings": [
    { "key": "datei", "label": "Dateiname", "type": "text", "default": "log.txt" },
    { "key": "nur_acars", "label": "Nur ACARS", "type": "bool", "default": false },
    { "key": "grenze", "label": "Mindest-Priorität", "type": "number", "default": 2 },
    { "key": "art", "label": "Format", "type": "choice", "default": "kurz", "options": ["kurz", "lang"] }
  ]
}
FieldMeaning
idunique, only letters, digits, . _ - (best a reversed domain). Also the folder name.
apimust be 1
eventswhich events the plugin gets: message, position, status. Empty = all.
permissionsnetwork, files, map, station (see below). Unknown values → the plugin does not start.
timeron_timer() every N seconds (0 = never)
settingsthe app builds the settings form from it. Types text, number, bool, choice (with options).

A plugin draws no interface of its own – output goes through show() and table().


2. Events (functions in main.rhai)

All are optional; the app only calls what exists.

Functionwhen
fn on_start(settings)at start and after every change of the settings (the plugin is then restarted)
fn on_message(msg)every decoded message
fn on_position(pos)every position (from ADS-C, ACARS text, STD-C text)
fn on_status(st)decoder started / stopped: st.running, st.decoder ("stdc"/"aero"), st.freq_hz
fn on_timer()every timer seconds
fn on_http(id, status, body)answer to http_post / http_get (status −1 = network error)
fn on_stop()the plugin is switched off / the app ends

Code outside the functions runs once when loading. State between calls belongs in this (a map the app keeps), permanently across app restarts in store_set / store_get:

fn on_start(settings) { this.zaehler = 0; }
fn on_message(msg)    { this.zaehler += 1; show(`${this.zaehler} Meldungen`); }

msg – a message

Common: time (ISO 8601 with time zone), freq_hz (integer), type, text, positions (array of positions, often empty).

typefurther fields
"acars"rate (600/1200/10500), aes (hex, 6 characters), ges (hex), reg (registration), flight (flight number, may be empty), label (e.g. "H1", "B6"), block, mode, kind ("", "ADS-C", "CPDLC")
"aero_data"rate, aes, ges – other payload of an aircraft
"egc"service (e.g. “NAVAREA / METAREA warning”), priority (0 routine, 1 safety, 2 urgency, 3 distress), id (hex), cont (true = continuation, text then holds the whole message)
"ship_msg"lcn (logical channel) – STD-C message to a ship

Example:

{ "type": "acars", "time": "2026-11-19T18:22:57+01:00", "freq_hz": 1545150000,
  "rate": 1200, "aes": "3C6586", "ges": "82", "reg": "D-ABYT", "flight": "LH0402",
  "label": "H1", "block": "1", "mode": "2", "kind": "",
  "text": "M02ALH0402/POS N5002.1E00834.6 FL380",
  "positions": [ { "id": "D-ABYT", "kind": "aircraft", "name": "LH0402 · D-ABYT",
                   "lat": 50.035, "lon": 8.5767, "alt_ft": 38000, "source": "ACARS" } ] }

pos – a position

id, kind ("aircraft", "ship", "spot" = a place named in a warning), name, lat, lon, alt_ft (or ()), source ("ADS-C", "ACARS", "EGC", "STD-C", "Aero").


3. Functions of the app

FunctionPermission
show(text) / print(text)–line in the 🔌 Plugins tab (the last 500)
table(#{ "column": value, … })–table row in the 🔌 Plugins tab (max. 12 columns, the last 500 rows)
columns([ "column", … ])–fixed order of the table columns (otherwise alphabetical); other keys are not shown
log(text)–line in the app’s debug log
cfg(key)–setting as text (bool → "true"/"false")
now() / now_utc()–local time ISO 8601 / UTC "2026-11-19 17:22:57"
json(value) / parse_json(text)–Rhai value ↔ JSON text
store_get(key) / store_set(key, value)–small permanent store (data/store.json, max. 1000 keys / 1 MB); () when missing
file_append(name, text) / file_write(name, text)filesfile in data/ (name only letters, digits, . _ - space; max. 50 MB)
marker(id, lat, lon, label)mapmarker on the map (same id = move it)
http_post(url, body) / http_post(url, body, content_type) / http_get(url)networkin the background, returns a number at once (−1 = queue full); answer via on_http. At most 1 request/s, 20 waiting, 10 s timeout, answer max. 1 MB.
station()stationown location #{ lat, lon } or ()

A call without the permission raises an error (see 4).


4. Limits and errors

  • Every plugin runs in a thread of its own. The decoders never wait for a plugin; with more than 256 events pending, new ones for that plugin are dropped (counter “dropped”).
  • Per call at most 2 s and 2 million Rhai operations; strings max. 1 MB, arrays / maps max. 20 000 entries, call depth 32. eval is blocked.
  • Every error (run-time error, limit, missing permission) appears as “⚠ …” in the tab and in the debug log. After 5 errors the plugin is switched off (“⛔”); “↻ Restart” or switching it off and on starts it again.
  • No access to receivers, frequencies, other plugins, the file system outside data/ or the network without permission.

5. Installing

  • File: copy the .inmplugin (or the plugin folder) into the app’s Plugins/ folder – Android: Android/data/eu.medienwerk.inmarsat/files/Plugins/ (USB or file manager) –, then 🔄 Re-read.
  • Address: 🌐 From address – type https://…/plugin.inmplugin, 📥 Load.
  • Switch it on with the tick → the app shows description and permissions → Allow.
  • An update (same id) replaces the files, data/ is kept.

Plugins are not signed; the app points this out when you switch one on.


6. Testing on a computer

With the desktop program (cargo build --release, program target/release/inmarsat):

inmarsat --plugin-test plugins/examples/seenot-alarm
inmarsat --plugin-test mein-plugin meldungen.jsonl
inmarsat --plugin-test plugins/examples/webhook --set url=https://ntfy.sh/test --set format="Text (ntfy)"

Without a file, five built-in sample messages run through (ACARS with position, ADS-C, EGC gale warning, EGC distress with position, ship message). All permissions of the plugin apply; HTTP requests are not sent, only shown; on_http gets status 200. Output: lines, table, markers, errors, run times. Plugin settings with --set key=value. Exit code 0 = no errors.

Real messages for testing: in the app switch on ⚙ Settings → Display and sound → Record messages as JSONL. Every message then becomes a line in messages-<date>.jsonl in the app folder – exactly what on_message gets.


7. A complete small plugin

plugin.json:

{ "id": "de.beispiel.zaehler", "name": "Zähler", "version": "1.0.0", "author": "Ich",
  "description": "Zählt Meldungen pro Flugzeug.", "api": 1, "events": ["message"],
  "permissions": [], "timer": 60 }

main.rhai (counts messages per aircraft; je_flugzeug = “per aircraft”):

fn on_start(settings) {
    this.je_flugzeug = #{};
}

fn on_message(msg) {
    if msg.type != "acars" { return; }
    let k = if msg.reg != "" { msg.reg } else { msg.aes };
    let n = this.je_flugzeug[k] ?? 0;
    this.je_flugzeug[k] = n + 1;
}

fn on_timer() {
    for k in this.je_flugzeug.keys() {
        table(#{ "Zeit": now_utc(), "Flugzeug": k, "Meldungen": this.je_flugzeug[k] });
    }
}