Class: GrabbaProxcard

GrabbaProxcard

Access this class via grabba.proxcard

Constructor

new GrabbaProxcard()

Access Grabba proxcard capabilities via grabba.proxcard

Methods

isSupported(onSuccess, onError)

Determines if the currently connected Grabba supports proxcard functionality.
Parameters:
Name Type Description
onSuccess function Called on success with the following parameters:
{boolean} Boolean indicating if GrabbaProxcard is supported.
onError function Called on error with the following parameters:
{String} error description.
Example
//Button to check if the connected Grabba supports proxcard functionality.
 <button onclick="grabba.proxcard.isSupported(function(supported){
 alert('Grabba proxcard supported is ' + supported);
 },
 function(errorString) {
     alert('on error ' + errorString);
 });">Is proxcard supported?</button>

registerCallback(callback, onError)

Register callbacks for Proxcard related events.
If no callbacks are passed to this function, all present callbacks will be cleared.
Parameters:
Name Type Description
callback Object An object which implements the following functions:
triggeredEvent : function(){}
Called when the proxcard scanner is triggered.

timeoutEvent : function(){}
Called when the proxcard scanner has timed out.

stoppedEvent : function(){}
Called when the proxcard scanner has stopped.

scannedEvent : function(proxcard){}
Called when a proxcard is scanned.
The returned object contains properties as follows:
{int[]} proxcard.data The scanned proxcard data.
{String} proxcard.type The scanned proxcard's type.
{int} proxcard.typeInt Integer representation of the proxcard's type.
onError function Called on error with the following parameters:
{String} error description.
Example
//An example of an implemented proxcard callback is as follows:
 grabba.proxcard.registerCallback(proxcardCallbacks, onError);
 var proxcardTimeoutFunction = function() {
     alert('Proxcard timed out');
 };
 var proxcardCallbacks = {
 //Functions may also be declared inline as seen here.
 triggeredEvent: function() {
     alert('Proxcard triggered');
 },
 //These functions are optional and unimplemented functions will simply not be called.
 //stoppedEvent : function () {
 //alert('Proxcard scanning stopped');
 //},
 scannedEvent: function(proxcard) {
 //proxcard contains data fields
 //Convert the data to a base 16 hex string
 var hexString = ons.grabba.util.integerArrayToHexString(proxcard.data);
     alert('Proxcard scanned event\n Data: ' + hexString + '\n' + "Type: " + proxcard.type);
 },
 //You may create a function separately as seen with proxcardTimeoutFunction here.
 timeoutEvent: proxcardTimeoutFunction
 };

trigger(onError, enable)

Starts or stops proxcard scanning.
To receive the proxcard events and scanned data, first register for callbacks using GrabbaProxcard#registerCallback and then call:
grabba.proxcard.trigger(onError, true)
To start the proxcard scanner and scan the proxcard.
Parameters:
Name Type Description
onError function Called on error with the following parameters:
{String} error description.
enable boolean Pass true to start scanning, false to stop.
See:
Example
<!--A button which starts the proxcard scanning process-->
<button onclick="grabba.proxcard.trigger(onError, true)">Trigger</button>