How use MatterSupport to commission a thread device?

Hi, When I would like to use MatterAddDeviceRequest to commission a thread device, I will get error "Error Domain=HMErrorDomain Code=18 "Pairing Failed" UserInfo={NSLocalizedDescription=Pairing Failed, NSUnderlyingError=0x282786e20 {Error Domain=HAPErrorDomain Code=15 "(null)"}}".

As checking logs, I found App will always get fail to store thread credential (-[THClient storeCredentialsForBorderAgent:activeOperationalDataSet:completion:]_block_invoke:646: - Response: Error Domain=ThreadCredentialsStore Code=1 "Backing store is nil..." UserInfo={NSLocalizedDescription=<private>}) so that I will also get error "CHIP Accessory Server failed to obtain Thread credentials for selected extended PAN ID... Error: (null)" in following.

Logs:

error	17:59:05.713433+0800	CoreThreadCommissionerServiced	ThreadCommissioningService is Enabled
error	17:59:05.713597+0800	CoreThreadCommissionerServiced	Server: -[CTCSXPCService checkEntitlements:connection:] - Entitlement Check is successful for the key : <private>
error	17:59:05.714183+0800	MatterExtension	                Client: -[THClient getConnectionEntitlementValidity]_block_invoke - Error: (null)
error	17:59:05.714695+0800	MatterExtension	                -[THClient storeCredentialsForBorderAgent:activeOperationalDataSet:completion:]_block_invoke:646: - Response: Error Domain=ThreadCredentialsStore Code=1 "Backing store is nil..." UserInfo={NSLocalizedDescription=<private>}
error	17:59:05.715346+0800	CoreThreadCommissionerServiced	Server: -[CTCSXPCService listener:shouldAcceptNewConnection:]_block_invoke - XPC Connection invalidated
error	17:59:05.747498+0800	CoreThreadCommissionerServiced	ThreadCommissioningService is Enabled
error	17:59:05.748245+0800	CoreThreadCommissionerServiced	Server: -[CTCSXPCService checkEntitlements:connection:] - Entitlement Check is successful for the key : <private>
error	17:59:05.749249+0800	homed	                        Client: -[THClient getConnectionEntitlementValidity:]_block_invoke - Error: (null)
error	17:59:05.750575+0800	CoreThreadCommissionerServiced	Server: -[CTCSXPCService checkEntitlements:connection:] - Entitlement Check is successful for the key : <private>
default	17:59:05.750705+0800	CoreThreadCommissionerServiced	Request to fetch active dataset record with xpanid <private>
default	17:59:05.751315+0800	CoreThreadCommissionerServiced	nw_path_evaluator_start [AC0FC426-242F-40D0-945A-27682116B6EE <NULL> generic, attribution: developer]path: satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns
error	17:59:05.752692+0800	homed	                        [1263984240/1] CHIP Accessory Server failed to obtain Thread credentials for selected extended PAN ID... Error: (null)
error	17:59:05.754467+0800	homed	                        Invalidating XPC connection.
error	17:59:05.754694+0800	homed	                        Client: -[THClient connectToXPCService]_block_invoke - CTCS XPC Client is invalidated.
error	17:59:05.755485+0800	CoreThreadCommissionerServiced	Server: -[CTCSXPCService listener:shouldAcceptNewConnection:]_block_invoke - XPC Connection invalidated

May I get an advice?? Thanks

Answered by DTS Engineer in 798109022

Hi, When I would like to use MatterAddDeviceRequest to commission a thread device, I will get error "Error Domain=HMErrorDomain Code=18 "Pairing Failed" UserInfo={NSLocalizedDescription=Pairing Failed, NSUnderlyingError=0x282786e20 {Error Domain=HAPErrorDomain Code=15 "(null)"}}".

Are you accessing THClient in your app or in your Matter Pairing Extension? There's a known bug (r.127307833) that interferes with accessing THClient outside of an app context, however, the bigger issue here is that trying to use THClient inside your Matter Pairing Extension would be a mistake even if it worked.

Your Matter Pairing Extension has a very limited ability to handle failures, so it's critical that you get "all" of the necessary pairing information and BEFORE you start the pair request. That way you move as many failures as possible into the place where you can best communicate and act on them.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Hi, When I would like to use MatterAddDeviceRequest to commission a thread device, I will get error "Error Domain=HMErrorDomain Code=18 "Pairing Failed" UserInfo={NSLocalizedDescription=Pairing Failed, NSUnderlyingError=0x282786e20 {Error Domain=HAPErrorDomain Code=15 "(null)"}}".

Are you accessing THClient in your app or in your Matter Pairing Extension? There's a known bug (r.127307833) that interferes with accessing THClient outside of an app context, however, the bigger issue here is that trying to use THClient inside your Matter Pairing Extension would be a mistake even if it worked.

Your Matter Pairing Extension has a very limited ability to handle failures, so it's critical that you get "all" of the necessary pairing information and BEFORE you start the pair request. That way you move as many failures as possible into the place where you can best communicate and act on them.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

@DTS Engineer The same is happening to me and indeed I am using THClient from within the selectThreadNetwork(from threadScanResults: since I have to save the credential before returning the selected network as the documentation says: https://developer.apple.com/documentation/mattersupport/matteradddeviceextensionrequesthandler/selectthreadnetwork(from:)

In my use case I don't know the mac extended address of my thread network until I get the thread scan results, so it needs to be in this method. For context, at this point I am only aware of extended PAN ID and operational dataset.

Is this a bug or limitation? Can I scan for thread networks in any other way?

How use MatterSupport to commission a thread device?
 
 
Q