diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c9db6f6..022e1a4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,12 @@ on: - 'v*' pull_request: +env: + # ONNX Runtime for the Linux jobs. Its Linux downloads from + # github.com/microsoft/onnxruntime currently 404, so tagged Linux AppImages + # ship without image messages until this is set back to "on". + MESHCORE_LINUX_ONNX: "off" + jobs: android: runs-on: ubuntu-latest @@ -71,7 +77,7 @@ jobs: run: | shellcheck scripts/build_appimage.sh scripts/appimage/*.sh scripts/appimage/AppRun bash scripts/appimage/test_packaging.sh - - run: flutter pub get + - run: scripts/onnx.sh "$MESHCORE_LINUX_ONNX" - run: flutter build linux --release --no-pub - uses: docker/setup-buildx-action@v3 - name: Read AppImage base image @@ -141,7 +147,7 @@ jobs: run: | shellcheck scripts/build_appimage.sh scripts/appimage/*.sh scripts/appimage/AppRun bash scripts/appimage/test_packaging.sh - - run: flutter pub get + - run: scripts/onnx.sh "$MESHCORE_LINUX_ONNX" - run: flutter test --reporter expanded - name: Build ARM64 Linux release run: | diff --git a/.github/workflows/flutter_dart.yml b/.github/workflows/flutter_dart.yml index 93fdd230..3ac94bcc 100644 --- a/.github/workflows/flutter_dart.yml +++ b/.github/workflows/flutter_dart.yml @@ -38,3 +38,9 @@ jobs: - name: Run tests run: flutter test -r github + + - name: Analyze and test without ONNX Runtime + run: | + scripts/onnx.sh off + flutter analyze --fatal-infos --fatal-warnings + flutter test -r github diff --git a/.gitignore b/.gitignore index 6e4fb526..43dcc50b 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,6 @@ keystore.properties # Claude Code local working dir (worktrees, jobs, settings) .claude/ + +# Written by scripts/onnx.sh off (ONNX-free build) +/pubspec_overrides.yaml diff --git a/README.md b/README.md index 14d8b142..9c4dcfe4 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,26 @@ The matrix describes implemented functionality, not a guarantee that every featu flutter run ``` +### Building without ONNX Runtime + +ONNX Runtime (ORT) runs only the [image message](documentation/image-messages.md) codec, and every platform build fetches it: Linux and Windows from GitHub releases, Android from Maven Central, iOS and macOS from CocoaPods/SwiftPM. If those downloads fail, build without it: + +```bash +scripts/onnx.sh off # stub flutter_onnxruntime, then flutter pub get +flutter build apk --release # or linux, windows, ios, macos +scripts/onnx.sh on # back to the default build +``` + +`off` writes a git-ignored `pubspec_overrides.yaml` that points `flutter_onnxruntime` at the pure-Dart stub in `third_party/flutter_onnxruntime_stub`, so no native plugin or ORT library is built, downloaded or bundled. On Windows without bash, create that file by hand: + +```yaml +dependency_overrides: + flutter_onnxruntime: + path: third_party/flutter_onnxruntime_stub +``` + +Image messages then behave as on web: the app cannot send them or reconstruct received ones, and Settings says the build has no ONNX Runtime. Everything else is unchanged. While the override is active, `flutter pub get` also rewrites the committed plugin registrants (`linux/`, `windows/`, `macos/Flutter/`); switch back before committing. Linux builds in CI (`.github/workflows/build.yml`) currently use this mode because the ORT Linux release downloads are unavailable. + ### Linux AppImage `flutter build linux --release` produces the regular Flutter bundle and an diff --git a/documentation/README.md b/documentation/README.md index 64533529..41809be7 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -20,7 +20,7 @@ MeshCore Open is an open-source Flutter client for MeshCore LoRa mesh networking 7. [Settings](settings.md) - Device settings, app settings, radio configuration, backup/restore, and exports 8. [Notifications](notifications.md) - System notifications, replies from watches and Android Auto, unread badges, and notification preferences 9. [Repeater Management](repeater-management.md) - Repeater hub, status, CLI, telemetry, and neighbors -10. [Additional Features](additional-features.md) - GIF picker, localization, debug logs, SMAZ compression, and more +10. [Additional Features](additional-features.md) - GIF picker, localization, debug logs, SMAZ and Cyr2Lat compression, and more 11. [Routing Paths](routing-paths.md) - Path encoding, validation, device capability detection, and storage 12. [BLE Protocol & Data Layer](ble-protocol.md) - Technical reference for the communication protocol and data architecture 13. [Regions](regions.md) - App and radio default regions, unscoped sends, message labels, and reply regions @@ -34,6 +34,7 @@ MeshCore Open is an open-source Flutter client for MeshCore LoRa mesh networking 21. [UI Design Reference](design.md) - Contributor reference: theme, typography, spacing, shared widgets, sheets vs dialogs vs pages, states, and localization rules for UI changes 22. [Offline Mode](offline-mode.md) - Read-only view of the last radio's contacts, channels and messages while no radio is connected, and the Connect sheet 23. [Performance Profiling](performance-profiling.md) - Contributor reference: frame and memory baselines, HTTP capture retention, and resetting diagnostic recordings +24. [Chess](games.md) - Play and watch chess games on a channel: invites, challenges, time per move, and how moves are sent and checked ## App Overview @@ -49,6 +50,7 @@ MeshCore Open connects to MeshCore LoRa mesh radios over BLE, USB, or TCP. Once - **Configure radio settings** including frequency, power, bandwidth, and spreading factor - **Cache offline maps** for use without internet connectivity - **Analyze line-of-sight** between nodes with terrain elevation profiles +- **Play chess** on a channel, or watch other people's games - **Filter spam** in channels with your own rules and automatic on-device checks - **Use Android Auto** to hear new messages and reply by voice while driving (Android) diff --git a/documentation/additional-features.md b/documentation/additional-features.md index b160577d..e01949b6 100644 --- a/documentation/additional-features.md +++ b/documentation/additional-features.md @@ -58,21 +58,28 @@ A list of nodes heard passively over the air but not yet added as contacts. Each --- -## SMAZ Compression +## Compression (SMAZ and Cyr2Lat) -### What It Is -An optional per-contact and per-channel text compression feature using the SMAZ algorithm (optimized for short English text). +### Where to Find It +Every open direct-message and channel chat shows **Compression: Off**, **Compression: SMAZ** or **Compression: Cyr2Lat** in a strip just below the app bar, above the messages. Tap it to open one sheet with the three choices and what each does. The choice applies to that contact or channel only and is saved on the phone, so it can be changed while the radio is offline. A channel that has not synced from the radio yet has no saved identity, so the strip is disabled and says why. -### How to Enable -- **Per contact**: Chat screen → overflow menu → Contact Settings → toggle "SMAZ compression" -- **Per channel**: Long-press channel → Edit → toggle "SMAZ compression" +Only one mode is active per chat. Choosing SMAZ turns Cyr2Lat off and the other way round. Off and SMAZ close the sheet once saved; Cyr2Lat keeps it open to show its profile picker. If saving fails, the sheet says so and keeps showing the saved choice. -### How It Works -- When enabled, compression is applied using a "compress only if smaller" strategy — the message is only transmitted compressed if the encoded result is actually shorter than the original. Otherwise, the original text is sent uncompressed -- Compressed messages are transmitted with a `s:` prefix followed by base64-encoded data -- Recipients using MeshCore Open will decompress automatically. **Recipients using other software** that is not SMAZ-aware will see garbled `s:...` text -- The codec operates on ASCII. Non-ASCII / non-English text generally does not benefit from compression and may even expand. Best suited for short English messages -- Disabled by default +### Off +Sends your text exactly as typed. Every app can read it. + +### SMAZ (lossless) +- Compresses with the SMAZ short-text dictionary (optimized for short English text) +- "Compress only if smaller": a message is sent compressed only when the encoded result is shorter. Otherwise the original text is sent, so turning SMAZ on does not compress every message +- Compressed messages are sent as `s:` followed by base64 data. MeshCore Open decodes them back to exactly the original text. **Apps that do not understand SMAZ** show the `s:...` text instead +- The codec works on ASCII. Non-English text rarely benefits and may grow + +### Cyr2Lat (character substitution) +- Replaces some Cyrillic letters with lookalike Latin ones (for example `А→A`, `З→3`, `Ь→b`). Many Cyrillic letters take two bytes in UTF-8 and Latin ones take one, so some Cyrillic messages get shorter +- Not lossless: the exact characters change. Recipients need nothing special to read the result, but copying, searching, names and technical text may behave differently. Your own sent messages appear in the converted form +- The replacements come from a Cyr2Lat profile. Pick the chat's profile in the same sheet; without one, the app-wide profile from App Settings → Cyr2Lat is used. Not useful for English text + +Both are off by default. Settings saved before this selector existed are kept. --- @@ -156,7 +163,7 @@ Maintains an in-memory LRU cache of up to 50 contacts, each with up to 100 route Each route keeps delivery and failure counts that fade over time (half their weight per day, at most 16 recent results). For each send attempt a route is chosen by Thompson sampling over those counts, adjusted slightly for speed and for what the radio currently hears. There are no user-tunable weights. A route is deleted only when it keeps failing and hasn't delivered for a week. Flood deliveries that receive an ACK credit the specific return path. Details: [Auto route selection](routing-paths.md#auto-route-selection). Used internally for: -- **Auto route rotation**: Picks a route for each attempt; retries usually move to a different route, and the last attempt floods +- **Auto route rotation**: Picks a route for each direct attempt; retries usually move to a different route, then the flood attempts run - **Flood statistics**: Tracks flood deliveries and failures --- @@ -167,16 +174,16 @@ Used internally for: Handles reliable delivery of outgoing direct messages: 1. Assigns a UUID and sends immediately. Only one message per contact can be in-flight at a time (avoids overflowing the firmware's 8-entry ACK table); subsequent messages are queued 2. Listens for ACK frames matched via SHA-256 hash of `[timestamp][attempt][text][sender_pubkey]` -3. On timeout, retries with exponential backoff: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s...) -4. Each retry may use a different path (via path history diversity window) -5. After max retries: marks failed but keeps a **30-second grace window** during which a late ACK can still resolve the message to "delivered". Optionally clears the contact's path +3. On timeout, retries with exponential backoff: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s...), capped at 32 seconds +4. Each direct retry may use a different path (via path history diversity window) when auto route rotation is on +5. After the configured direct and flood attempts: marks failed but keeps a **30-second grace window** during which a late ACK can still resolve the message to "delivered". Optionally clears the contact's path 6. Reports RTT and path data for quality learning 7. Maintains an ACK hash history (last 50 entries) to handle duplicate ACKs -### Configurable Settings (App Settings → Messaging) -- Max retries (2–10, default 5) +### Configurable Settings (App Settings → Routing) +- Direct attempts (0–15, default 4) and flood attempts (0–10, default 1), set separately from auto route rotation - Clear path on max retry (on/off) -- Auto route rotation with weight parameters +- Auto route rotation --- diff --git a/documentation/ble-protocol.md b/documentation/ble-protocol.md index 88f83dc3..30fe8bea 100644 --- a/documentation/ble-protocol.md +++ b/documentation/ble-protocol.md @@ -282,3 +282,5 @@ Reactions use `r::`. Channel replies Transport-routed raw packets include four transport-code bytes before packed path metadata. For transport floods, the app matches the first two code bytes against locally known region candidates using HMAC-SHA256 over `[payloadType][payload]`. Region scope keys are the first 16 bytes of SHA256 of `#`. The radio's default flood scope is also a candidate, matched on the key the radio reports (it may have been set by another client). The name itself is not carried as plain text. Unknown or ambiguous matches remain null; see [regions](regions.md). Image chunks use `CMD_SEND_CHANNEL_DATA` (62), `RESP_CODE_CHANNEL_DATA_RECV` (27), and application data type `0xAE1C`. The framing, capacities, metadata byte, and XOR recovery algorithm are defined in [image_chunk_transport.dart](../lib/services/image_chunk_transport.dart), which is the source of truth. See [image messages](image-messages.md) for user requirements and limitations. + +Chess games use the same command and response with data type `0x0100`, which is registered to MeshCore Open in the firmware's `docs/number_allocations.md`. The high nibble of the first payload byte names the app feature (`1` = chess v1), so other games can share the data type. The packet layouts are in [chess_packets.dart](../lib/games/chess/chess_packets.dart) and [games](games.md#how-moves-are-sent). diff --git a/documentation/channels.md b/documentation/channels.md index a8ce6641..6f324f7d 100644 --- a/documentation/channels.md +++ b/documentation/channels.md @@ -61,7 +61,7 @@ Name limits count the `#` and any community prefix, so the name stored on the ra | Action | Description | |---|---| -| Edit | Change name, PSK (with a dice icon to generate a random PSK), SMAZ compression toggle (compresses outgoing messages to allow longer text within the byte limit), Cyr2Lat encoding toggle (transliterates Cyrillic to Latin for compatibility), or "Enable URL images" toggle (previews image links; requires internet) | +| Edit | Change name, PSK (with a dice icon to generate a random PSK), or "Enable URL images" toggle (previews image links; requires internet). Compression is chosen inside the channel chat (see below) | | Mute / Unmute | Toggle push notification suppression for this channel | | Delete | Remove the channel from the device and delete its messages, settings, region and images (confirmation required) | @@ -82,6 +82,10 @@ Tap a channel card to open the channel chat screen. - Overflow menu (⋮) → **Show bookmarks** toggles the channel's bookmarked-message filter; the bookmark icon is filled while active and outlined while inactive. - Overflow menu (⋮) → **Chat background**: a color or picture, with a fade slider, behind this channel only. See [Chat backgrounds](themes.md#chat-backgrounds). Holiday greetings in new messages play a short animation, as in [direct chat](chat-and-messaging.md#message-list) +### Compression Strip + +Below the app bar, above the messages, the same strip as in [direct chats](chat-and-messaging.md#compression-strip) shows and changes this channel's compression: Off, SMAZ or Cyr2Lat. It is stored with the channel's key, so every slot holding that channel shares it, and it can be changed offline. Until the channel has synced from the radio the strip is disabled and says why. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). + ### Message Display - Reverse-scrolling list (newest at bottom) @@ -97,7 +101,7 @@ Messages also show a region label when known, independently of message tracing. ### Message Types in Chat -- **Plain text** with linkified URLs +- **Plain text** with linkified URLs and interactive decimal GPS coordinates (tap to open the **Location** map, long-press for **Copy location** / **Open in maps**; see [Inline GPS Coordinates](chat-and-messaging.md#inline-gps-coordinates)) - **GIFs** (`g:{gifId}`) rendered inline via Giphy CDN - **Location pins** (`m:{lat},{lon}|{label}|`) shown as tappable location cards - **Mesh images** sent as GRP_DATA chunks and reconstructed locally ([setup and limitations](image-messages.md)) @@ -124,7 +128,7 @@ The app bar overflow menu (⋮) has **Filter messages in this channel** (shown w ### Channel Auto-Resend -With **Resend channel messages until they travel far enough** on (App Settings → Messaging), the app waits after each channel send and checks how far the message was heard repeated. If no repeat reached the required hop count, it sends the message again, up to the configured number of times. +With **Resend channel messages until they travel far enough** on (App Settings → Routing), the app waits after each channel send and checks how far the message was heard repeated. If no repeat reached the required hop count, it sends the message again, up to the configured number of times. Where your radio only hears nearby repeaters, turn on **Also count different nearby repeaters**: the message then also counts as sent once the required number of *different* first-hop repeaters have repeated it, across all attempts. Your own radio's echo and zero-hop echoes don't count. @@ -140,6 +144,8 @@ Where your radio only hears nearby repeaters, turn on **Also count different nea | Mark as Unread | Incoming messages only | Marks this message and all subsequent incoming messages as unread | | Delete | All messages | Removes locally (not from mesh) | +Long-pressing directly on a detected GPS coordinate opens the coordinate action sheet (**Copy location** and **Open in maps**) instead of this message menu; long-press non-coordinate text in the message (or right-click on desktop) for channel message actions. + ## Communities Communities are a layer above channels that provide a private namespace. diff --git a/documentation/chat-and-messaging.md b/documentation/chat-and-messaging.md index 53a47331..40826682 100644 --- a/documentation/chat-and-messaging.md +++ b/documentation/chat-and-messaging.md @@ -20,7 +20,11 @@ From the Contacts screen, tap any Chat-type contact to open the ChatScreen. - **Subtitle**: Current routing path label (e.g., "2 hops", "flood (auto)", "direct (forced)") and unread count. Tapping the subtitle shows the full path details. - **Action buttons**: - **Search** (magnifier icon): Replaces the title with a search field and lists every message in this conversation's full history whose text (or translation) contains the typed word, newest first, with matches highlighted. Channel search also matches sender names and skips messages caught by the [message filter](message-filter.md). Back, Esc or the arrow closes search. Channel chats have the same button. - - **Overflow menu** (⋮ icon): Contains Routing, Info, Telemetry, Settings, Chat background, Clear Chat, and Remove from contacts (rooms also have Room Server Management). Routing opens the routing sheet where you can switch between Auto, Direct, and Flood routing and manage recent paths (hop count, round-trip time, age, success count, color-coded by repeater). Info shows a dialog with contact type, path, GPS coordinates, and public key. Chat background sets a color or picture (with a fade slider) behind this chat only; see [Chat backgrounds](themes.md#chat-backgrounds). + - **Overflow menu** (⋮ icon): Contains Routing, Info, Telemetry, Settings (link images and telemetry permissions), Chat background, Clear Chat, and Remove from contacts (rooms also have Room Server Management). Routing opens the routing sheet where you can switch between Auto, Direct, and Flood routing and manage recent paths (hop count, round-trip time, age, success count, color-coded by repeater). Info shows a dialog with contact type, path, GPS coordinates, and public key. Chat background sets a color or picture (with a fade slider) behind this chat only; see [Chat backgrounds](themes.md#chat-backgrounds). + +### Compression Strip + +Below the app bar, above the messages, a strip shows **Compression: Off**, **SMAZ** or **Cyr2Lat** for this contact. Tap it to choose a mode in one sheet that explains each: SMAZ is lossless but needs a SMAZ-aware app on the other end and is only used when it makes a message smaller; Cyr2Lat swaps some Cyrillic letters for lookalike Latin ones, stays readable everywhere, but changes the exact characters, using the chosen Cyr2Lat profile. The setting is saved on the phone and can be changed offline. Channel chats show the same strip. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). ### Message List @@ -31,33 +35,66 @@ From the Contacts screen, tap any Chat-type contact to open the ChatScreen. - **Incoming messages**: Left-aligned, grey background with a colored avatar (initial letter or first emoji of sender name; color is deterministic from a hash of the sender name) - Long-press a message and choose **Bookmark** to show a yellow bookmark on the bubble. **Show bookmarks** in the chat menu toggles a filter for bookmarked messages; use **Bookmarks** in the Channels screen menu to browse saved messages, including those from deleted contacts or channels. From the bookmarks list, copy a message with its copy button. It is ordered oldest-to-newest and opens at the newest message. The Export screen can save or share a dated Markdown file, grouped by contact and then channel, with linked URLs and URL-image embeds. Links remain tappable, and supported URL-image previews are shown when **Load images from links** is enabled in App Settings. - Bubble width capped at 72% of screen width -- Hyperlinks rendered as tappable green underlined text +- Hyperlinks rendered as tappable underlined text; inline decimal GPS coordinates are rendered as bold underlined links (see [Inline GPS Coordinates](#inline-gps-coordinates)) - Message text follows the system font size (Android/iOS accessibility text size); pinch-to-zoom scales on top of it - **Pinch-to-zoom**: Two-finger zoom (0.8x–1.8x) and double-tap to reset - **Jump to bottom**: Floating button appears when scrolled away from the bottom -- **Lazy loading**: Scrolling to top loads older messages from storage. The newest 200 messages are kept in memory; up to 1000 per conversation are kept in storage +- **Lazy loading**: Scrolling to top loads older messages from storage. The newest 200 messages are kept in memory, plus any older pages loaded while the chat is open; up to 1000 per conversation are kept in storage +- **Reading position**: Near the bottom, the chat follows new messages. Scrolled up, it stays on the messages you are reading while new ones arrive below, such as a room's backlog right after login, and never pulls a scroll in progress back to the bottom - **Arrival order**: Messages are ordered by when they arrived on this device, not by the sender's clock. If a message's time is more than 5 minutes in the future, a small clock-warning icon appears next to its time (the sender's clock is probably wrong); tap it for an explanation ### Input Bar -- **Send action button** (left, ⊕ icon): Opens a menu with **Send GIF** (GIF picker bottom sheet) and **Share my location** +The composer is a rounded bubble at the bottom of the chat with one round button beside it. With a chat background set, the bubble floats over the background. + +- **Round button** (right): shows **+** while the field is empty and **Send** once you type. **+** opens the send action menu: **Send GIF** (GIF picker bottom sheet), **Share my location**, **Share contact**, and, when set up, image uploads - **Share my location**: Sends your radio's current position (from the radio, not the phone's GPS) as a location pin. You're asked for a label (default: your node name) before sending; the keyboard's Send key confirms. If the radio reports no usable position (none set, or 0,0), the item is hidden and a snackbar says "Your radio has no location set". Location shares follow the same send cooldown as typed messages and are never sent as a reply. In channel chat the menu also holds **Send low-res image over radio** when image messages are set up -- **Translation button** (optional, between GIF and text field): Shown only when translation is enabled in App Settings. Tap to configure outgoing-message translation language and on/off toggle. -- **Text field** (center): Auto-capitalization, enforces UTF-8 byte limit in real-time -- **Send button** (right): Submits the message +- **Text field**: Auto-capitalization, enforces the UTF-8 byte limit in real time. It grows to five lines (fewer with very large text while the keyboard is open), then scrolls +- **Byte counter**: appears in the bottom-right of the bubble once a message passes 70 % of the limit, and turns red near the limit +- **Translation button** (inside the bubble, right): Shown only when translation is enabled in App Settings. Tap to configure outgoing-message translation language and on/off toggle. +- **Reply preview**: In channel chat, replying shows the quoted message at the top of the bubble with a **✕** to cancel and, when the original had a region, the region chip - On desktop: Enter/Numpad Enter also submits -- When a GIF is selected, the text field shows an inline GIF preview with a dismiss button +- When a GIF is selected, the bubble shows a GIF preview with a remove button; Enter sends it +- With no radio connected, the bubble says so and a **Connect** button takes the place of the round button ## Message Types | Type | Wire Format | Display | |---|---|---| -| Plain text | Raw UTF-8 string | Inline text with link detection | +| Plain text | Raw UTF-8 string | Inline text with URL and decimal coordinate detection | | URL image preview | Image URL in text (per-contact opt-in; requires internet) | Downloaded inline preview | | GIF | `g:` | Inline GIF image from Giphy CDN | | Location pin | `m:,\|