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

Getting onboarding payload after QR code is scanned #222

Open
remziyey opened this issue Sep 24, 2024 · 2 comments
Open

Getting onboarding payload after QR code is scanned #222

remziyey opened this issue Sep 24, 2024 · 2 comments

Comments

@remziyey
Copy link

remziyey commented Sep 24, 2024

Hi all,

I want to get onboarding payload (starts with MT) of a matter device after its QR code scanned (or setup code is entered) and commissioning is successful (to pass it to custom tv hub).
commissionedDeviceDescriptor doesn't contain onboarding payload and I tried to get it from intent like this:

val commissionDeviceLauncher =
    rememberLauncherForActivityResult(
      contract = ActivityResultContracts.StartIntentSenderForResult()
    ) { result ->
      // Commission Device Step 5.
      // The Commission Device activity in GPS (step 4) has completed.
      val resultCode = result.resultCode
      if (resultCode == Activity.RESULT_OK) {
        Timber.d("CommissionDevice: Success")

        val payload = result.data?.getStringExtra(Matter.EXTRA_ONBOARDING_PAYLOAD)
        Timber.i("Payload $payload")

        // We let the ViewModel know that GPS commissioning has completed successfully.
        // The ViewModel knows that we still need to capture the device name and will\
        // update UI state to trigger the NewDeviceAlertDialog.
        homeViewModel.gpsCommissioningDeviceSucceeded(result)
      } else {
        homeViewModel.commissionDeviceFailed(resultCode)
      }
    }

but intent doesn't have an EXTRA_ONBOARDING_PAYLOAD extra.
I tried these with both with matter virtual device (macOS app) and real matter device.

I am not sure if I am missing something, any help would be appreciated.

@aBozowski
Copy link
Member

EXTRA_ONBOARDING_PAYLOAD is for the 3p (with respect to play services) app to include the QR code in its request to initiate commissioning to play services. This allows the calling app to provide the payload and skip QR scan, e.g. when sharing an already commissioned device. Its not for the callback.

After a device is commissioned, the commissioning window should close and subsequent attempts would take a new discriminator and passcode. Hence typically the original payload isn't useful and thus doesn't seem to be passed back.

However it looks like you can get some other information about the commissioned device, like vid / pid.

https://developers.home.google.com/reference/com/google/android/gms/home/matter/commissioning/CommissioningResult

-- DeviceDescriptor -->

https://developers.home.google.com/reference/com/google/android/gms/home/matter/common/DeviceDescriptor

@aBozowski
Copy link
Member

aBozowski commented Oct 23, 2024

Apologies for leaving this out, but this should help with your problem end to end.

Play services should call back into your app with a new payload for the same device before the task above completes.

Please take a look at the sample here.

And please take a look at slide 48 here

https://github.com/google-home/sample-apps-for-matter-android/blob/main/docs/GoogleHomeMobileSDK.pdf

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