Skip to content

Instantly share code, notes, and snippets.

@LethalMaus
Created January 15, 2026 22:07
Show Gist options
  • Select an option

  • Save LethalMaus/be82b343eec2288e7d1c1dc063dd269a to your computer and use it in GitHub Desktop.

Select an option

Save LethalMaus/be82b343eec2288e7d1c1dc063dd269a to your computer and use it in GitHub Desktop.
publishControl.kt
fun publishControl(controlStatus: ControlStatus) {
_controlStatus.value = controlStatus
scope.launch {
val request = PutDataMapRequest.create(WearPaths.CONTROL).apply {
dataMap.putString(WearKeys.HOLDER, controlStatus.holder.name)
dataMap.putBoolean(WearKeys.EMERGENCY, controlStatus.emergency)
dataMap.putLong(WearKeys.TIMESTAMP, controlStatus.timestamp)
}.asPutDataRequest().setUrgent()
runCatching { dataClient.putDataItem(request).await() }
.onFailure { throwable ->
Log.e(TAG, "Failed to publish control", throwable)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment