How to commission a device to our fabric after adding it using Matter.Support

How to commission a device to our fabric after adding it using Matter.Support

We have the following configuration:

  • eero border router
  • our own thermostat device that we are developing
  • no home pod or home TV are used

We have followed this guide

https://developer.apple.com/documentation/mattersupport/adding-matter-support-to-your-ecosystem

and implemented Matter Extension, as Matter.Framework is no more allowed to pair device.

In Matter Extension the following callbacks are fired:

override func selectThreadNetwork(from threadScanResults: [MatterAddDeviceExtensionRequestHandler.ThreadScanResult]) async throws -> MatterAddDeviceExtensionRequestHandler.ThreadNetworkAssociation

override func commissionDevice(in home: MatterAddDeviceRequest.Home?, onboardingPayload: String, commissioningID: UUID) async throws

In our demo app the following function completes without errors

try await request.perform()

The thermostat device seems to be successfully commissioned.

In https://developer.apple.com/documentation/mattersupport/adding-matter-support-to-your-ecosystem there is a comment that says:

Use Matter.Framework APIs to pair the accessory to your application with the provided onboardingPayload.

How should this thing be done ?

We tried to start the matter controller in the old way:

func start() -> Bool
{
    if (self.matterController == nil)
    {
        let storage = MatterStorage.shared
        let factory = MTRDeviceControllerFactory.sharedInstance()
        let factoryParams = MTRDeviceControllerFactoryParams(storage: storage)
        
        do
        {
            try factory.start(factoryParams)
        }
        catch
        {
            return false
        }
        
        let keys = FabricKeys()
        let params = MTRDeviceControllerStartupParams(signing: keys, fabricId: UInt64(fabricId), ipk: keys.ipk)
        params.vendorID = NSNumber(value: self.vendorId)
        
        self.matterController = try? factory.createController(onExistingFabric: params)
        
        let controllerNid = self.matterController?.controllerNodeID
        
        if (self.matterController == nil)
        {
            self.matterController = try? factory.createController(onNewFabric: params)
        }
    }
    
    return (self.matterController != nil)
}

Certificate are generated locally as in Matter Darwin example.

We tried to call

let params = MTRCommissioningParameters() matterController?.commissionNode(withID: NSNumber(value: self.deviceNid), commissioningParams: params)

in commissionDevice of Matter Extension but we get error:

Invalid object state.

Here

override func commissionDevice(in home: MatterAddDeviceRequest.Home?, onboardingPayload: String, commissioningID: UUID) async throws {}

in Matter Extension(request handler), you can get a payload, use this payload to commission into your fabric.

@RobinGao Hi there: I still can not get any response from commissionDevice. I make a http request when receive callback in commissionDevice. I added MatterExtension, I am not sure if I miss some configuration to do that.

How to commission a device to our fabric after adding it using Matter.Support
 
 
Q