|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sap.ip.me.api.pios.connection.Connection
com.sap.ip.me.api.pios.rfid.RfidConnection
RfidConnection defines a connection (session) with a specific RFID reader. RFID operations are executed and results are returned within the context of the connection. Includes methods to list all supported tag types, identify tags in range and read/write operation on tags.
Example: Identify all tags within the RFID reader area of coverage and write some bytes to the first writable area of the first identified tag.
Connector connector = Connector.getInstance();
DriverInfo[] rfidDrivers = connector.listDrivers(ConnectionType.RFID);
RfidParameters rfidParams = new RfidParameters(rfidDrivers[0]);
RfidConnection rfidConnection = (RfidConnection)connector.open(rfidParams);
RfidTag[] tagList = rfidConnection.identify();
if(tagList.length > 0) {
RfidTagUserArea[] tagArea = tagList[0].getTagType().getUserWritableAreas();
if (tagArea.length > 0) {
int writableSize = tagArea[0].getEndPos() - tagArea[0].getStartPos() + 1;
byte[] dataBytes = new byte[writableSize];
new Random().nextBytes(dataBytes); //creates a byte array with random values
rfidConnection.write(tagList[0], tagArea[0].getStartPos(), dataBytes);
}
else {
System.out.println("Tag is read only!");
}
}
else {
System.out.println("No tags in range.");
}
rfidConnection.close();
Example: Program and lock a new tag id.
Connector connector = Connector.getInstance();
DriverInfo[] rfidDrivers = connector.listDrivers(ConnectionType.RFID);
RfidParameters rfidParams = new RfidParameters(rfidDrivers[0]);
RfidConnection rfidConnection = (RfidConnection)connector.open(rfidParams);
rfidConnection.programTagID(new byte[]{1,2,3,4,5});
rfidConnection.lockTagID("pwd".getBytes());
rfidConnection.close();
Example: Reset the first tag identified.
Connector connector = Connector.getInstance();
DriverInfo[] rfidDrivers = connector.listDrivers(ConnectionType.RFID);
RfidParameters rfidParams = new RfidParameters(rfidDrivers[0]);
RfidConnection rfidConnection = (RfidConnection)connector.open(rfidParams);
RfidTag[] tagList = rfidConnection.identify();
if(tagList.length > 0) {
rfidConnection.resetTagID(tagList[0], "pwd".getBytes()); //Unlocks a tag id and reset it's contents to zero.
}
rfidConnection.close();
To determine if a required RFID functionality is provided by a driver use a DriverInfo instance provided by the connector.
Example: Determine if the RFID driver supports the read method.
Connector connector = Connector.getInstance();
DriverInfo[] rfidDrivers = connector.listDrivers(ConnectionType.RFID);
if (rfidDrivers[0].isAttributeSupported(RfidConnection.Attributes.READ_SINGLE)) {
//Add some code here
}
else {
System.out.println("Read operation not supported by this driver.");
}
rfidConnection.close();
RfidParameters
,
Connection
,
RfidTag
,
RfidTagData
,
RfidTagType
Nested Class Summary | |
static interface |
RfidConnection.Attributes
Contains all possible attribute names for RFID. |
Field Summary |
Fields inherited from class com.sap.ip.me.api.pios.connection.Connection |
attributesFileName, cfgFile, opened, parameters |
Constructor Summary | |
protected |
RfidConnection()
Constructs a new RFID connection. |
Method Summary | |
abstract TagConfigurationManager |
getTagConfigurationManager()
Returns the TagConfigurationManager object for this RFID connection. |
abstract RfidTagType |
getTagType(java.lang.String typeName)
Returns an RfidTagType object containing the tag type information for the specified tag type configuration name. |
abstract RfidTag[] |
identify()
Returns all the tags available within the RFID reader area of coverage. |
abstract RfidTag[] |
identify(RfidTagType tagType)
Returns all the tags available within the RFID reader area of coverage that matches the tag type specified. |
abstract RfidTagType[] |
listTagTypes()
Returns an RfidTagType array containing the tag types supported by the selected RFID reader. |
abstract void |
lockTagID(byte[] password)
The lockTagID function locks a tag id so it cannot be changed. |
abstract void |
programTagID(byte[] newTagID)
Programs a tag with a new TagID. |
abstract RfidTagData |
read(RfidTag tag,
int startPos,
int length)
Reads bytes from the selected tag. |
abstract void |
resetTagID(RfidTag tag,
byte[] password)
Resets a tag id, making it programmable again. |
abstract void |
write(RfidTag tag,
int startPos,
byte[] data)
Writes bytes to the selected tag. |
Methods inherited from class com.sap.ip.me.api.pios.connection.Connection |
close, getParameters, isOpen, open |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected RfidConnection() throws PIOSException
PIOSException
- thrown if an error is detected while creating or
opening an RFID connection.Method Detail |
public abstract RfidTag[] identify() throws RfidException, UnsupportedException
RfidException
- thrown if an error occurs while communicating with the RFID engine.
UnsupportedException
- thrown if the identify method is not supported
by the RFID engine.public abstract RfidTag[] identify(RfidTagType tagType) throws RfidException, UnsupportedException
tagType
- the tag type object containing the tag type to identify
RfidException
- thrown if an error occurs while communicating with the RFID engine.
UnsupportedException
- thrown if the identify by tag type method is not supported
by the RFID engine.public abstract RfidTagData read(RfidTag tag, int startPos, int length) throws RfidException, UnsupportedException
tag
- the RfidTag object containing the tag to readstartPos
- the starting byte position to perform the read operationlength
- the amount of bytes to read
RfidException
- thrown if an error occurs while communicating with the RFID engine or
the specified tag could not be read.
UnsupportedException
- thrown if the read method is not supported
by the RFID engine.public abstract void write(RfidTag tag, int startPos, byte[] data) throws RfidException, UnsupportedException
tag
- the RfidTag object containing the tag to writestartPos
- the starting byte position to perform the write operationdata
- the byte representation of the data to write
RfidException
- thrown if an error occurs while communicating with the RFID engine or
the specified tag could not be written.
UnsupportedException
- thrown if the write method is not supported
by the RFID engine.public abstract void programTagID(byte[] newTagID) throws RfidException, UnsupportedException
newTagID
- the byte representation of the tag id to write
RfidException
- thrown if an error occurs while communicating with the RFID engine or
the specified tag id could not be programmed.
UnsupportedException
- thrown if the program tag id method is not supported
by the RFID engine.public abstract void lockTagID(byte[] password) throws RfidException, UnsupportedException
password
- the password used to lock a tag. This password must be used when unlocking the tag.
Password required length or contents may vary depending on the type of tag being used.
The RfidTagType class can be used to obtain information about password requirements
RfidException
- thrown if an error occurs while communicating with the RFID engine or
the specified tag id could not be locked.
UnsupportedException
- thrown if the lock tag id method is not supported
by the RFID engine.public abstract void resetTagID(RfidTag tag, byte[] password) throws RfidException, UnsupportedException
tag
- the RfidTag object containing the tag to reset.password
- the password previously used to lock the tag.
The password provided must match the password used to lock the tag.
RfidException
- thrown if an error occurs while communicating with the RFID engine or
the specified tag id could not be unlocked or erased.
UnsupportedException
- thrown if the reset tag id method is not supported
by the RFID engine.public abstract RfidTagType[] listTagTypes() throws RfidException
RfidException
- thrown if an error occurs while communicating with the RFID driver.public abstract RfidTagType getTagType(java.lang.String typeName) throws RfidException
typeName
- tag type configuration name specified on the configuration file
RfidException
- thrown if an error occurs while communicating with the RFID driver or
if the specified tag type was not configured.public abstract TagConfigurationManager getTagConfigurationManager() throws ConfigurationException
ConfigurationException
- thrown when unable to return the
tag configuration manager for this connection.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |