mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-09-17 07:41:53 -04:00
The wasmJs web target cannot reach api.meshtastic.org at all. v1 keeps a hardcoded CORS origin allowlist and answers any request carrying an unrecognised Origin with HTTP 500 and the body "Origin not allowed by CORS". A browser sends Origin on every cross-origin request, and localhost is not on the list, so even local development against v1 fails. Verified: meshtastic.org and flasher.meshtastic.org get 200, client.meshtastic.org and http://localhost:8080 get 500, and the OPTIONS preflight is a 500 too. apiv2.meshtastic.org serves access-control-allow-origin: * and a 204 preflight, so the browser target works without any server-side change. Payload parity was checked endpoint by endpoint before switching. All six endpoints the app consumes return 200 with application/json on both hosts: resource/deviceHardware, resource/deviceLinks, github/firmware/list, resource/eventFirmware, resource/bootloaderOtaQuirks and resource/maintenanceUf2. Four are byte-identical; deviceLinks differs only in its generatedAt stamp with all 213 links identical, and github/firmware/list differs by one transient pull-request entry. Both are CDN cache freshness, not shape. The three maintenance UF2 binaries served under resource/maintenanceUf2/asset/ are byte-identical on both hosts and match the sha256 digests the manifest declares, so the digest-verified flash path is unaffected. The timeout and retry constants are left alone. v2 answered every probe in about 0.2s from a Cloudflare cache HIT, but that is no evidence about a cold MISS, and the generous deadline costs nothing given stale-while-revalidate callers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
: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 itsRadioTransportadapter.SerialTransport: JVM-shared USB/Serial transport powered by jSerialComm.BleRadioTransport(radio/): TheRadioTransportimplementation for Bluetooth devices.BaseRadioTransportFactory: Common factory for instantiating the KMP transports.
BLE: the
RadioTransportimplementation (BleRadioTransport) lives here inradio/; it delegates to the lower-level Kable connection primitives (BleConnection,BleScanner,BluetoothRepository, …) provided by:core:ble.BaseRadioTransportFactoryinstantiates it when an address with thex(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;