Files
Meshtastic-Android/core/network
James RichandClaude Sonnet 5 58d1d5068c feat(data): enable wasmJs, exposing mqttTransportFactory from core:network
core:data ties together core:database, core:datastore, core:di,
core:model, core:network, core:prefs, core:repository (all already
wasmJs-enabled), core:takserver (out of scope, relocated below), and
Room -- the last of which turned out to be the real blocker.

core:takserver's dependency moves to nonWebMain-only: a grep pass
confirmed core:data's own commonMain never actually references
org.meshtastic.tak (the only "TAK" substring matches were the
unrelated PortNum.ATAK_PLUGIN protobuf constant and a code comment),
so this is a mechanical relocation, not a port -- core:takserver
itself stays out of scope (niche ATAK feature).

MqttManagerImpl.kt duplicated the exact TCP+WS transport composition
core:network's MqttTransportSelection.kt already solved for
MQTTRepositoryImpl. Rather than duplicate the platform-selection
logic (and its TCP-exclusion reasoning) a second time, core:network's
mqttTransportFactory drops its `internal` modifier and becomes public;
MqttManagerImpl.kt's one-off probe client now calls it directly.

The real, unpredicted blocker: core:database exposes Room only as
`implementation` in its own commonMain, so RoomDatabase -- the
supertype of MeshtasticDatabase that core:data's repositories reach
through DatabaseProvider -- isn't visible to external consumers on
wasmJs. This never surfaced on android/jvm/iOS because core:data's
own jvmAndroidMain already carries the identical redundant Room
redeclaration, for the same reason, pre-dating this session. Fixed
with a matching wasmJsMain dependency on
androidx.room.runtime/androidx.room.paging (both confirmed to publish
real wasmJs variants; sqlite-bundled stays excluded, native-only and
unrelated to RoomDatabase itself). core:database's own
implementation-vs-api Room exposure would be a cleaner long-term fix
but is out of this pass's scope since nothing else currently needs it.

14 of core:data's 33 commonTest files -- the ones that actually import
core:testing (core:testing itself has no wasmJs target, same gap
core:ble/core:database/core:network hit) -- move to a new nonWebTest
source set; confirmed empirically that core:data's own
compileTestKotlinWasmJs task genuinely needs every commonTest
dependency to resolve, even with no browser()/nodejs() test executor
configured -- this is a real compile-time constraint on every module,
not something a bare wasmJs() sidesteps by omission.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-30 23:12:35 -05:00
..

:core:network

Overview

The :core:network module handles all internet-based communication, including fetching firmware metadata, device hardware definitions, and map tiles (in the fdroid flavor). It also provides the shared radio transport layer (TcpTransport/TcpRadioTransport, SerialTransport, BleRadioTransport).

Key Components

1. Ktor Client

The module uses Ktor as its primary HTTP client for high-performance, asynchronous networking.

2. Remote Data Sources

  • FirmwareReleaseRemoteDataSource: Fetches the latest firmware versions from GitHub or Meshtastic's metadata servers.
  • DeviceHardwareRemoteDataSource: Fetches definitions for supported Meshtastic hardware devices.

3. Shared Transports

  • TcpTransport (transport/) + TcpRadioTransport (radio/): Multiplatform TCP transport and its RadioTransport adapter.
  • SerialTransport: JVM-shared USB/Serial transport powered by jSerialComm.
  • BleRadioTransport (radio/): The RadioTransport implementation for Bluetooth devices.
  • BaseRadioTransportFactory: Common factory for instantiating the KMP transports.

BLE: the RadioTransport implementation (BleRadioTransport) lives here in radio/; it delegates to the lower-level Kable connection primitives (BleConnection, BleScanner, BluetoothRepository, …) provided by :core:ble. BaseRadioTransportFactory instantiates it when an address with the x (or !) prefix is resolved.

Dependency Graph

graph TB
  :core:network[network]:::kmp-library
  :core:network --> :core:repository
  :core:network -.-> :core:common
  :core:network -.-> :core:di
  :core:network -.-> :core:model
  :core:network -.-> :core:ble
  :core:network -.-> :core:testing

classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-application-compose fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef compose-desktop-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-library-compose fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000;
classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library-compose fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000;