Stay organized with collections Save and categorize content based on your preferences.

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_getDeviceParamsChangedCount()
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_saveDeviceParams(const uint8_t *uri, int size)
void
Saves the encoded device parameters provided by an URI.
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.

encoded_device_params Must not be null. When it is unmet, a call to this function results in a no-op.

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.

encoded_device_params Must not be null. size Must not be null. When it is unmet, a call to this function results in a no-op and default values are returned (empty values). Does not require a prior call to Cardboard_initializeAndroid in Android devices.

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

CardboardQrCode_getDeviceParamsChangedCount

int CardboardQrCode_getDeviceParamsChangedCount()

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.

encoded_device_params Must not be null. size Must not be null. When it is unmet, a call to this function results in a no-op and default values are returned (empty values).

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

CardboardQrCode_saveDeviceParams

void CardboardQrCode_saveDeviceParams(
  const uint8_t *uri,
  int size
)

Saves the encoded device parameters provided by an URI.

This function obtains the encoded device parameters by parsing a URI string and then saves them.

Expected URI format for:

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 CardboardQrCode_getDeviceParamsChangedCount when new device parameters where successfully saved.