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.
-
Make sure an up-to-date version of Node.js is installed, then install the Cordova Command-Line Interface:
npm install -g cordova
-
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
-
Add the plugin to your project
cordova plugin add com.radlib.cordova.rfidreader
-
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:
|
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:
|
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:
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 |