完成 handehuoe驱动更新

master
wanghao 6 months ago
parent 6d2031f1a4
commit 3aab607a3f

@ -16,7 +16,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { ndk {
// SO // SO
abiFilters 'arm64-v8a' , 'armeabi' , 'armeabi-v7a' abiFilters 'arm64-v8a' , 'armeabi' , 'armeabi-v7a'
} }
} }

@ -43,10 +43,23 @@ public class BFActivity extends BaseActivity implements TakePictureDialog.dialog
dataBinding.setVm(wm); dataBinding.setVm(wm);
takeDialog = new TakePictureDialog(this); takeDialog = new TakePictureDialog(this);
takeDialog.setCall(this); takeDialog.setCall(this);
setPower(SharedPreferencesUtils.getInt("powerScrap", 17));
bitmaps = new ArrayList<>(); bitmaps = new ArrayList<>();
files = new ArrayList<>(); files = new ArrayList<>();
} }
@Override
protected void onResume() {
super.onResume();
setPower(SharedPreferencesUtils.getInt("powerScrapIn",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
}
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
}
@Override @Override
protected void sanRfid(List<Reader.TAGINFO> epcs) { protected void sanRfid(List<Reader.TAGINFO> epcs) {

@ -194,8 +194,12 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void offCheckRead(View view) { public void offCheckRead(View view) {
var b = checkState.get(); var b = checkState.get();
if (b) { if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
} else { } else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0); handler.postDelayed(runnable, 0);
} }
checkState.set(!b); checkState.set(!b);
@ -214,7 +218,7 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void run() { public void run() {
// sendBroadcast(broadcastIntent); // sendBroadcast(broadcastIntent);
sanEpc(); sanEpc();
handler.postDelayed(runnable, 1000); handler.postDelayed(runnable, 50);
} }
}; };
@ -243,4 +247,14 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void returnListSize(int size) { public void returnListSize(int size) {
binding.confirmPictureNumber2.setText(bitmaps.size() + ""); binding.confirmPictureNumber2.setText(bitmaps.size() + "");
} }
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler = null;
runnable = null;
}
} }

@ -33,7 +33,22 @@ public class FpInActivity extends BaseActivity {
ActivityFpInBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_fp_in); ActivityFpInBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_fp_in);
vm = new FpInVm(); vm = new FpInVm();
binding.setVm(vm); binding.setVm(vm);
}
@Override
protected void onResume() {
super.onResume();
setPower(SharedPreferencesUtils.getInt("powerScrapIn",17)); setPower(SharedPreferencesUtils.getInt("powerScrapIn",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
}
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
} }
@Override @Override

@ -45,7 +45,7 @@ public class FpOutActivity extends BaseActivity {
binding.setAdapter(adapter); binding.setAdapter(adapter);
tagList=new ArrayList<>(); tagList=new ArrayList<>();
initRequest(); initRequest();
setPower(SharedPreferencesUtils.getInt("powerScrapOut",17)); setPower(SharedPreferencesUtils.getInt("powerScrapOut",33));
} }
private List<String> tagList; private List<String> tagList;
@ -87,8 +87,12 @@ public class FpOutActivity extends BaseActivity {
public void fp_out_read(View view) { public void fp_out_read(View view) {
var b = checkState.get(); var b = checkState.get();
if (b) { if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
} else { } else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0); handler.postDelayed(runnable, 0);
} }
checkState.set(!b); checkState.set(!b);
@ -139,7 +143,11 @@ public class FpOutActivity extends BaseActivity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler=null; handler=null;
runnable=null; runnable=null;
} }
} }

