UHF模块 A8操作类
UHF module operation type
第一步:通过
RFIDWithUHFUART.init(Context context)
连接读写器。
Step 1: Connect to the usb of the reader via
RFIDWithUHFUART.init(Context context)
第二步: 如果是设置参数,连接成功之后,调用对应的函数设置参数、读写操作。
如果是盘点调用
RFIDWithUHFUART.startInventoryTag()
函数开始执行盘点。
注意: 在盘点标签的时候rfid模块只能响应
RFIDWithUHFUART.stopInventory()
函数。
Step 2: If it is to set parameters, after the connection is successful, call the corresponding function to set parameters, read and write operations.
* If the inventory label is to call
RFIDWithUHFUART.startInventoryTag()
function to start the inventory.
* Note: The rfid module can only respond to the
RFIDWithUHFUART.stopInventory()
function when inventorying tags.
第三步:退出app调用
RFIDWithUHFUART.free()
断开连接,如果断开之前正在盘点,请先停止盘点,在断开连接。
Step 3: Exit the app and call
RFIDWithUHFUART.free()
to disconnect. If you are taking inventory before disconnecting, please stop the inventory first and then disconnecting.
Example Usage:
public class UHFDemo() {
RFIDWithUHFA8 rfid = RFIDWithUHFA8.getInstance();
boolean isInventory=false;
public void uhf(){
boolean result = rfid.init(context);
if (!result) {
//connect fail
return;
}
//connect success
//configuration parameters
// rfid.setFrequencyMode(xx);
// rfid.setPower(30);
if (rfid.startInventoryTag()) {
//success
isInventory=true;
new ThreadInventory().start();
} else {
rfid.stopInventory();
//fail
}
//..............
rfid.stopInventory();
isInventory=false;
//.................
//disconnect uhf
rfid.free();
}
private class ThreadInventory extends Thread{
@Override
public void run(){
while (isInventory){
UHFTAGInfo uhftagInfo= rfid.readTagFromBuffer();
if(uhftagInfo==null){
Thread.sleep(20);
continue;
}
String epc= uhftagInfo.getEPC();
String rssi= uhftagInfo.getRssi();
//.....
}
}
}
}