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

[Feature] #26684

Closed
LucaFagan opened this issue May 19, 2023 · 2 comments · Fixed by #26693
Closed

[Feature] #26684

LucaFagan opened this issue May 19, 2023 · 2 comments · Fixed by #26693

Comments

@LucaFagan
Copy link

LucaFagan commented May 19, 2023

Feature description

I'm using

    let parser = MTRQRCodeSetupPayloadParser(base38Representation: "MT:5KR00-Q000KA0648G00")
    
    if let payload = try? parser.populatePayload()
    {
        let serialNumber = payload.serialNumber
        let productIdHex = String(format:"%04X", payload.productID.uint64Value)
        let vendorIdHex = String(format:"%04X", payload.vendorID.uint64Value)
        let versionHex = String(format:"%02X", payload.version.uint64Value)
    }

to parse a commissioning QR code but serialNumber is nil.

Is it possible to have serialNumber in the QR code string ? How can generate such a QR code ?

Platform

darwin

Platform Version(s)

No response

Anything else?

No response

@bzbarsky-apple
Copy link
Contributor

bzbarsky-apple commented May 19, 2023

The serial number would need to live in the TLV extension bits of the payload. Specifically, you would have an anonymous-tagged structure with a single field: context-specific tag 0, type string or unsigned integer, value serial number. So something like hex bytes 152c0002424318 for a two-char string "BC".

% chip-tool payload generate-qrcode --existing-payload "MT:5KR00-Q000KA0648G00" --tlvBytes hex:152c0002424318 --version 0
[1684509906518] [59255:25761244] [TOO] QR Code: MT:4KR00-Q000KA064IJ3P0GUE20A6.S0

to generate a payload like the one you have above but with valid version number and those TLV bytes. That leads to:

% chip-tool payload parse-setup-payload MT:4KR00-Q000KA064IJ3P0GUE20A6.S0
[1684509957942] [59353:25762171] [SPL] Parsing base38Representation: MT:4KR00-Q000KA064IJ3P0GUE20A6.S0
[1684509957942] [59353:25762171] [SPL] Version:             0
[1684509957942] [59353:25762171] [SPL] VendorID:            4969
[1684509957942] [59353:25762171] [SPL] ProductID:           32768
[1684509957942] [59353:25762171] [SPL] Custom flow:         0    (STANDARD)
[1684509957942] [59353:25762171] [SPL] Discovery Bitmask:   0x00 (NONE)
[1684509957942] [59353:25762171] [SPL] Long discriminator:  3840   (0xf00)
[1684509957942] [59353:25762171] [SPL] Passcode:            20202021
[1684509957943] [59353:25762171] [SPL] SerialNumber:        BC

I should fix MTRSetupPayload's qrCodeString to encode the serialNumber in there if it's set.... Then you could just set your payload's serialNumber and qrCodeString to get the string.

Also, you should probably use MTRSetupPayload.setupPayload(onboardingPayload: ...) for parsing, not the deprecated MTRQRCodeSetupPayloadParser bit.

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue May 19, 2023
Without this when we convert to QRCode we are dropping the serialNumber.

Fixes project-chip#26684
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue May 19, 2023
Without this when we convert to QRCode we are dropping the serialNumber.

Fixes project-chip#26684
bzbarsky-apple added a commit that referenced this issue May 19, 2023
Without this when we convert to QRCode we are dropping the serialNumber.

Fixes #26684
@LucaFagan
Copy link
Author

It works, thanks

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

Successfully merging a pull request may close this issue.

2 participants