Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Thread border agent IDs encoded as hex second instance #3838

Merged
merged 3 commits into from
Sep 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class ThreadManagerImpl @Inject constructor(
override suspend fun getPreferredDatasetFromServer(serverId: Int): ThreadDatasetResponse? =
getDatasetsFromServer(serverId)?.firstOrNull { it.preferred }

@OptIn(ExperimentalStdlibApi::class)
override suspend fun importDatasetFromServer(
context: Context,
datasetId: String,
Expand All @@ -172,7 +173,8 @@ class ThreadManagerImpl @Inject constructor(
BORDER_AGENT_ID
}
).toByteArray()
agners marked this conversation as resolved.
Show resolved Hide resolved
val threadBorderAgent = ThreadBorderAgent.newBuilder(borderAgentId).build()
val idAsBytes = borderAgentId.let { if (it.length == 16) it.toByteArray() else it.hexToByteArray() }
val threadBorderAgent = ThreadBorderAgent.newBuilder(idAsBytes).build()
val threadNetworkCredentials = ThreadNetworkCredentials.fromActiveOperationalDataset(tlv)
suspendCoroutine { cont ->
ThreadNetwork.getClient(context).addCredentials(threadBorderAgent, threadNetworkCredentials)
Expand Down