Show TOC Start of Content Area

This graphic is explained in the accompanying textIdentify All  Locate the document in its SAP Library structure

In this example the RFID reader identifies all the tags, independently of the tag type, in the reader's range. The program performs the following steps:

...

       1.      Gets the RFID parameters from the first driver and, using them, opens the connection to the RFID reader.

       2.      Checks if the driver supports the "identify all" attribute and displays how many tags are in range.

       3.      Displays the tag ID and tag type for each of the detected RFID tags.

 

import com.sap.ip.me.api.pios.PIOSException;

import com.sap.ip.me.api.pios.connection.*;

import com.sap.ip.me.api.pios.rfid.*;

 

public class ExampleIdentifyAll {

 

   public static void main(String[] args) {

 

       RfidConnection rfidConnection = null;

 

       try {

 

          Connector connector = Connector.getInstance();

 

          //----------------------(1)--------------------

          DriverInfo[] rfidDrivers =

              connector.listDrivers(ConnectionType.RFID);

 

          if (rfidDrivers.length > 0) {

 

              RfidParameters rfidParams = new RfidParameters(rfidDrivers[0]);

 

              rfidConnection = (RfidConnection) connector.open(rfidParams);

 

              //----------------------(2)--------------------

              if (rfidDrivers[0]

                 .isAttributeSupported(

                     RfidConnection.Attributes.IDENTIFY_ALL)) {

 

                 RfidTag[] tagList = rfidConnection.identify();

 

                 if (tagList.length <= 0) {

 

                     System.out.println("There are no tags in range.");

 

                 } else {

 

                     System.out.println(

                        "Total tags: " + tagList.length + ".");

 

                 }

 

                 //----------------------(3)--------------------

                 for (int i = 0; i < tagList.length; i++) {

 

                     System.out.print("TagID: ");

 

                     for (int j = 0;

                        j < tagList[i].getTagID().length;

                        j++) {

 

                        System.out.print(tagList[i].getTagID()[j] + " ");

 

                     }

 

                     System.out.println(

                        "\t  tag type: "

                           + tagList[i].getTagType().getName());

                 }

              } else {

 

                 System.out.println(

                     "Required driver attribute is not supported.");

              }

          } else {

             

              System.out.println("There are no RFID drivers.");

 

          }

       } catch (Exception ex) {

 

          ex.printStackTrace();

 

       } finally {

 

          try {

 

              rfidConnection.close();

 

          } catch (PIOSException pex) {

 

              pex.printStackTrace();

 

          }

       }

   }

}

 

 

End of Content Area