Skip to content

MECP (Mesh Emergency Communication Protocol)

Developer reference for MECP compose, alerts, audit log, ALERT_APP ingest, or cross-protocol RF rebroadcast. Repo-wide rules live in AGENTS.md. The operator-facing guide (send, receive, audit log, RF bridge) is ../emcomm.md; keep it in sync when user-visible behavior changes.

Wire format

MECP/<severity>/<codes> [freetext]
  • Protocol adherence: MECP 1.4.1 (MECP_PROTOCOL_VERSION)
  • Severity: 0 MAYDAY, 1 URGENT, 2 SAFETY, 3 ROUTINE
  • Codes: letter + two digits (M01, M16 medical supply drop, M18 stroke, …); drill D01/D02 set isDrill (suppresses alerts; D05 end-of-test does not). Labels come from vendored language packs under languages/. Beacon §B (B01/B02/B03) is semantic-only in the protocol — Incident Command's ACK/confirm/cancel workflow is app policy, not a mandated wire state machine. Private Use U## scopes an optional first-token app designator in freetext (ADR 0006)
  • Max 200 UTF-8 bytes (MAX_MESSAGE_BYTES)
  • Freetext conventions (pax, GPS, Duration/R03, #tag, @lang, @HHMM, ~callsign, Private Use app designator) follow mecp-org/MECP §6.1 patterns vendored under engine/freetext/. Decode claims tokens in fixed order so digits are not double-read (timestamp/GPS before pax/duration). R03 Duration uses min/h/d only (30s is freetext); any positive total with no 1440-minute cap; first unit-bearing match by position wins; unit-bearing values must not be read from digits after a decimal mark (1.5h is not 5 h). @HHMM is the sender's local time (display as sent; no zone on the wire)
  • Vendored engine: src/renderer/lib/mecp/engine/ adapted from mecp-org/mecp-app (GPLv3); freetext decode follows MECP 1.4.1 §6.1 (freetext/patterns.json from mecp-org/MECP tip — strict duration encode without spaces; decode still accepts spaced inbound tokens; decoders strip one trailing CR/LF; claim-order + Private Use designator)
  • Canonical form (§6.6): upstream defines one canonical string per decoded message (codes in ASCII order, conventions in decode order, remainder last) with vectors in freetext/canonical.json (vendored for reference only). mesh-client does not claim canonical encoder output — the compose/incident paths send operator-entered freetext in the order typed (codes in selection order, original token casing/spacing preserved) so the operator's wording survives round-trip. Decode accepts canonical and non-canonical input identically. Adopting canonical emission is a product decision, not a protocol-adherence requirement
  • Language packs: src/renderer/lib/mecp/languages/ from mecp-org/MECP (CC BY 4.0). Shipped packs are those reachable from mecpLanguageForAppLocale (Greek el and other upstream packs without an app UI locale are omitted until a locale is added)
  • Overview / video: mecp.radio
  • App wrappers: mecpMessages.ts (MECP_REGEX, tryParseMecp), mecpAlert.ts, mecpRebroadcast.ts

Receive path

  1. Messages land in messageStore as normal chat text (Meshtastic RF/MQTT, MeshCore, Reticulum).
  2. Meshtastic ALERT_APP (port 11) is decoded like TEXT_MESSAGE_APP in MeshtasticProtocol / MQTT.
  3. useMecpAlertWatcher (mounted once from App.tsx):
  4. Seeds a dedup set at mount (no alert/audit on hydration)
  5. New inbound MECP → durable audit append (mecp:appendReceived)
  6. Alerts: sev 0 'mecpSiren' (~5s six-cycle siren, length-matched to URGENT) + emergency toast; sev 1 US EAS-style 853+960 Hz 'mecpEas' (~5s) + toast (ignore mutes; always including focused chat); sev 2 'mecpSafety' (short–long dit–dah × 6, 1175 Hz square, ~4.4s) / 3 'mecp' repeated rising triple when unmuted; drills never alert
  7. Focused Chat still alerts via ChatPanel → triggerMecpAlert (deduped with the watcher)
  8. Blocked senders (mecpBlockStore, SQLite app_settings.mecpBlockedSenders canonical with localStorage mesh-client:mecpBlockedSenders cache, keyed ${protocol}:${String(msg.from)}, capped at MAX_MECP_BLOCKED_SENDERS): audit append only, with blocked: true. No incident upsert (live or seed), no alert, no rebroadcast (S18). ChatPanel skips its alert for them too. Block from the Incident row (Block alerts, optionally resolving that sender's open rows via blockMecpIncidentSender) or the suppression toast; unblock in App → MECP → Blocked emergency senders
  9. Alert throttle (mecpAlertThrottle.ts): the watcher calls recordMecpAlert once per live non-drill message. More than MECP_ALERT_THROTTLE_MAX (3) alerts from one sender inside MECP_ALERT_THROTTLE_WINDOW_MS (10 min), or MECP_ALERT_FLOOD_MAX_SENDERS (5) other senders inside MECP_ALERT_FLOOD_WINDOW_MS (1 min), silences the tone and toast. The report is still upserted with quiet: true, so the row exists but is created already seen and never drives the standing banner (S19). One notifyMecpAlertsSuppressed toast per window (sender toast offers Block sender). ChatPanel reads isMecpAlertThrottled without counting
  10. Optional RF rebroadcast (§ below)
  11. Upserts eligible MECP into the Incident Command store — see Incident Command. Live: peer reports plus B03/R01/B02 control updates, excluding history, store-and-forward, tapback and invalid severity. Seed (mount snapshot or DB rows): records older than INCIDENT_SEED_MAX_AGE_MS (24h) are dropped before any handling, and new reports honor resolved tombstones. Own traffic is skipped except own B01/B03 beacon control (not via S&F/tapback), so Resolve can send B03. Records stored by the bulk message-store writers (wasMessageBulkLoaded, tracked per stored record object) always take the silent seed path even when hydration lands after mount; a DB row never demotes a live record already in the store
  12. Chat channel/DM chips and the overflow ChatChannelSwitcher (rows + trigger) show a static severity-colored ShieldAlert (MecpUnreadIcon) for the most severe unread MECP in that view (computeUnreadMecpSeverityByView, same watermark as unread counts). The Incident tab badge counts every open Incident-panel row, any severity, drills included (incidentTabBadgeCount, S9); quit confirmation still uses non-drill openMaydayUrgentCount

  13. The TAK relay (takChannelRelay.ts, takDirectMessages.ts) hands a heard report to TAK clients in words via takMecpText.ts: severity, code meanings from the pack for the app's locale (loaded when a TAK sink starts), people, position and leftover free text, with the raw code line below, matching MeshCore TAK Bridge (Mecp.describe in Colorado-Mesh/meshcore-kotlin)

  14. Open incidents with coordinates (the Map's incident layer) go to TAK clients as spot markers: takIncidentMarkers.ts builds the list from the Incident Command store, useTakInboundChat sends it over tak:setIncidentMarkers while a sink is up, and main (incident-cot.ts, TakServerManager.setIncidentMarkers) validates it, writes new or changed markers, deletes resolved ones (a peer's B03 clears the beacon but leaves the incident open), refreshes the rest and sends them to clients that connect. Local clients only
  15. ATAK's emergency alarm (opt-in mecpAlarm in takRelayPrefsStore, off by default): takIncidentMarkers sets a marker's alarm (the sender's name) for an unresolved, positioned, non-drill MAYDAY that is not local-origin, not from a blocked sender (mecpBlockStore, by the id and the protocol the report was first heard on, since a relay keeps the sender's id) and whose beacon has not been cancelled since it last opened. It starts only while the incident is unseen, which leaves out throttled (quiet) and history-seeded incidents, created seen, and keeps sounding once seen until one of the rest stops being true. All the deciding is in the renderer; main keeps only what needs the sockets. parseTakIncidentMarkers refuses alarm on anything but a non-drill MAYDAY, and TakServerManager.setIncidentMarkers, diffing the list as it does for markers, sends b-a-o-tbl to the local clients when a marker gains the field, linked to the marker, and b-a-o-can when it drops it or goes (buildIncidentAlarmCot), as MeshCore TAK Bridge's raiseAlert / cancelAlert do. The alarm is not refreshed: its stale time is INCIDENT_MARKER_STALE_MS (30 minutes) from when it was sent, which bounds an alarm whose cancel never arrives, as when the server stops (no cancel is sent then, as in the bridge). Clients that connect later get the marker only

Default tone shapes and timings: notification-sounds.md — Default MECP tone shapes.

Durable audit log

  • File: mecp-received.log (+ .1 size rotate) under Electron userData — not session mesh-client.log
  • IPC: mecp:appendReceived, mecp:exportReceivedLog (Save dialog)
  • Included only in private developer support bundles; omitted from public-safe GitHub reports
  • App → MECP section: Export MECP log (Save dialog) alongside RF bridge settings and a link to upstream docs
  • Lines from blocked senders carry "blocked": true (validated as optional boolean in isValidMecpAppendPayload)

Spam and full node blocks

  • MECP-only blocks and the throttle are described under Receive path. Node IDs (especially Meshtastic) are spoofable, so blocks stop casual abuse; the throttle covers id-hopping floods.
  • Full LoRa node block: Node Detail Block writes blocked_contacts with protocol = meshtastic / meshcore and the stable scope LORA_BLOCKLIST_SCOPE_ID (lora-blocklist), not the per-connection identity id. blockStore holds one bucket per protocol (byProtocol); App hydrates both LoRa buckets on mount (hydrateLoraBlocklists), useReticulumRuntime hydrates Reticulum. PacketRouter.dispatch drops text_message from a blocked sender before the store write and listeners (isLoraSenderBlocked: Meshtastic decimal node id; MeshCore node id or registered 32-byte pubkey hex), and Meshtastic MQTT ingest checks the same helper. Channel senders known only by a MeshCore display-name stub cannot be matched. Rows already in SQLite are not deleted. Unblock in App → Blocked nodes (LoraBlockedNodesSection)

Send path

  • App → MECP → Show MECP buttons in Chat (default off) gates the Chat MECP compose control
  • When enabled: red Siren (request/report) and blue ShieldCheck (response) buttons in the composer action row (ChatComposer actionSlot, left of Send; hidden in Starred) → MecpComposeModal → encode → sendEmergencyText (emergencySend.ts) → emergency outbox row → immediate drain through useSendMessage (targets the queued DM/channel). Requests open on Drill; responses open on Response. Both default to ROUTINE with no selected codes. Each opening starts a fresh compose session.
  • mecpComposeRoles.ts filters the shared upstream language packs for UI shortcuts: request/report omits R, H and B02; response offers R/H, position, coordination, drills, M14/M15 search results, T10 shelter and B02 beacon acknowledgement. B01/B03 remain with the originator. Show all MECP codes exposes the complete pack without dropping selected codes. These profiles do not add wire fields, fork translations or change received-message severity colors.
  • MeshCore emergency outbox sends use the destination channel’s saved scope and restore the radio-wide default. Retries use the current channel preference; explicit Unscoped stays unscoped even when the radio default is regional.
  • Retry until acknowledged: every report is queued in the chat outbox with priority: 'emergency' and stays there until the network acknowledges it — no 24h drain cutoff, no attempt stop, soft cap of 20 rows (overflow blocks the oldest, never deletes). See emcomm.md — WS2
  • What counts as acknowledged (networkAckAwait.ts awaitNetworkAck), any one of:
  • Meshtastic: device acked (routing ACK on a DM, implicit ACK / rebroadcast heard on a channel) or MQTT publish acked
  • MeshCore: DM ACK (event 130); channel floods need at least one repeater in the heard-repeat window (companion accept alone does not count)
  • Reticulum: LXMF receipt (or remote PN propagated), same as assertReticulumSendAcked
  • Any protocol: another station's R01 echoing our codes (or our severity when it echoes none), a B02 for our B01, or a relayed copy of the same payload (isPeerMecpNetworkAck)
  • Stopping retries: the outbox row shows "Waiting for network acknowledgement…" while a send is in flight and a countdown while backing off. Stop retrying (confirm) aborts any in-flight wait (abortOutboxRowSend in chatOutboxDrain.ts) and deletes the row; the drain does not re-persist a cancelled row.
  • Attach GPS uses the app share-location waterfall (resolveShareLocation), not raw navigator.geolocation alone
  • Meshtastic outbound uses normal text (TEXT_MESSAGE_APP), not ALERT_APP. This is deliberate — see Why not ALERT_APP outbound

Why not ALERT_APP outbound

Evaluated and not planned. Blockers:

  • Firmware rate limit: PhoneAPI.cpp allows one locally-originated ALERT_APP packet per 10s (same rule as POSITION / WAYPOINT / TELEMETRY), versus 2s for text (MESHTASTIC_TEXT_CHUNK_SEND_INTERVAL_MS). An over-limit packet is dropped with only a queue-status reply — no RATE_LIMIT_EXCEEDED routing error — so @meshtastic/core waits for its 60s queue timeout before rejecting.
  • Silent drops look like timeouts: an over-limit ALERT_APP packet never reaches acked, so the emergency outbox would only retry after the network-ACK timeout, burning more of the 10s budget on every attempt.
  • Bursts: tryParseMecp also matches R01 / B02 / B03 ACK and beacon control traffic, and RF rebroadcast (sendMecpRebroadcast.ts) is unpaced, so a MAYDAY followed by an ACK, update, or bridge send within 10s would lose packets.
  • No Store & Forward replay: the S&F server stores only TEXT_MESSAGE_APP.

If ever revisited, it needs at least: a dedicated ≥10s ALERT_APP pacer covering compose, outbox drain, ACK/beacon, and rebroadcast; a send result that re-queues to the emergency outbox on timeout; and a classifier limited to severity 0/1 that excludes R/B control codes and drills.

RF rebroadcast (default off)

  • App → MECP section: rules { enabled, bidirectional, endpointA, endpointB } (Meshtastic/MeshCore channel indices 0–7, or Reticulum LXMF peer / RRC hub+room)
  • One-way A→B by default; Bidirectional toggle enables B→A
  • Trigger: new inbound MECP with receivedVia rf/both (not mqtt-only); skip own/history/drill
  • Reticulum sources: LXMF DMs via messageStore + useMecpAlertWatcher; RRC room msg lines via handleRrcMecpInbound (rrcMecpInbound.ts) because RRC chat lives in rrcSessionStore
  • Loop guard: payload+dest fingerprint TTL
  • After each successful bridge send: short follow-up notice MECP from <sender> via <Meshtastic|MeshCore|Reticulum> (<channel or room name>) (not a wire MECP)
  • Implementation: mecpRebroadcast.ts + sendMecpRebroadcast.ts + rrcMecpInbound.ts

Incident Command

Inbound MECP feeds the always-visible Incident tab (SQLite-backed incidentStore with a preserved localStorage recovery cache, cross-protocol merge, R01 ACK / B02 beacon Confirm, Resolve, map markers). Ops alerts, exports, SAR map tools, and incident track retention are also EMCOMM workstreams. See emcomm.md.

Sound choices and volume are configurable per severity in App → Notifications. Original sounds remain defaults; MAYDAY/URGENT retain mute bypass and a 10% volume floor. See notification-sounds.md.