修改 设备异常后重新获取实例

master
wangh 5 months ago
parent c763aa21ae
commit 730e2cfa3a

@ -31,10 +31,10 @@
<activity <activity
android:name=".AppLoginActivity" android:name=".AppLoginActivity"
android:exported="true"> android:exported="true">
<intent-filter> <!-- <intent-filter>-->
<action android:name="android.intent.action.MAIN" /> <!-- <action android:name="android.intent.action.MAIN" />-->
<category android:name="android.intent.category.LAUNCHER" /> <!-- <category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter> <!-- </intent-filter>-->
</activity> </activity>
<activity <activity
android:name=".ReadActivity" android:name=".ReadActivity"
@ -47,10 +47,10 @@
<activity <activity
android:name=".WriteUserActivity" android:name=".WriteUserActivity"
android:exported="true"> android:exported="true">
<!-- <intent-filter>--> <intent-filter>
<!-- <action android:name="android.intent.action.MAIN" />--> <action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" />--> <category android:name="android.intent.category.LAUNCHER" />
<!-- </intent-filter>--> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".ConfigurationTableActivity" android:name=".ConfigurationTableActivity"

@ -64,8 +64,8 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
binding.setAdapter(adapter); binding.setAdapter(adapter);
// 名称 // 名称
stringArray = getResources().getStringArray(R.array.project_list); stringArray = getResources().getStringArray(R.array.project_list);
rfidModel = new C5106Device(this,this); // rfidModel = new C5106Device(this,this);
// rfidModel=new AutoID9UDevice(this,this); rfidModel=new AutoID9UDevice(this,this);
} }

@ -58,8 +58,8 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
popupMenu = new PopupMenu(this, binding.writeMenu); popupMenu = new PopupMenu(this, binding.writeMenu);
popupMenu.setOnMenuItemClickListener(this); popupMenu.setOnMenuItemClickListener(this);
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu()); getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
rfidModel = new C5106Device(this,this); // rfidModel = new C5106Device(this,this);
// rfidModel=new AutoID9UDevice(this,this); rfidModel=new AutoID9UDevice(this,this);
} }

@ -85,21 +85,32 @@ public class AutoID9UDevice implements RFIDModel {
public void sanUser(int len) { public void sanUser(int len) {
var power = uhfService.getPower(); var power = uhfService.getPower();
Log.e("TAG", "设备功率:" + power); Log.e("TAG", "设备功率:" + power);
if (power==0){
uhfService.close();
uhfService = UHFService.getInstance();
uhfService.open();
Log.e("TAG", "设备功率:" + uhfService.getPower());
}
if (id==null){
String info = null;
EPC epc=new EPC();
var result = uhfService.inventoryOnce(epc, 100);
Log.e("TAG", "单次寻卡:" + result);
Log.e("TAG", "epcid:" + epc.getId());
id=epc.getId();
return;
}
String info = null; // if (result) {
EPC epc=new EPC();
var result = uhfService.inventoryOnce(epc, 100);
Log.e("TAG", "epcid:" + epc.getId());
if (result) {
var i = len * 2; var i = len * 2;
byte[] data = new byte[i]; byte[] data = new byte[i];
result = uhfService.readTagData(AutoID9UUtil.getHexByteArray(epc.getId()), password, 3, 0, i, data); var result = uhfService.readTagData(AutoID9UUtil.getHexByteArray(id), password, 3, 0, i, data);
Log.e("TAG", "按长度读取:" + result); Log.e("TAG", "按长度读取:" + result);
if (result) { if (result) {
info = Tools.Bytes2HexString(data, data.length); var info = Tools.Bytes2HexString(data, data.length);
} }
} // }
call.readUserInfo(info,result,null); // call.readUserInfo(info,result,null);
} }
@Override @Override

Loading…
Cancel
Save