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

How to pair a device using qr-code and commission wifi/thread #15384

Closed
caipiblack opened this issue Feb 21, 2022 · 4 comments
Closed

How to pair a device using qr-code and commission wifi/thread #15384

caipiblack opened this issue Feb 21, 2022 · 4 comments

Comments

@caipiblack
Copy link
Contributor

caipiblack commented Feb 21, 2022

Problem

I'm looking for the correct way to pair a device with qr-code and commission the device using the Matter stack.

Before this PR (#12909) the chip-tool example was doing the commissioning step when the callback OnPairingComplete() was triggered.

Why this example has been removed ? It's not the good way ?

Also, I found some discussions here: #14429

As I understand there are two way's to do this:

  1. Decode the QR Code to get RendezvousParameters and use this function:
CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParameters & rendezvousParams,
                                          CommissioningParameters & commissioningParams)

Like this the commissioning is performed automaticaly but we have to get the informations from the QR Code and we need to know (before the commissioning) the thread/wifi credentials

  1. Pass the QR Code to this function, and use Network Commissioning Cluster to commission the device (not sure if possible)
CHIP_ERROR PairDevice(NodeId remoteDeviceId, const char * setUpCode);

Like this we just have to supply the QR Code, when the callback OnPairingComplete() is triggered we can ask the user for wifi/thread credentials

I'm really not sure to know what is the best way to do it.

What are these functions really intended for ??

Which function is future proof ?

Why the function with const char * setUpCode parameter doesn't have CommissioningParameters ?

@cecille
Copy link
Contributor

cecille commented Feb 25, 2022

Please see #14429. This got a little stale as we prioritized some other work in the lead up to the last branch, but I should get back to it either late today or early next week.

@caipiblack
Copy link
Contributor Author

@cecille : I also have more questions:

What is the final objective of all the commissioning callbacks ?

  • Is it just to get informations about the commissioning status ? Or is there something to do in the callbacks during the commissioning ?

Also, is there any plans to improve these callbacks ? (regroup them and add more status)

Currently If I do the commissioning of a thread device from the application, we have to see the Matter logs to know what happens,

I think it should be good to implement more states in the OnStatusUpdate() callback so we can use it to display "commissioning status" on the final application.

For example:

  • Searching the device (BLE, SoftAP, OnNetwork)
  • Device discovered (BLE, SoftAP, OnNetwork)
  • Waiting for the device in the end network (should be called when we know the device is going to connect on final network)
  • Device discovered in the end network

Or better: add a status for each commissioning steps in chip::Controller::DevicePairingDelegate::Status !

    enum Status : uint8_t
    {
        SecurePairingSuccess = 0,
        SecurePairingFailed,
    };

    /////////// callbacks from DevicePairingDelegate /////////
    void OnStatusUpdate(chip::Controller::DevicePairingDelegate::Status status) override;
    void OnPairingComplete(CHIP_ERROR error) override;
    void OnCommissioningComplete(NodeId deviceId, CHIP_ERROR error) override;

@cecille
Copy link
Contributor

cecille commented Mar 10, 2022

Callbacks cleanup issue: #15612

Please feel free to add status callback updates if you will find them helpful. You can also achieve this by using a custom commissioner delegate.

@cecille
Copy link
Contributor

cecille commented Mar 29, 2022

#14429 handles this issue. Callbacks is tracked in another issue, so closing this.

@cecille cecille closed this as completed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants