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"/>
Device
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.
|
MSROperationResult |
waitForSwipe(int timeout)
A synchronous version of
listenForSwipe(OperationListener, int) . |
cancelRequest, close, getFailCount, getUsageCount, open
void open(int logicalID) throws DeviceException
logicalID
- The logical ID of the MSR device.DeviceException
- for standard reasons as documented in DeviceException
.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
,
MSRTrackData
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
.