{"id":20677362,"url":"https://github.com/operatorfoundation/transmissionandroid","last_synced_at":"2026-05-09T20:04:45.208Z","repository":{"id":42562954,"uuid":"460229468","full_name":"OperatorFoundation/TransmissionAndroid","owner":"OperatorFoundation","description":"A Kotlin implemetation of the Transmission library.","archived":false,"fork":false,"pushed_at":"2024-02-28T19:25:17.000Z","size":159,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-17T14:57:29.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OperatorFoundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-17T00:48:03.000Z","updated_at":"2024-01-14T12:46:53.000Z","dependencies_parsed_at":"2024-01-23T20:48:43.725Z","dependency_job_id":"5059737c-f09a-4e02-aa3c-89b41add0b92","html_url":"https://github.com/OperatorFoundation/TransmissionAndroid","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FTransmissionAndroid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FTransmissionAndroid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FTransmissionAndroid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OperatorFoundation%2FTransmissionAndroid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OperatorFoundation","download_url":"https://codeload.github.com/OperatorFoundation/TransmissionAndroid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242907669,"owners_count":20205053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T21:15:22.080Z","updated_at":"2026-05-09T20:04:45.202Z","avatar_url":"https://github.com/OperatorFoundation.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TransmissionAndroid\nAn Android library for reliable serial communication with microcontrollers over USB. Provides both simple byte-level communication and length-prefixed protocols for robust data exchange.\n\n# TransmissionAndroid\n\nA Kotlin library for USB serial communication with microcontrollers on Android devices.\n\n## Features\n\n- **USB Serial Communication**: Direct communication with Arduino, ESP32, FeatherM4, and other microcontrollers\n- **Modern Android APIs**: Uses contemporary permission handling and Kotlin coroutines\n- **Automatic Permission Management**: Streamlined USB permission requests\n- **Multiple Connection Types**: Supports both USB serial and network (TCP/UDP) connections\n- **Reactive State Management**: StateFlow-based connection state updates\n\n## Requirements\n\n- Android API 21+ (Android 5.0)\n- USB OTG support on Android device\n- Kotlin/Java project\n\n## Dependencies\n\nAdd to your `build.gradle` (app level):\n\n```gradle\ndependencies {\n    implementation 'com.github.mik3y:usb-serial-for-android:3.4.6'\n    implementation 'com.jakewharton.timber:timber:5.0.1' // Optional: for logging\n}\n```\n\n## Basic Usage\n\n### 1. Create Connection Factory\n\n```kotlin\nval connectionFactory = SerialConnectionFactory(this) // Activity context\n```\n\n### 2. Find and Connect to Device\n\n```kotlin\nclass MainActivity : ComponentActivity() {\n    private lateinit var connectionFactory: SerialConnectionFactory\n    private var currentConnection: SerialConnection? = null\n    \n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        \n        connectionFactory = SerialConnectionFactory(this)\n        \n        // Find available devices\n        val devices = connectionFactory.findAvailableDevices()\n        \n        if (devices.isNotEmpty()) {\n            connectToDevice(devices.first())\n        }\n    }\n    \n    private fun connectToDevice(driver: UsbSerialDriver) {\n        lifecycleScope.launch {\n            connectionFactory.createConnection(driver.device).collect { state -\u003e\n                when (state) {\n                    is SerialConnectionFactory.ConnectionState.Connected -\u003e {\n                        currentConnection = state.connection\n                        startCommunication()\n                    }\n                    is SerialConnectionFactory.ConnectionState.Error -\u003e {\n                        Log.e(\"Serial\", \"Connection failed: ${state.message}\")\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\n### 3. Send and Receive Data\n\n```kotlin\n// Send data\nprivate fun sendCommand(command: String) {\n    lifecycleScope.launch(Dispatchers.IO) {\n        currentConnection?.write(command)\n    }\n}\n\n// Read data\nprivate fun startCommunication() {\n    lifecycleScope.launch(Dispatchers.IO) {\n        val connection = currentConnection ?: return@launch\n        \n        while (currentConnection != null) {\n            val data = connection.readAvailable()\n            if (data != null \u0026\u0026 data.isNotEmpty()) {\n                val message = String(data)\n                Log.d(\"Serial\", \"Received: $message\")\n            }\n            delay(10)\n        }\n    }\n}\n```\n\n### 4. Disconnect\n\n```kotlin\noverride fun onDestroy() {\n    super.onDestroy()\n    currentConnection?.close()\n    connectionFactory.disconnect()\n}\n```\n\n## Connection States\n\nThe library provides reactive connection state updates:\n\n- `Disconnected` - No active connection\n- `RequestingPermission` - Requesting USB permission from user\n- `Connecting` - Establishing connection\n- `Connected` - Ready for communication\n- `Error` - Connection failed with error message\n\n## Supported Devices\n\n### Tested\n- Adafruit Feather M4\n- \n### Theoretical\n- Arduino boards (Uno, Nano, Mega, etc.)\n- ESP32 and ESP8266 development boards\n- Any device using common USB-to-serial chips (FTDI, CH340, CP210x, etc.)\n\n## Demo Application\n\nSee the included demo app for a complete example showing:\n- Device discovery and connection\n- Permission handling\n- Real-time data exchange\n- Connection state management\n\n## License\n\nMIT License\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Submit a pull request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperatorfoundation%2Ftransmissionandroid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foperatorfoundation%2Ftransmissionandroid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperatorfoundation%2Ftransmissionandroid/lists"}