Thread Network API not working

I'm trying to use ThreadNetwork API to manage TheradNetworks on device (following this documentation: https://developer.apple.com/documentation/threadnetwork/), but while some functions on THClient work (such as getPreferedNetwork), most don't (storeCredentials, retrieveAllCredentials). When calling these functions I get the following warning/error:


Client: -[THClient getConnectionEntitlementValidity]_block_invoke - Error:

-[THClient storeCredentialsForBorderAgent:activeOperationalDataSet:completion:]_block_invoke:701: - Error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process.}

Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process.}

Failed to store Thread credentials: Couldn’t communicate with a helper application.

STEPS TO REPRODUCE

  1. Create new project

  2. Add Thread Network capability via Xcode UI (com.apple.developer.networking.manage-thread-network-credentials)

  3. Trigger storeCredentials


let extendedMacData = "9483C451DC3E".hexadecimal

let tlvHex = "0e080000000000010000000300001035060004001fffe002083c66f0dc9ef53f1c0708fdb360c72874da9905104094dce45388fd3d3426e992cbf0697b030d474c2d5332302d6e65773030310102250b04106c9f919a4da9b213764fc83f849381080c0402a0f7f8".hexadecimal

// Initialize the THClient

let thClient = THClient()

// Store the credentials

await thClient.storeCredentials(forBorderAgent: extendedMacData!, activeOperationalDataSet: tlvHex!) { error in

if let error = error {

print(error)

print("Failed to store Thread credentials: \(error.localizedDescription)")

} else {

print("Successfully stored Thread credentials")

}

}

NOTES:

  • I tried with first calling getPreferedNetwork to initiate network permission dialog

  • Tried adding meshcop to bojur services

  • Tried with different release and debug build configurations

I'm trying to use ThreadNetwork API to manage TheradNetworks on device (following this documentation: https://developer.apple.com/documentation/threadnetwork/), but while some functions on THClient work (such as getPreferedNetwork), most don't (storeCredentials, retrieveAllCredentials). When calling these functions I get the following warning/error:

A few different questions here:

  • What system are you running on (iOS vs. mac) and is your code running directly in your app or is it in an extension point? If it's in an extension point, I would recommend getting this working properly in the app context first.

  • Is thread itself "working"? For example, do you have a Matter over Thread accessory paired and working in HomeKit?

  • Have you captured a sysdiagnose and look at the failure in the broader console log to see what as logged there?

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Yes, I captured sysdiagnose logs, but I was unable to locate any error or log that would relate to this issue

Please file a bug on this, upload the sysdiagnose there, then post the bug number back here.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thread Network API not working
 
 
Q