import com.phidgets.PhidgetException;
import com.phidgets.RFIDPhidget;
import com.phidgets.event.TagGainEvent;
import com.phidgets.event.TagGainListener;
import com.phidgets.event.TagLossEvent;
import com.phidgets.event.TagLossListener;

public class rfidex1 implements TagLossListener, TagGainListener {

    public static void main(String[] args) throws PhidgetException {
        new rfidex1();
    }

    public rfidex1() throws PhidgetException {

        RFIDPhidget phid = new RFIDPhidget();
        phid.addTagLossListener(this);
        phid.addTagGainListener(this);

        phid.openAny();
        phid.waitForAttachment();

        System.out.println(phid.getDeviceType());
        System.out.println("Serial Number " + phid.getSerialNumber());
        System.out.println("Device Version " + phid.getDeviceVersion());
        System.out.println("Attached " + phid.isAttached());
        phid.setLEDOn(true);
        phid.setAntennaOn(true);

        // sleeping around, just to avoid the program finishing
        while (true)
            try {
                Thread.sleep(1000);
            } catch (Throwable t) {
                t.printStackTrace();
            }
    }

    public void tagLost(TagLossEvent arg0) {
        System.out.println(arg0);
    }

    public void tagGained(TagGainEvent arg0) {
        System.out.println(arg0);
    }
}
