Files
Meshtastic-Android/settings.gradle.kts
James Rich 8b459881e0 feat: integrate meshtastic-sdk POC vertical slice
Wires core flows to the meshtastic-sdk (0.1.0-SNAPSHOT) while keeping the
legacy path alive. Goal: prove the SDK works with a real Android app and
surface API deficiencies.

Build:
- settings.gradle.kts: composite build inclusion for meshtastic-sdk
  (../meshtastic-sdk) with dependency substitution for all SDK artifacts
- libs.versions.toml: sdk = "0.1.0-SNAPSHOT", mavenCentral snapshots repo
- app/build.gradle.kts: sdk-core, sdk-proto, sdk-transport-ble,
  sdk-storage-sqldelight dependencies

Bootstrap:
- MeshUtilApplication: AndroidContextHolder.context set in onCreate()
  before startKoin so SqlDelightStorageProvider can locate app files
- RadioClientProvider (@Single, binds SdkClientLifecycle): mutex-serialized
  rebuildAndConnect(), strips 'x' prefix from BLE devAddr, holds
  RadioClient StateFlow
- RadioClientViewModel: exposes RadioClientProvider to UI layer

SDK ViewModels (POC quality, compile-verified):
- SdkNodeListViewModel: NodeChange.Snapshot/Added/Updated/Removed → UiNode
- SdkMessagingViewModel: sendText() via client.sendText(), incomingText
  via client.textMessages (Gap B — now fixed in SDK)
- SdkConfigViewModel: configBundle reads, setConfig/setOwner writes,
  loadChannels() via admin, Gap G workaround (local override map)
- SdkTelemetryViewModel: TelemetryApi.observe(NodeId), requestDeviceMetrics

Service lifecycle:
- SdkClientLifecycle interface in core:service (avoids reverse dep from
  service → app); RadioClientProvider implements it
- MeshService.onDestroy: calls sdkClientLifecycle.disconnect() before
  serviceJob.cancel()
- BlePeripheralFactory.kt in core:ble: public buildPeripheralForAddress()
  wrapper (Gap F workaround; proper fix needed in SDK transport-ble)

SDK gaps discovered and logged:
  Gap B - textMessages flow (FIXED in SDK feat/meshtastic-android-integration-gaps)
  Gap C - channels StateFlow (no reactive cache, only admin.listChannels())
  Gap F - BleTransport MAC string factory (requires live Peripheral today)
  Gap G - configBundle not refreshed after editSettings writes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-06 17:52:05 -05:00

139 lines
4.4 KiB
Kotlin

/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
pluginManagement {
includeBuild("build-logic")
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver") version "1.0.0"
id("com.gradle.develocity") version "4.4.1"
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.6.0"
}
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
// Only enable mavenLocal for local JitPack testing; never in CI.
if (providers.gradleProperty("useMavenLocal").isPresent) mavenLocal()
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
maven {
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
mavenContent { snapshotsOnly() }
}
maven {
url = uri("https://jitpack.io")
content {
includeGroupByRegex("com\\.github\\..*")
}
}
}
}
rootProject.name = "MeshtasticAndroid"
// meshtastic-sdk composite build — dependency substitution maps published Maven artifacts
// to the local source projects so SDK changes are reflected in this build immediately.
includeBuild("../meshtastic-sdk") {
dependencySubstitution {
substitute(module("org.meshtastic:sdk-proto")).using(project(":proto"))
substitute(module("org.meshtastic:sdk-core")).using(project(":core"))
substitute(module("org.meshtastic:sdk-transport-ble")).using(project(":transport-ble"))
substitute(module("org.meshtastic:sdk-transport-tcp")).using(project(":transport-tcp"))
substitute(module("org.meshtastic:sdk-transport-serial")).using(project(":transport-serial"))
substitute(module("org.meshtastic:sdk-storage-sqldelight")).using(project(":storage-sqldelight"))
substitute(module("org.meshtastic:sdk-testing")).using(project(":testing"))
}
}
// https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:type-safe-project-accessors
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
// Shared Develocity and Build Cache configuration
apply(from = "gradle/develocity.settings.gradle")
@Suppress("UnstableApiUsage")
toolchainManagement {
jvm {
javaRepositories {
repository("foojay") {
resolverClass.set(org.gradle.toolchains.foojay.FoojayToolchainResolver::class.java)
}
}
}
}
// Desktop-only mode: skip Android-only modules when ANDROID_HOME is unavailable (e.g. Flatpak builds).
// Activate via: DESKTOP_ONLY=true ./gradlew :desktop:packageUberJarForCurrentOS
val desktopOnly =
providers.gradleProperty("desktop.only").orNull?.toBoolean() == true ||
System.getenv("DESKTOP_ONLY")?.toBoolean() == true
include(
":core:ble",
":core:common",
":core:data",
":core:database",
":core:datastore",
":core:di",
":core:domain",
":core:model",
":core:navigation",
":core:network",
":core:nfc",
":core:prefs",
":core:proto",
":core:repository",
":core:service",
":core:resources",
":core:takserver",
":core:testing",
":core:ui",
":feature:intro",
":feature:messaging",
":feature:connections",
":feature:map",
":feature:node",
":feature:settings",
":feature:firmware",
":feature:wifi-provision",
":desktop",
)
if (!desktopOnly) {
include(
":app",
":core:api",
":core:barcode",
":feature:widget",
)
}