Smartscanner
Smart Scanner is a mobile app extension built on top of the SmartScanner-Core. It enhances traditional QR code scanning by supporting multiple versions of QR codes and parsing algorithms that vary across different countries.
Key Features
CSV-Based QR Code Versioning: The app can use a CSV input file to define the different versions of QR codes used in a country.
Direct Value Assignment: QR code type information and configurations can be directly assigned in the ODK form’s data section.
Dynamic Parsing: Smart Scanner identifies the type of QR code from the CSV or data input and applies the appropriate parsing logic.
Form Integration: The scanning results are returned via an intent, providing all the data necessary to fill out a form.
Supported QR Code Types
Smart Scanner currently supports three QR code types:
CWT (CBOR Web Token):
The QR code data is encrypted, and the JSON payload is only accessible after verifying the digital signature using a public key.
Plain JSON:
The QR code contains a JSON payload, which is subject to signature verification after scanning. The verification ensures the data’s integrity by using specific fields from the QR code.
Plain Text:
The QR code directly contains a plain text string, which can be used without additional parsing or verification.
Public Key Verification
CWT: The verification process must succeed before receiving the JSON payload.
Plain JSON: Verification is done after receiving the payload, ensuring the data hasn't been tampered with.
Input Requirements
To use Smart Scanner, you need to pass an intent with a JSON array containing the following inputs:
qr_code_type:
Metadata defining the different QR code types and their versions.
Example:
public_keys (for CWT and JSON types):
Public keys for each version of the QR code to verify its signature.
Example:
field_mapper:
A mapping that defines how form fields correspond to fields in the scanned QR code.
Example:
signature_mapper (for JSON types):
Fields used for signature verification in the JSON QR code. Includes the order of fields and how they should be prettified.
Example:
Default Behavior
If no input is passed to the scanner, it returns an error.
If only a public key is passed, the scanner defaults to CWT logic and attempts to decode all fields in the QR code.
Example for public key-only input:
Error Codes
When scanning fails, the following fields and codes are returned:
QRCODE_SCAN_status:
true
(success) orfalse
(failure).QRCODE_SCAN_status_message: The reason for the failure.
QRCODE_SCAN_status_code: Error code explaining the failure.
Error Code | Description |
---|---|
101 | QR Code Types Not Specified Correctly |
102 | Public Key Not Specified Correctly |
103 | Signature Mapper Not Specified Correctly |
104 | Fields Not Specified Correctly in Scanner Input |
105 | QR Code Not Recognized |
106 | Failure But Reason Unknown |
Configuration in ODK Forms
CSV Input for Scanner
A CSV file can be supplied and referenced in the ODK form. It should follow this format:
Direct Assignment in ODK Form
Instead of using a CSV file, you can directly assign the values in the ODK form's data section:
ODK Form Integration
The ODK form should have variable names consistent with the field mapper in the CSV or data input. The form should include variables for the scanning status and the error codes.
Example structure:
An intent call in the form would look like this:
Download APK
Last updated