/**
* Callback response from OCR.read.
* @callback OCRReadCallback
* @property {number} peripheralID - ID of the peripheral which was read.
* @property {object} record - Record scanned by OCR process.
* @property {string} image - Base 64 encoded string representation of the image who's values were read.
*/
/**
* @exports ValidicMobile.OCR
* Represents Validic OCR functionality.
*/
exports.OCR = {
/**
* Gets an array of supported peripherals for use with OCR.
* @param {PeripheralsCallback} success - Callback function containing an array of peripheral devices.
*/
getSupportedPeripherals : function(success) {
cordova.exec(success, null, "ValidicMobileOCR", "OCR_getSupportedPeripherals", []);
},
/**
* Gets an array of supported peripherals matching a given type.
* @param {number} type - Peripheral Type.
* @param {PeripheralsCallback} success - Callback function containing an array of all peripherals matching given type.
* @param {FailCallback} error - Callback function indicating invalid type.
*/
getPeripheralsOfType : function(type, success, error) {
cordova.exec(success, error, "ValidicMobileOCR", "OCR_getPeripheralsOfType", [type]);
},
/**
* Gets information on a supported peripheral with a given id.
* @param {number} id - Peripheral ID.
* @param {PeripheralsCallback} success callback function containing the peripheral's information.
* @param {FailCallback} error callback function with a n error message indicating failure reason.
*/
getPeripheral : function(id, success, error) {
cordova.exec(success, error, "ValidicMobileOCR", "OCR_getPeripheral", [id]);
},
/**
* Launches the OCR view to take a reading.
* @param {number} id - Id of peripheral to take a reading from.
* @param {OCRReadCallback} success Callback indicates the capture screen was loaded successfully.
* @param {FailCallback} error - Indicates the capture screen was not loaded successfully. Includes failure reason in message.
*/
read : function(id, success, error) {
cordova.exec(success, error, "ValidicMobileOCR", "OCR_read", [id]);
},
/**
* Launches the OCR view to take a reading that is displayed in the provided unit.
* @param {number} id - Id of peripheral to take a reading from.
* @param {GlucoseUnit} unit - The unit that the device is displaying in.
* @param {OCRReadCallback} success Callback indicates the capture screen was loaded successfully.
* @param {FailCallback} error - Indicates the capture screen was not loaded successfully. Includes failure reason in message.
*/
readWithGlucoseUnit : function(id, unit, success, error) {
cordova.exec(success, error, "ValidicMobileOCR", "OCR_read", [id, unit])
},
/**
* Used for setting units for ocr.
* @enum {string}
*/
GlucoseUnits : {
MGDL: "mg/dL",
MMOLL: "mmol/L"
}
}