public interface MSRDevice extends Device, TimeConstants
MSRDevice interface defines the API for interacting with Magnetic Stripe Reader (MSR) devices.
This interface allows applications to control the MSR device and read data from magnetic stripe cards.
An instance of MSRDevice is obtained as follows:
MSRDevice msrDevice = (MSRDevice) POSTerminal.getInstance().getDevice("com.cloudpos.device.msr");
The identifier "com.cloudpos.device.msr" is used to specify the MSR device in the specific implementation.
Applications must request permission to access the MSR device:
<uses-permission android:name="android.permission.CLOUDPOS_MSR"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_GET_PIN_BLOCK"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_MAC"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_ENCRYPT_DATA"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_UPDATE_USER_KEY"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_UPDATE_MASTER_KEY"/>
<uses-permission android:name="android.permission.CLOUDPOS_PIN_LOAD_KEY"/>
Device| Modifier and Type | Field and Description |
|---|---|
static int |
TYPE_F6L4
Display the first 6 characters and the last 4 characters of the plain text, and replace the middle data with '*'
|
static int |
TYPE_F8L4
Display the first 8 characters and the last 4 characters of the plain text, and replace the middle data with '*'
|
FOREVER, IMMEDIATE, MilliSECOND, SECOND| Modifier and Type | Method and Description |
|---|---|
void |
listenForSwipe(OperationListener listener,
int timeout)
Initiates an asynchronous operation to read data from selected tracks of a swiped card.
|
void |
open(int logicalID)
Opens a connection to the MSR device using a specified logical ID.
|
void |
open(int logicalID,
KeyInfo keyinfo,
int enMode,
byte[] iv,
int truncType)
Opens a connection to the MSR device using a specified logical ID.
|
MSROperationResult |
waitForSwipe(int timeout)
A synchronous version of
listenForSwipe(OperationListener, int). |
cancelRequest, close, getFailCount, getUsageCount, openstatic final int TYPE_F6L4
static final int TYPE_F8L4
void listenForSwipe(OperationListener listener, int timeout) throws DeviceException
This method supports timeout management; hence, the device must be capable of responding to cancelRequest() to abort the operation if necessary.
In case of a timeout, the result will contain an error code OperationResult.ERR_TIMEOUT.
listener - The listener to handle operation results.timeout - Maximum time to wait for a card swipe, in milliseconds. Special values:
TimeConstants.FOREVER for indefinite waiting,
TimeConstants.IMMEDIATE for immediate input reading.DeviceException - for standard reasons as documented in DeviceException.OperationListener.handleResult(com.cloudpos.OperationResult),
MSROperationResult,
MSRTrackDatavoid open(int logicalID) throws DeviceException
logicalID - The logical ID of the MSR device.DeviceException - for standard reasons as documented in DeviceException.void open(int logicalID,
KeyInfo keyinfo,
int enMode,
byte[] iv,
int truncType)
throws DeviceException
logicalID - The logical ID of the MSR device.keyinfo - Details of the key used for encryption.enMode - Encryption mode: MODE_EBC(0), MODE_CBC(1), MODE_CFB(2) or MODE_OFB.NoPadding(3).truncType - The default format of truncated PAN in (@@link #TYPE_F6L4 or #TYPE_F8L4).DeviceException - for standard reasons as documented in DeviceException.MSROperationResult waitForSwipe(int timeout) throws DeviceException
listenForSwipe(OperationListener, int).
Blocks the calling thread until data is received, the operation times out, or it is canceled.timeout - Maximum time to wait for a card swipe, in milliseconds. Special values:
TimeConstants.FOREVER for indefinite waiting,
TimeConstants.IMMEDIATE for immediate input reading.DeviceException - for standard reasons as documented in DeviceException.