Skip to content

radlib/radlib-cordova

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

RadLib

An Apache Cordova plugin that allows for interfacing mobile applications with RFID tag readers. ######The currently supported readers are as follows:

######Supported Platforms

  • Android 4.4+

If you're comfortable with JavaScript, HTML, and CSS, it's easy to make your own app with RadLib!

#Installation - Quick Start Make sure you have the Cordova Command-Line Interface and the Android SDK installed.

Run the command git clone https://github.com/radlib/radlib-cordova.git to download all the files for our sample application. If you have an Android hardware device, you can run cordova run android to flash the demo application to your device.

#Installation - Starting from Scratch The plugin can be found at the Cordova Plugin Registry.

  1. Make sure an up-to-date version of Node.js is installed, then install the Cordova Command-Line Interface:

    npm install -g cordova
    
  2. Create a project and add platforms (please see list below for supported platforms)

    cordova create my_sample_app  
    cd my_sample_app  
    cordova platform add android  
    
  3. Add the plugin to your project

    cordova plugin add com.radlib.cordova.rfidreader
    
  4. Build and run, using the commands

    cordova build android  
    cordova emulate android
    

    or (if hardware device attached)

    cordova run android
    

#Using RadLib The plugin declares two global objects, radlib and bluetoothUtils.

The radlib object has two functions, connect() and scan():

radlib.scan = function (success, failure, connectionTypes);
Description: scans for nearby devices based on the connectionType(s) specified.
success A function that is called back on success. On success, the callback function will be provided with an array of objects with the following properties:
  • name: name of the found device
  • address: address of the found device
  • connectionType: an array of connection type strings. Currently only ["BLUETOOTH"] is supported.
failure A function that is called back on failure. Failure includes providing an invalid connectionTypes value
connectionTypes An array of connectionType to scan for. Currently the only supported value for connectionTypes is ["BLUETOOTH"]
radlib.connect = function (success, failure, reader);
Description: connects to a specified reader.
success A function that is called back on success. On success, the callback function will be provided with an object with the following properties:
  • id: id of tag that was read
  • reader: device name of the reader
  • time: time the frame was read in the form HH:mm:ss AM/PM
  • date: date the frame was read in the form MM:dd:yyyy
  • frame: the frame of data which was parsed
  • friendlyName: user specified name sent in through the reader object
  • report: a string with value "seen" or "lost"
    • For continuous readers, like the "ARDUINO_RC522_LF", report is “seen” on tag reads and “lost” on tag lost
    • For trigger readers, like the “TSL_1128_UHF” or Barcode Scanner, report is always “seen”
failure A function that is called back on failure. Failure includes failing to connect to the specified device or providing a wrong property to reader.
reader An object with the following required properties:
  • model: model of the reader device (only required for "BLUETOOTH" connectionType). Current accepted models are "ARDUINO_RC522_HF" or "TSL_1128_UHF"
  • address: address of the reader device (only required for "BLUETOOTH" connectionType)
  • connectionType: type of connection for device. Currently only "BLUETOOTH" and "CAMERA" are supported
and the following optional property:
  • friendlyName: a user specified name to help differentiate between readers
    • Note: the required properties for this reader object are similar to what is returned in scan(). It is possible to save the object obtained from scan(), add a model property to it, and then use it for connect().

The bluetoothUtils object has three functions: turnOnBluetooth(), turnOffBluetooth(), and stopDiscovery():

bluetoothUtils.turnOnBluetooth = function(success, failure);
Description: enables the Bluetooth module located in the Android phone
success Callback function providing a success message
failure Callback function providing a failure message
bluetoothUtils.turnOffBluetooth = function(success, failure);
Description: disables the Bluetooth module located in the Android phone
success Callback function providing a success message
failure Callback function providing a failure message
bluetoothUtils.stopDiscovery = function(success, failure);
Description: tells the bluetooth device to finish up looking nearby bluetooth devices. This function only needs to be called if radlib.scan() for Bluetooth is to be stopped prematurely.
success Callback function providing a success message
failure Callback function providing a failure message

About

All the files in the www folder in the apache cordova directory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •