Skip to content

syshlted/mondonode-connector-example

Repository files navigation

MondoNode Connector — Example App

License: MIT

Kotlin Multiplatform example application demonstrating every major feature of the mondonode-connector-sdk across four platforms: Android, Desktop (JVM), iOS, and browser (WasmJS).


What the example demonstrates

Screen What you learn
Connect Build a ConnectorConfig (host, port, TLS fingerprint, client label) and call MondoNodeConnector.create()
Authentication The 3-step EC challenge-response flow — authenticate() → device approval → completeAuthentication()
Pending Polling loop that retries completeAuthentication() every 5 s while the user approves on the device
API Console Call every ApiEndpoint (GET/PUT monitors, plugins, transformers, results, pipeline, storages, …) and inspect the raw JSON response
Live Events Open a WebSocket via connectEvents(), manage subscriptions with SET_SUBSCRIPTIONS, and watch real-time event frames scroll in

The full authentication flow in ConnectViewModel is intentionally minimal (≈80 lines) so you can copy it directly into your own app.


Requirements

Platform Minimum
Android minSdk 26 (Android 8.0 Oreo)
Desktop JVM JVM 17
iOS iOS 14+
WasmJS Modern browser with WebCrypto support

Kotlin 2.0+, Gradle 8.x.


Building and running

Clone the repo, then follow the steps for your target platform.

Android

./gradlew :composeApp:assembleDebug

Install to a connected device or running emulator:

./gradlew :composeApp:installDebug

Desktop (JVM)

./gradlew :composeApp:run

iOS

Requires a Mac with Xcode 15+.

  1. Open iosApp/iosApp.xcodeproj in Xcode.
  2. Select an iPhone simulator or a connected device.
  3. Press Run (⌘R).

No local Mac? See ios-build-services.md for GitHub Actions, Codemagic, and other remote build options.

WasmJS (browser)

./gradlew :composeApp:wasmJsBrowserDevelopmentRun

The task starts a local dev server and prints the URL. Open it in any modern browser. On the first connection to a self-signed MondoNode device you will need to accept the certificate exception in the browser — the WasmJS platform delegates TLS to the browser rather than performing its own fingerprint check.


Project structure

composeApp/
  src/
    commonMain/            Shared Compose UI and ViewModels
      ui/
        ConnectScreen.kt   Connection form
        PendingScreen.kt   Waiting-for-approval screen
        MainScreen.kt      Tabbed container (API Console + Live Events)
        ApiConsoleScreen.kt
        EventsScreen.kt
        AboutDialog.kt
      viewmodel/
        ConnectViewModel.kt   Auth flow and connector lifecycle
        ApiConsoleViewModel.kt
        EventsViewModel.kt
      App.kt               Root composable; routes authState to screens
    androidMain/           Android entry point (MainActivity)
    desktopMain/           Desktop entry point (main.kt)
    iosMain/               iOS entry point (MainViewController)
    wasmJsMain/            Browser entry point (main.kt)
iosApp/                    Xcode project wrapper for iOS

SDK dependency

During local development the SDK is resolved from the sibling ../mondonode-connector-sdk directory via a Gradle composite build:

// settings.gradle.kts
includeBuild("../mondonode-connector-sdk")

To use the published Maven Central release instead, remove that line and add a version:

// composeApp/build.gradle.kts — commonMain
implementation("com.systemhalted.mondonode:mondonode-connector-sdk:<version>")

Check Maven Central for the latest release.


Getting a TLS fingerprint

The SHA-256 fingerprint of the Connector plugin's self-signed certificate is displayed on the plugin's settings screen on the MondoNode device — either as text or as a QR code. Enter it in the TLS Certificate Fingerprint field in the app. Format: colon-separated uppercase hex, e.g. AA:BB:CC:DD:….


License

MIT — see LICENSE.

© 2025 SystemHalted

About

Example application for interacting with the MondoNode REST Connector Plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors