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 |
|
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 |
|
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 |
|
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:
- Cardboard Viewer v1: https://g.co/cardboard
- Cardboard Viewer v2: https://google.com/cardboard/cfd?p=deviceParams (for example, https://google.com/cardboard/cfg?p=CgZHb29nbGUSEkNhcmRib2FyZCBJL08gMjAxNR0rGBU9JQHegj0qEAAASEIAAEhCAABIQgAASEJYADUpXA89OggeZnc-Ej6aPlAAYAM). Redirection is also supported up to a maximum of 5 possible redirects before reaching the proper pattern. This function only supports HTTPS connections. In case a URI containing an HTTP scheme is provided, it will be replaced by an HTTPS one. Upon termination, it will increment a counter that can be queried via See also:CardboardQrCode_getDeviceParamsChangedCount() when new device parameters were successfully saved.
uri
Must not be null.size
Must be higher than 0.Parameters uri
UTF-8 URI string. See above for supported formats.size
Size in bytes ofuri
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.