1---2name: mqtt-kmp3description: MQTTastic Client KMP — Kotlin Multiplatform MQTT 5.0 client library project knowledge4---56# MQTTastic Client KMP78## Project Facts9- **Language:** Kotlin 2.4.10 (Multiplatform)10- **Build:** Gradle Kotlin DSL, version catalog at `gradle/libs.versions.toml`11- **Targets:** jvm, android, iosArm64, iosSimulatorArm64, macosArm64, linuxX64, linuxArm64, mingwX64, wasmJs12- **Dependencies:** Ktor 3.4.2, kotlinx-coroutines 1.10.2, kotlinx-io-bytestring 0.8.2 (zero external deps beyond these)13- **Protocol:** Full MQTT 5.0 (all 15 packet types, QoS 0/1/2, enhanced auth, topic aliases, flow control)1415## Architecture16- `commonMain` — ALL protocol logic (packets, codec, client, connection, properties)17- `nonWebMain` — TCP + WebSocket transports (ktor-network, ktor-client-websockets)18- `wasmJsMain` — Browser WebSocket transport19- `MqttTransport` — internal interface, sole platform abstraction boundary20- Public API: `MqttClient`, `MqttConfig`, `MqttMessage`, `QoS`, `ConnectionState`, `ReasonCode`, `MqttEndpoint`2122## Key Constraints23- No `java.*`, `android.*`, `platform.*` imports in `commonMain`24- No dependencies beyond Ktor + coroutines + kotlinx-io25- Packet codecs must match OASIS MQTT 5.0 byte-level spec exactly26- All new features need encode/decode round-trip tests27- Code coverage ≥80% enforced via koverVerify28- `spotlessCheck` + `detektAll` + `apiCheck` must pass2930## File Locations31| What | Where |32|------|-------|33| Protocol logic | `library/src/commonMain/kotlin/org/meshtastic/mqtt/` |34| Platform transports | `library/src/nonWebMain/kotlin/`, `library/src/wasmJsMain/kotlin/` |35| Tests | `library/src/commonTest/kotlin/` |36| Build config | `build.gradle.kts`, `gradle/libs.versions.toml` |37| Sample app | `sample/src/commonMain/kotlin/` |38| Agent instructions | `AGENTS.md` (source of truth), `.github/instructions/` |3940## Build Commands41```bash42./gradlew build # full build + test + check43./gradlew allTests # all KMP tests44./gradlew jvmTest # JVM tests only45./gradlew spotlessApply # auto-fix formatting46./gradlew detektAll # static analysis47./gradlew apiCheck # public API compatibility48./gradlew koverVerify # coverage check (≥80%)49```5051## Git Conventions52- Conventional Commits: `<type>(<scope>): <subject>`53- Types: feat, fix, docs, style, refactor, test, chore54- Scopes: packet, transport, client, codec, qos, props, build, ci, deps