Skip to main content

decode_qr_payload

Function decode_qr_payload 

Source
pub fn decode_qr_payload(qr: &str) -> Result<OnboardingInfo>
Expand description

Decode a Matter QR code payload (the MT:... string, with or without the MT: prefix).

The payload is a Base38-encoded 88-bit integer with the following layout (LSB first):

  • bits 0- 2 : version (3 bits)
  • bits 3-18 : vendor ID (16 bits)
  • bits 19-34 : product ID (16 bits)
  • bits 35-36 : commissioning flow (2 bits)
  • bits 37-44 : discovery capabilities (8 bits)
  • bits 45-56 : discriminator (12 bits)
  • bits 57-83 : passcode (27 bits)
  • bits 84-87 : padding (4 bits, must be zero)