feat: Add disconnect broadcast and improve app port handling (#4502)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-02-07 16:19:10 -06:00 committed by GitHub
parent a493cf1420
commit 31790ff709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 181 additions and 41 deletions

View file

@ -27,7 +27,7 @@ dependencies {
// Replace 'v2.7.13' with the specific version you need
val meshtasticVersion = "v2.7.13"
// The core AIDL interface
// The core AIDL interface and Intent constants
implementation("com.github.meshtastic.Meshtastic-Android:meshtastic-android-api:$meshtasticVersion")
// Data models (DataPacket, MeshUser, NodeInfo, etc.)
@ -77,15 +77,17 @@ override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
### 3. Register a BroadcastReceiver
To receive packets and status updates, register a `BroadcastReceiver`.
To receive packets and status updates, register a `BroadcastReceiver`. Use `MeshtasticIntent` constants for the actions.
**Important:** On Android 13+ (API 33), you **must** use `RECEIVER_EXPORTED` since you are receiving broadcasts from a different application.
```kotlin
// Using constants from org.meshtastic.core.api.MeshtasticIntent
val intentFilter = IntentFilter().apply {
addAction("com.geeksville.mesh.RECEIVED.TEXT_MESSAGE_APP")
addAction("com.geeksville.mesh.NODE_CHANGE")
addAction("com.geeksville.mesh.CONNECTION_CHANGED")
addAction(MeshtasticIntent.ACTION_RECEIVED_TEXT_MESSAGE_APP)
addAction(MeshtasticIntent.ACTION_NODE_CHANGE)
addAction(MeshtasticIntent.ACTION_CONNECTION_CHANGED)
addAction(MeshtasticIntent.ACTION_MESH_DISCONNECTED)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
@ -97,6 +99,6 @@ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
## Modules
* **`core:api`**: Contains `IMeshService.aidl`.
* **`core:api`**: Contains `IMeshService.aidl` and `MeshtasticIntent`.
* **`core:model`**: Contains Parcelable data classes like `DataPacket`, `MeshUser`, `NodeInfo`.
* **`core:proto`**: Contains the generated Protobuf code (Wire).