QR Code Scanner

This module manages the entire process of capturing, decoding and getting the device parameters from a QR code.

Summary

It also saves and loads the device parameters to and from the external storage.

Functions

CardboardQrCode_destroy(const uint8_t *encoded_device_params)
void
Releases memory used by the provided encoded_device_params array.
CardboardQrCode_getCardboardV1DeviceParams(uint8_t **encoded_device_params, int *size)
void
Gets Cardboard V1 device parameters.
CardboardQrCode_getQrCodeScanCount()
int
Gets the count of successful device parameters read and save operations.
CardboardQrCode_getSavedDeviceParams(uint8_t **encoded_device_params, int *size)
void
Gets currently saved devices parameters.
CardboardQrCode_scanQrCodeAndSaveDeviceParams()
void
Scans a QR code and saves the encoded device parameters.

Functions

CardboardQrCode_destroy

void CardboardQrCode_destroy(
  const uint8_t *encoded_device_params
)

Releases memory used by the provided encoded_device_params array.

Details
Parameters
encoded_device_params
The device parameters serialized using cardboard_device.proto.

CardboardQrCode_getCardboardV1DeviceParams

void CardboardQrCode_getCardboardV1DeviceParams(
  uint8_t **encoded_device_params,
  int *size
)

Gets Cardboard V1 device parameters.

This function does not use external storage, and stores into encoded_device_params the value of a pointer storing proto buffer. Users of this API should not free memory.

Details
Parameters
encoded_device_params
Reference to the device parameters.
size
Size in bytes of encoded_device_params.

CardboardQrCode_getQrCodeScanCount

int CardboardQrCode_getQrCodeScanCount()

Gets the count of successful device parameters read and save operations.

Details
Returns
The count of successful device parameters read and save operations.

CardboardQrCode_getSavedDeviceParams

void CardboardQrCode_getSavedDeviceParams(
  uint8_t **encoded_device_params,
  int *size
)

Gets currently saved devices parameters.

This function allocates memory for the parameters, so it must be released using CardboardQrCode_destroy.

Details
Parameters
encoded_device_params
Reference to the device parameters serialized using cardboard_device.proto.
size
Size in bytes of encoded_device_params.

CardboardQrCode_scanQrCodeAndSaveDeviceParams

void CardboardQrCode_scanQrCodeAndSaveDeviceParams()

Scans a QR code and saves the encoded device parameters.

Upon termination, it will increment a counter that can be queried via See also:CardboardQrCode_getQrCodeScanCount() when new device parameters where succesfully saved.