@ -21,6 +21,8 @@ import com.example.beijing_daxing.databinding.ActivityHomePageBinding;
import com.example.beijing_daxing.been.HomeIcon; import com.example.beijing_daxing.been.HomeIcon;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -34,11 +36,10 @@ public class HomePageActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ActivityHomePageBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_home_page); ActivityHomePageBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_home_page);
initUi(binding); initUi(binding);
/* myNetWorkReceiver=new MyNetWorkReceiver(); UHFRManager instance = UHFRManager.getInstance();
IntentFilter intentFilter = new IntentFilter(); MyApplication.getApplication().setUhfrManager(instance);
intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); instance.setRegion(Reader.Region_Conf.RG_PRC);
registerReceiver(myNetWorkReceiver, intentFilter);*/ instance.setPower(33,33);
} }
@ -62,10 +63,10 @@ public class HomePageActivity extends AppCompatActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
var uhfLongerManager = MyApplication.getUhfLongerManager(); var uhfLongerManager = MyApplication.getApplication().getUhfrManager();
uhfLongerManager.asyncStopReading(); uhfLongerManager.asyncStopReading();
uhfLongerManager.close(); uhfLongerManager.close();
MyApplication.uhfLongerManager = null; MyApplication.getApplication().setUhfrManager(null);
Log.e("TAG", "关闭" ); Log.e("TAG", "关闭" );
// unregisterReceiver(myNetWorkReceiver); // unregisterReceiver(myNetWorkReceiver);
} }

@ -67,6 +67,7 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
protected void sanRfid(List<Reader.TAGINFO> epcs) { protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.stream().forEach(t -> { epcs.stream().forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length); var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
Log.e("TAG", "sanRfid:" + epc);
if (!epc.substring(0,8).equals("53574C44")) return; if (!epc.substring(0,8).equals("53574C44")) return;
if (tagList.contains(epc)) return; if (tagList.contains(epc)) return;
tagList.add(epc); tagList.add(epc);
@ -126,8 +127,6 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
private Runnable runnable = new Runnable() { private Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
// Log.e("TAG", "发送广播读取RFID");
// sendBroadcast(broadcastIntent);
sanEpc(); sanEpc();
handler.postDelayed(runnable, 50); handler.postDelayed(runnable, 50);
} }
@ -135,8 +134,12 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
public void instore_check(View view) { public void instore_check(View view) {
var b = checkState.get(); var b = checkState.get();
if (b) { if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
} else { } else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0); handler.postDelayed(runnable, 0);
} }
checkState.set(!b); checkState.set(!b);
@ -146,6 +149,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
handler = null; handler = null;
runnable = null; runnable = null;

@ -4,6 +4,7 @@ import androidx.databinding.DataBindingUtil;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.example.beijing_daxing.adapter.InAdapter; import com.example.beijing_daxing.adapter.InAdapter;
@ -51,12 +52,15 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
setPower(SharedPreferencesUtils.getInt("powerOut",17)); setPower(SharedPreferencesUtils.getInt("powerOut",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
} }
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override
protected void sanRfid(List<Reader.TAGINFO> epcs) { protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.forEach(t -> { epcs.forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length); var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
Log.e("TAG", "sanRfid:" + epc);
if (!epc.startsWith("53574C44")) return; if (!epc.startsWith("53574C44")) return;
if (tagList.contains(epc)) return; if (tagList.contains(epc)) return;
tagList.add(epc); tagList.add(epc);
@ -103,4 +107,10 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
}); });
} }
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
}
} }

@ -110,8 +110,12 @@ public class StoreCheckActivity extends BaseActivity {
public void check_read(View view) { public void check_read(View view) {
var b = checkState.get(); var b = checkState.get();
if (b) { if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
} else { } else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0); handler.postDelayed(runnable, 0);
} }
checkState.set(!b); checkState.set(!b);
@ -160,6 +164,8 @@ public class StoreCheckActivity extends BaseActivity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler = null; handler = null;
runnable = null; runnable = null;
} }

