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
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.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe QR Code Scanner module manages the process of capturing, decoding, and retrieving device parameters from QR codes.\u003c/p\u003e\n"],["\u003cp\u003eIt provides functions to save and load device parameters to and from external storage.\u003c/p\u003e\n"],["\u003cp\u003eThe module supports Cardboard Viewer v1 and v2 QR code formats.\u003c/p\u003e\n"],["\u003cp\u003eIt includes functionality to scan QR codes directly and save the obtained device parameters.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access the saved device parameters and track changes using provided functions.\u003c/p\u003e\n"]]],[],null,["# QR Code Scanner\n===============\n\nThis module manages the entire process of capturing, decoding and getting the device parameters from a QR code.\n\nSummary\n-------\n\nIt also saves and loads the device parameters to and from the external storage.\n\n| ### Functions ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [CardboardQrCode_destroy](#group__qrcode-scanner_1gaab54d0d46eb5857287e774f96c9788d8)`(const uint8_t *encoded_device_params)` | `void` Releases memory used by the provided encoded_device_params array. |\n| [CardboardQrCode_getCardboardV1DeviceParams](#group__qrcode-scanner_1gaff73f4881bb9404f0b7c0c33b4045025)`(uint8_t **encoded_device_params, int *size)` | `void` Gets Cardboard V1 device parameters. |\n| [CardboardQrCode_getDeviceParamsChangedCount](#group__qrcode-scanner_1gaf0a71fb74c6b9b3857beb383ff8e85da)`()` | `int` Gets the count of successful device parameters read and save operations. |\n| [CardboardQrCode_getSavedDeviceParams](#group__qrcode-scanner_1ga50e736dab99e572c773d90aa91321c3b)`(uint8_t **encoded_device_params, int *size)` | `void` Gets currently saved devices parameters. |\n| [CardboardQrCode_saveDeviceParams](#group__qrcode-scanner_1ga152b744b27fe7eedacc53c45eb81e58e)`(const uint8_t *uri, int size)` | `void` Saves the encoded device parameters provided by an URI. |\n| [CardboardQrCode_scanQrCodeAndSaveDeviceParams](#group__qrcode-scanner_1ga3bf36a2d41651e22344dd95030eea324)`()` | `void` Scans a QR code and saves the encoded device parameters. |\n\nFunctions\n---------\n\n### CardboardQrCode_destroy\n\n```gdscript\nvoid CardboardQrCode_destroy(\n const uint8_t *encoded_device_params\n)\n``` \nReleases memory used by the provided encoded_device_params array.\n\n`encoded_device_params` Must not be null. When it is unmet, a call to this function results in a no-op.\n\n| Details ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |-------------------------|----------------------------------------------------------------| | `encoded_device_params` | The device parameters serialized using cardboard_device.proto. | |\n\n### CardboardQrCode_getCardboardV1DeviceParams\n\n```scdoc\nvoid CardboardQrCode_getCardboardV1DeviceParams(\n uint8_t **encoded_device_params,\n int *size\n)\n``` \nGets Cardboard V1 device parameters.\n\nThis 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.\n\n`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](/cardboard/reference/c/group/initialization#group__initialization_1gaf3bcb627b96ad8045ef58e5ab6d6b04f) in Android devices.\n\n| Details ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |-------------------------|-------------------------------------------| | `encoded_device_params` | Reference to the device parameters. | | `size` | Size in bytes of `encoded_device_params`. | |\n\n### CardboardQrCode_getDeviceParamsChangedCount\n\n```scdoc\nint CardboardQrCode_getDeviceParamsChangedCount()\n``` \nGets the count of successful device parameters read and save operations.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|---------------------------------------------------------------------|\n| **Returns** | The count of successful device parameters read and save operations. |\n\n### CardboardQrCode_getSavedDeviceParams\n\n```scdoc\nvoid CardboardQrCode_getSavedDeviceParams(\n uint8_t **encoded_device_params,\n int *size\n)\n``` \nGets currently saved devices parameters.\n\nThis function allocates memory for the parameters, so it must be released using [CardboardQrCode_destroy](/cardboard/reference/c/group/qrcode-scanner#group__qrcode-scanner_1gaab54d0d46eb5857287e774f96c9788d8).\n\n`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).\n\n| Details ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |-------------------------|-----------------------------------------------------------------------------| | `encoded_device_params` | Reference to the device parameters serialized using cardboard_device.proto. | | `size` | Size in bytes of encoded_device_params. | |\n\n### CardboardQrCode_saveDeviceParams\n\n```gdscript\nvoid CardboardQrCode_saveDeviceParams(\n const uint8_t *uri,\n int size\n)\n``` \nSaves the encoded device parameters provided by an URI.\n\nThis function obtains the encoded device parameters by parsing a URI string and then saves them.\n\nExpected URI format for:\n\n- Cardboard Viewer v1: \u003chttps://g.co/cardboard\u003e\n- Cardboard Viewer v2: \u003chttps://google.com/cardboard/cfd?p=deviceParams\u003e (for example, \u003chttps://google.com/cardboard/cfg?p=CgZHb29nbGUSEkNhcmRib2FyZCBJL08gMjAxNR0rGBU9JQHegj0qEAAASEIAAEhCAABIQgAASEJYADUpXA89OggeZnc-Ej6aPlAAYAM\u003e). 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()](/cardboard/reference/c/group/qrcode-scanner#group__qrcode-scanner_1gaf0a71fb74c6b9b3857beb383ff8e85da) when new device parameters were successfully saved.`uri` Must not be null. `size` Must be higher than 0. Parameters\n\n |--------|----------------------------------------------------|\n | `uri` | UTF-8 URI string. See above for supported formats. |\n | `size` | Size in bytes of `uri` |\n\n\u003cbr /\u003e\n\n### CardboardQrCode_scanQrCodeAndSaveDeviceParams\n\n```scdoc\nvoid CardboardQrCode_scanQrCodeAndSaveDeviceParams()\n``` \nScans a QR code and saves the encoded device parameters.\n\nUpon termination, it will increment a counter that can be queried via [CardboardQrCode_getDeviceParamsChangedCount](/cardboard/reference/c/group/qrcode-scanner#group__qrcode-scanner_1gaf0a71fb74c6b9b3857beb383ff8e85da) when new device parameters where successfully saved."]]