Class: Grabba

Grabba

Grabba plugin for Cordova 3.5.0+
Currently supports:
- Android 4.4.2+
- iOS 8.0+
- Windows 10

Constructor

new Grabba()

Members

barcode :GrabbaBarcode

Access Grabba barcode reading capabilities through grabba.barcode
Type:

bertlv :GrabbaBerTlv

Access GrabbaBerTlv through grabba.bertlv
Type:

fingerprint :GrabbaFingerprint

Access Grabba fingerprint reading capabilities through grabba.fingerprint
Type:

magstripe :GrabbaMagstripe

Access Grabba magnetic stripe reading capabilities via grabba.magstripe
Type:

passport :GrabbaPassport

Access Grabba passport MRZ reading capabilities through grabba.passport
Type:

preferences :GrabbaPreferences

Grabba general preference identifiers.
Type:

proxcard :GrabbaProxcard

Access Grabba proxcard reading capabilities through grabba.proxcard
Type:

util :GrabbaUtil

Access Grabba utilities through grabba.util
Type:

Methods

getBatteryLevel(onSuccess, onError)

Check the Grabba battery level.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{int} battery level.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to the current Grabba battery level
<button onclick="grabba.getBatteryLevel(function(state){
     alert('Grabba battery is ' + state);
},
 function(errorString) {
     alert('on error ' + errorString);
 });">get battery level</button>

getBoolPref(boolPrefID, onSuccess, onError)

Obtain the value of a given boolean preference.
Parameters:
Name Type Description
boolPrefID String boolean preference ID. Preference IDs can be found under each respective class's preferences member.
onSuccess function Invoked on success with the following parameters:
{boolean} Boolean value of preference.
onError function Called on error with the following parameters:
{String} error description.

getDriverVersion(onSuccess, onError)

Obtain the Grabba driver version.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{String} Driver version.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the current driver version
 <button onclick="grabba.getDriverVersion(function(version){
 alert('Grabba driver version is ' + version);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get driver version</button>

getFirmwareVersion(onSuccess, onError)

Obtain the Grabba firmware version.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{String} firmware version.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the current firmware version
 <button onclick="grabba.getFirmwareVersion(function(version){
 alert('Grabba firmware version is ' + version);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get firmware version</button>

getHardwareVersion(onSuccess, onError)

Obtain the Grabba hardware version.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{String} hardware version.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the current hardware version
 <button onclick="grabba.getHardwareVersion(function(version){
 alert('Grabba hardware version is ' + version);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get hardware version</button>

getIntPref(intPrefID, onSuccess, onError)

Obtain the value of a given integer preference.
Parameters:
Name Type Description
intPrefID String Integer preference ID. Preference IDs can be found under each respective class's preferences member.
onSuccess function Invoked on success with the following parameters:
{int} Integer value of preference.
onError function Called on error with the following parameters:
{String} error description.

getLeftButtonState(onSuccess, onError)

Check of the left Grabba button is pressed.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{boolean} Left button pressed state.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the Grabba model number
 <button onclick="grabba.getLeftButtonState(function(pressed){
 alert('Grabba left button state is ' + pressed);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get left button state</button>

getModel(onSuccess, onError)

Obtain the Grabba model number.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{String} Grabba model number.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the Grabba model number
 <button onclick="grabba.getModel(function(model){
 alert('Grabba model is ' + model);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get model number</button>

getRightButtonState(onSuccess, onError)

Check of the right Grabba button is pressed.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{boolean} Right button pressed state.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the Grabba model number
 <button onclick="grabba.getRightButtonState(function(pressed){
 alert('Grabba right button state is ' + pressed);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get right button state</button>

getSerialNumber(onSuccess, onError)

Obtain the Grabba's serial number.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{String} Grabba serial number.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to get the Grabba serial number
 <button onclick="grabba.getSerialNumber(function(serialNumber){
 alert('Grabba serial number is ' + serialNumber);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">get serial number</button>

isConnected(onSuccess, onError)

Check if the Grabba is connected.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{boolean} indicating connection state.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to check if the Grabba is connected
<button onclick="grabba.isConnected(function(state){
     alert('Grabba connected is ' + state);
},
 function(errorString) {
     alert('on error ' + errorString);
 });">Check connection</button>

isSupported() → {Boolean}

Check if the API is supported on this platform.
Returns:
Type
Boolean

registerButtonCallback(callback, onError)

Register a callback function for button events. If no callbacks (null) is passed to this function, all present callbacks will be cleared.
Parameters:
Name Type Description
callback Object An object which implements the following functions:
leftButtonEvent : function(boolean){}
Called when the left button changes states with the following parameters:
{boolean} indicating whether or not the button is pressed.

rightButtonEvent : function(boolean){}
Called when the right button changes states with the following parameters:
{boolean} indicating whether or not the button is pressed.

onError function Called on error with the following parameters:
{String} error description.
Example
//Register for button events
grabba.registerButtonCallback({
     leftButtonEvent: function(pressed) {
         alert('Left button state ' + pressed);
     },
     rightButtonEvent: function(pressed) {
         alert('Right button state ' + pressed);
     }
 },
 function(errorString) {
     alert('on error ' + errorString);
 });

registerConnectionCallback(callback, onError)

Register a callback function for connection events. If no callbacks (null) is passed to this function, all present callbacks will be cleared. Please be aware that it is possible to miss connection events if the Grabba is connected prior to calling this function. To avoid any issues you can check if the Grabba was already connected using grabba.isConnected(onSuccess, onError)
Parameters:
Name Type Description
callback function Called on connection event with the following parameters:
{boolean} Connected state.
onError function Called on error with the following parameters:
{String} error description.
Example
//Register for connection events
 grabba.registerConnectionCallback(function(isConnected) {
     alert('Connected state: ' + isConnected);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });

registerExclusiveAccessCallback(callback, onError)

Register a callback function for exclusive access events. If no callbacks (null) is passed to this function, all present callbacks will be cleared.
Parameters:
Name Type Description
callback function Called on exclusive access event with the following parameters:
{boolean} Gained/lost exclusive access to the Grabba.
onError function Called on error with the following parameters:
{String} error description.
Example
//Register for exclusive access events
 grabba.registerExclusiveAccessCallback(function(haveAccess) {
     alert('exclusive access ' + haveAccess);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });

savePreferences(onSuccess, onError)

Commit all preference changes to persistent memory and also to the Grabba hardware. Before calling this function, some (but not all) preference values may be in effect, so it is recommended to save the preferences as soon as possible after modification.
Parameters:
Name Type Description
onSuccess function Invoked on success.
onError function Called on error with the following parameters:
{String} error description.
See:

setBoolPref(boolPrefID, newBoolValue, onSuccess, onError)

Set the value of a given boolean preference. grabba.savePreferences must be called to commit preference changes on some platforms.
Parameters:
Name Type Description
boolPrefID String Boolean preference ID. Preference IDs can be found under each respective class's preferences member.
newBoolValue boolean New preference value.
onSuccess function Invoked on success.
onError function Called on error with the following parameters:
{String} error description.
See:

setIntPref(intPrefID, newIntValue, onSuccess, onError)

Set the value of a given integer preference. grabba.savePreferences must be called to commit preference changes on some platforms.
Parameters:
Name Type Description
intPrefID String Integer preference ID. Preference IDs can be found under each respective class's preferences member.
newIntValue int New preference value.
onSuccess function Invoked on success.
onError function Called on error with the following parameters:
{String} error description.
See: