How to retrieve the Matter QR code?

Due to production requirements, I need to obtain the device's QR code. However, I found that the QR code can only be retrieved using the code snippet below after calling Nrf::Matter::StartServer().
Since there are several production test items that need to be performed, I would like to retrieve the QR code immediately after the hardware initialization.
Is there any way to obtain the QR code right after the device boots up?
My SDK version is NCS 2.9.0.

CHIP_ERROR Sunion::AppTask::StartApp()
{
	ReturnErrorOnFailure(Init());

	AppEvent event = {};

    DoorLockServer::Instance().SetSoundVolume(kLockEndpointId, Para.BuzzerPercent);


    char buffer[128 + 1];
    chip::MutableCharSpan qrCode(buffer);
    chip::RendezvousInformationFlags rendezvousFlags = chip::RendezvousInformationFlag::kBLE;

    if (GetQRCode(qrCode, rendezvousFlags) == CHIP_NO_ERROR)
    {
        ChipLogProgress(AppServer, "SetupQRCode: [%s]", qrCode.data());
    }
    else
    {
        ChipLogError(AppServer, "Failed to get QR code");
    }

	while (true) {
		k_msgq_get(&sAppEventQueue, &event, K_FOREVER);
		DispatchEvent(event);
		Ex_StateMachine();
	}

	return CHIP_NO_ERROR;
}

Parents Reply
  • Hi,

    As I mentioned earlier, I must call PrintOnboardingCodes after executing Nrf::Matter::StartServer(), otherwise the system crashes. That’s why I’ve been emphasizing whether it’s possible to directly obtain the QR code string,because I believe it’s stored somewhere (likely in the factory data). So, how can I retrieve the QR code from anywhere in the program?

Children
No Data
Related