@ -40,8 +40,8 @@ import java.util.List;
import okhttp3.MediaType; import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity { public abstract class BaseActivity extends AppCompatActivity {
public static String url = "http://192.168.137.1:8090/api"; // public static String url = "http://192.168.137.1:8090/api";
// public static String url = "http://119.45.202.115:8090/api"; public static String url = "http://119.45.202.115:8090/api";
public ProgressDialog dialog; public ProgressDialog dialog;
public Gson gson; public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
@ -67,10 +67,8 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false); var keydown = intent.getBooleanExtra("keydown", false);
Log.e("TAG", "接收到广播:" + keydown); Log.e("TAG", "接收到广播:" + keydown);
if (!keydown) { if (!keydown) {
// readTime = System.currentTimeMillis();
sanEpc(); sanEpc();
} }
} }
@ -78,11 +76,9 @@ public abstract class BaseActivity extends AppCompatActivity {
public void sanEpc() { public void sanEpc() {
List<Reader.TAGINFO> strings = uhfLongerManager.tagInventoryRealTime(); List<Reader.TAGINFO> strings = uhfLongerManager.tagInventoryRealTime();
// Log.e("TAG", "驱动" + (uhfLongerManager == null));
if (strings == null || strings.isEmpty()) { if (strings == null || strings.isEmpty()) {
return; return;
} }
mediaPlayer.start(); mediaPlayer.start();
sanRfid(strings); sanRfid(strings);
} }
@ -96,11 +92,7 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
private void initSan() { private void initSan() {
uhfLongerManager = MyApplication.getUhfLongerManager(); uhfLongerManager = MyApplication.getApplication().getUhfrManager();
// intentFilter.addAction("android.intent.action.FUN_KEY");
uhfLongerManager.asyncStartReading();
myReceiver = new MyReceiver(); myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY"); intentFilter.addAction("android.rfid.FUN_KEY");
@ -112,7 +104,6 @@ public abstract class BaseActivity extends AppCompatActivity {
try { try {
Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power); Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr.name()); Log.e("TAG", "setPower:" + readerErr.name());
int[] power1 = uhfLongerManager.getPower(); int[] power1 = uhfLongerManager.getPower();
Log.e("TAG", "readPower:" + power1[0] + "," + power1[1]); Log.e("TAG", "readPower:" + power1[0] + "," + power1[1]);
} catch (Exception e) { } catch (Exception e) {

@ -38,8 +38,8 @@ import okhttp3.OkHttpClient;
*/ */
public class MyApplication extends Application { public class MyApplication extends Application {
MyApplication application; private static MyApplication application;
public static UHFRManager uhfLongerManager; private UHFRManager uhfrManager;
@Override @Override
public void onCreate() { public void onCreate() {
@ -60,18 +60,18 @@ public class MyApplication extends Application {
.init(this); .init(this);
} }
public static UHFRManager getUhfLongerManager() { public static MyApplication getApplication() {
if (uhfLongerManager==null){ return application;
try {
uhfLongerManager = UHFRManager.getInstance();
uhfLongerManager.setPower(33,33);
} catch (Exception e) {
e.printStackTrace();
}
}
return uhfLongerManager;
} }
public UHFRManager getUhfrManager() {
return uhfrManager;
}
public void setUhfrManager(UHFRManager uhfrManager) {
this.uhfrManager = uhfrManager;
}
// OKGO 初始化 // OKGO 初始化
private void okGoBase() { private void okGoBase() {
OkHttpClient.Builder builder = new OkHttpClient.Builder(); OkHttpClient.Builder builder = new OkHttpClient.Builder();

@ -1,10 +0,0 @@
package com.example.beijing_daxing.rfid;
public interface RFID {
void initRFIDModel();
void setPower(int power);
void sanRFID();
void close();
}

@ -1,60 +0,0 @@
package com.example.beijing_daxing.rfid.impl;
import android.util.Log;
import com.example.beijing_daxing.rfid.RFID;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.List;
public class Device6109 implements RFID {
private UHFRManager uhfrManager;
private EpcDataInterface epcDataInterface;
public Device6109(EpcDataInterface epcDataInterface) {
this.epcDataInterface = epcDataInterface;
}
public Device6109() {
}
@Override
public void initRFIDModel() {
if (uhfrManager == null) {
uhfrManager = UHFRManager.getInstance();
}
uhfrManager.asyncStartReading();
}
@Override
public void setPower(int power) {
Reader.READER_ERR readerErr = uhfrManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr);
}
@Override
public void sanRFID() {
List<Reader.TAGINFO> data = uhfrManager.tagInventoryRealTime();
if (data == null || data.isEmpty()) {
return;
}
epcDataInterface.epcData(data);
}
@Override
public void close() {
if (uhfrManager == null) {
return;
}
uhfrManager.asyncStopReading();
uhfrManager.close();
uhfrManager = null;
}
public interface EpcDataInterface {
void epcData(List<Reader.TAGINFO> data);
}
}
Loading…
Cancel
Save