-
Notifications
You must be signed in to change notification settings - Fork 1
hid_hf_external_integration
This application illustrates how to use the HID HF RFID reader on Coppernic C-One device using a snap-on.
Coppernic uses a Maven repository to provide libraries.
In the build.gradle, at project level, add the following lines:
allprojects {
repositories {
maven { url 'https://artifactory.coppernic.fr/artifactory/libs-release'}
}
}
CpcCore is the library responsible for power management.
In your build.gradle file, at module level, add the following lines:
compile 'fr.coppernic.sdk.core:CpcCore:1.0.0'
Power on/off the reader is performed using the RTS signal of the serial port created. It will be done after open command.
Use the SerialCom class in CpcCore.
First declare a SerialCom object:
private SerialCom serialCom;
Then instantiate it:
SerialFactory.getDirectInstance(this, this);
Where your activity implements InstanceListener:
@Override
public void onCreated(SerialCom serialCom) {
// Serial instance is obtained
this.serialCom = serialCom;
}
@Override
public void onDisposed(SerialCom serialCom) {
}
First open the serialCom object:
serialCom.open(SERIAL_PORT, getBaudrate());
serialCom.setRts(true);
where:
private static final String SERIAL_PORT = "/dev/ttyUSB0";
Then send commands:
byte[] command;
...
serialCom.send(command, command.length);
When powered up, reader is in continuous read mode. Before being able to use it, disable contiunous read mode:
private static final byte[] ABORT_CONTINUOUS_READ_COMMAND = new byte[]{'.'};
serialCom.send(ABORT_CONTINUOUS_READ_COMMAND, ABORT_CONTINUOUS_READ_COMMAND.length);