mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-06-01 10:39:00 -04:00
2.9 KiB
2.9 KiB
title, parent, nav_order, last_updated, aliases
| title | parent | nav_order | last_updated | aliases | ||||
|---|---|---|---|---|---|---|---|---|
| Transport | Developer Guide | 5 | 2026-05-13 |
|
Transport
Meshtastic communicates between the app and radio hardware through multiple transport mechanisms.
Transport Abstraction
The transport layer is abstracted through interfaces in core/network and core/ble, allowing the app to work identically regardless of the underlying connection type.
App ← RadioController → Transport (BLE | Serial | TCP)
Bluetooth Low Energy (BLE)
Module: core:ble
Platforms: Android, Desktop (JVM via Kable), iOS (planned)
The primary transport for mobile devices and also available on desktop:
- Service discovery for Meshtastic GATT services
- Characteristic-based read/write for protobuf packets
- Connection state management and automatic reconnection
- MTU negotiation for optimal packet sizes
Key Classes
core/ble/— BLE scanning, connection, and GATT operations- Platform-specific implementations in
androidMainandjvmMain(Kable)
USB Serial
Module: core:network
Platforms: Android (OTG), Desktop
Serial communication over USB:
- Uses
usb-serial-for-androidlibrary on Android - Direct serial port access on Desktop (JVM)
- Probe table for supported USB vendor/product IDs
- Automatic detection when USB device is connected
Key Classes
- Serial prober and transport factory in
core/network - Desktop-specific serial in
desktopApp/src/main/kotlin/.../radio/
TCP/IP
Module: core:network
Platforms: Android, Desktop, iOS
Network-based transport for WiFi-enabled radios:
- TCP socket connection to radio's IP address
- Default port: 4403
- Used for development with simulated radios
- Available when BLE/USB is impractical
Transport Factory
The RadioTransportFactory interface abstracts transport creation:
interface RadioTransportFactory {
val supportedDeviceTypes: List<DeviceType>
fun createTransport(address: String, service: RadioInterfaceService): RadioTransport
fun isMockTransport(): Boolean
fun isAddressValid(address: String?): Boolean
fun toInterfaceAddress(interfaceId: InterfaceId, rest: String): String
}
Platform-specific implementations:
- Android: Supports BLE + USB + TCP
- Desktop: Supports BLE (Kable) + USB + TCP
- iOS: Planned BLE + TCP
Connection Lifecycle
- Discovery — Scan for available radios (BLE scan / USB detect / manual TCP)
- Connection — Establish link to selected radio
- Handshake — Exchange node info and configuration
- Active — Normal message exchange
- Disconnection — Clean teardown or error recovery
Adding a New Transport
- Implement
RadioTransportinterface - Register in platform-specific
RadioTransportFactory - Add connection UI in
feature:connections - Update DI bindings for the platform