更改驱动

idata
wanghao
parent 586a4a2c41
commit ef9ad2c0a1

@ -16,7 +16,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// SO
abiFilters 'armeabi' , 'armeabi-v7a'
abiFilters 'arm64-v8a' , 'armeabi' , 'armeabi-v7a'
}
}
@ -41,8 +41,14 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation files('libs\\uhflonger_v1.3.jar')
implementation files('libs\\App_Demo_API.jar')
implementation files('libs\\DeviceAPIver20150204.jar')
implementation files('libs\\logutil-1.5.1.1.jar')
implementation files('libs\\ModuleAPI_J.jar')
implementation files('libs\\reader(1).jar')
implementation files('libs\\UHF67_v3.6.jar')
// implementation files('libs\\uhflonger_v1.3.jar')
// implementation files('libs\\ModuleAPI_J.jar')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".base.MyApplication"
@ -15,11 +16,15 @@
android:roundIcon="@drawable/logo"
android:supportsRtl="true"
android:theme="@style/Theme.Beijingdaxing"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<receiver
android:name=".broadcast.MyNetWorkReceiver"
android:name=".base.BaseActivity$MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.rfid.FUN_KEY"/>
</intent-filter>
</receiver>
<activity
@ -57,10 +62,10 @@
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

@ -17,9 +17,12 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.example.beijing_daxing.vm.BFWm;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.List;
import cn.pda.serialport.Tools;
public class BFActivity extends BaseActivity {
private BFWm wm;
@Override
@ -31,12 +34,14 @@ public class BFActivity extends BaseActivity {
}
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
var epc = epcs.get(0);
wm.setEpc(epc);
byte[] epcId = epc.EpcId;
String epc1 = Tools.Bytes2HexString(epcId, epcId.length);
wm.setEpc(epc1);
OkGo.<MyResult>post(url+"/bf/select")
.tag(this)
.params("epc",epc)
.params("epc",epc1)
.execute(new MyRecultCall(dialog,this){
@Override
public void onSuccess(Response<MyResult> response) {

@ -24,12 +24,15 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import cn.pda.serialport.Tools;
public class CheckActivity extends BaseActivity implements AdapterClickCall, InPutDialog.InPutDialogCall {
private ActivityCheckBinding binding;
@ -48,7 +51,6 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
adapter = new CheckAdapter(this, this);
state = new ObservableBoolean();
checkState = new ObservableBoolean();
binding.setAdapter(adapter);
binding.setState(state);
binding.setCheckState(checkState);
@ -99,7 +101,7 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
// 扫描到返回数据
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
// var text = epcs.get(0);
// binding.checkEpc.setText(text);
@ -113,13 +115,14 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
// subIndex = index;
epcs.forEach(t -> {
var epc= Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (tagList.contains(t)) {
return;
}
tagList.add(t);
tagList.add(epc);
var stock = new Stock();
stock.setEpcCode(t);
stock.setEpcCode(epc);
var index = list.indexOf(stock);
if (index != -1) {
list.get(index).setState("正常");
@ -196,7 +199,8 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
private Runnable runnable = new Runnable() {
@Override
public void run() {
sendBroadcast(broadcastIntent);
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 1000);
}
};

@ -17,9 +17,12 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.example.beijing_daxing.vm.FpInVm;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.List;
import cn.pda.serialport.Tools;
public class FpInActivity extends BaseActivity {
private FpInVm vm;
@ -32,8 +35,9 @@ public class FpInActivity extends BaseActivity {
}
@Override
protected void sanRfid(List<String> epcs) {
var epc = epcs.get(0);
protected void sanRfid(List<Reader.TAGINFO> epcs) {
Reader.TAGINFO taginfo = epcs.get(0);
var epc = Tools.Bytes2HexString(taginfo.EpcId,taginfo.EpcId.length);
vm.setEpc(epc);
OkGo.<MyResult>post(url+"/fpin/select")
.tag(this).params("epc",epc)

@ -23,10 +23,13 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.List;
import cn.pda.serialport.Tools;
public class FpOutActivity extends BaseActivity {
private ObservableBoolean checkState;
private List<Stock> list;
@ -44,14 +47,16 @@ public class FpOutActivity extends BaseActivity {
private List<String> tagList;
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
if (tagList==null) return;
epcs.forEach(t -> {
if (tagList.contains(t)){
tagList.add(t);
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (tagList.contains(epc)){
tagList.add(epc);
return;
}
var stock = new Stock();
stock.setEpcCode(t);
stock.setEpcCode(epc);
var index = list.indexOf(stock);
if (index != -1) {
list.get(index).setState("Y");
@ -122,7 +127,8 @@ public class FpOutActivity extends BaseActivity {
private Runnable runnable = new Runnable() {
@Override
public void run() {
sendBroadcast(broadcastIntent);
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 1000);
}
};

@ -61,6 +61,7 @@ public class HomePageActivity extends AppCompatActivity {
protected void onDestroy() {
super.onDestroy();
var uhfLongerManager = MyApplication.getUhfLongerManager();
uhfLongerManager.asyncStopReading();
uhfLongerManager.close();
MyApplication.uhfLongerManager = null;
// unregisterReceiver(myNetWorkReceiver);

@ -19,10 +19,12 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.example.beijing_daxing.vm.InStoreVM;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.List;
import cn.pda.serialport.Tools;
import okhttp3.RequestBody;
public class InActivity extends BaseActivity implements AdapterClickCall {
@ -47,12 +49,13 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
}
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
// Log.e("TAG", "sanRfid:" + epcs);
epcs.stream().forEach(t -> {
if (!epcList.contains(t)) {
epcList.add(t);
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (!epcList.contains(epc)) {
epcList.add(epc);
}
});
vm.setSanLength(epcList.size());

@ -17,6 +17,7 @@ import com.example.beijing_daxing.vm.LoginVm;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.List;
@ -38,7 +39,7 @@ public class MainActivity extends BaseActivity {
}
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
}

@ -18,6 +18,7 @@ import com.example.beijing_daxing.base.BaseActivity;
import com.example.beijing_daxing.been.RFIDLocation;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ActivityOffLineCheckBinding;
import com.uhf.api.cls.Reader;
import org.litepal.LitePal;
@ -55,7 +56,7 @@ public class OffLineCheckActivity extends BaseActivity {
}
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
}
@ -79,7 +80,8 @@ public class OffLineCheckActivity extends BaseActivity {
private Runnable runnable = new Runnable() {
@Override
public void run() {
sendBroadcast(broadcastIntent);
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 1000);
}
};

@ -16,8 +16,12 @@ import com.example.beijing_daxing.vm.OutStoreVm;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.List;
import cn.pda.serialport.Tools;
import okhttp3.RequestBody;
public class OutActivity extends BaseActivity implements AdapterClickCall {
@ -39,10 +43,11 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
}
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.stream().forEach(t -> {
if (!epcList.contains(t)) {
epcList.add(t);
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
if (!epcList.contains(epc)) {
epcList.add(epc);
}
});
adapter.notifyDataSetChanged();

@ -25,10 +25,12 @@ import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.List;
import cn.pda.serialport.Tools;
import okhttp3.RequestBody;
public class StoreCheckActivity extends BaseActivity {
@ -48,16 +50,20 @@ public class StoreCheckActivity extends BaseActivity {
binding.setAdapter(checkAdapter);
initRequest();
}
private List<String> tagList;
@Override
protected void sanRfid(List<String> epcs) {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
if (tagList == null) return;
epcs.forEach(t -> {
if (tagList.contains(t)){
tagList.add(t);
return;
}
var epc = Tools.Bytes2HexString(t.EpcId, t.EpcId.length);
if (tagList.contains(epc)) {
tagList.add(epc);
return;
}
var stock = new Stock();
stock.setEpcCode(t);
stock.setEpcCode(epc);
var index = list.indexOf(stock);
if (index != -1) {
list.get(index).setState("Y");
@ -75,7 +81,7 @@ public class StoreCheckActivity extends BaseActivity {
if (body.getCode() == 0) {
list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
}.getType());
tagList=new ArrayList<>();
tagList = new ArrayList<>();
checkAdapter.setList(list);
checkAdapter.notifyDataSetChanged();
} else {
@ -97,20 +103,20 @@ public class StoreCheckActivity extends BaseActivity {
public void store_check_submit(View view) {
handler.removeCallbacks(runnable);
OkGo.<MyResult>post(url+"/storecheck/submit")
OkGo.<MyResult>post(url + "/storecheck/submit")
.tag(this)
.params("user", SharedPreferencesUtils.getstring("user","test"))
.params("json",gson.toJson(list))
.params("user", SharedPreferencesUtils.getstring("user", "test"))
.params("json", gson.toJson(list))
// .upRequestBody(RequestBody.create(JSON, gson.toJson(list)))
.execute(new MyRecultCall(dialog,this){
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode()==0){
if (body.getCode() == 0) {
finish();
Toast.makeText(StoreCheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
}else {
} else {
Toast.makeText(StoreCheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
}
@ -127,7 +133,9 @@ public class StoreCheckActivity extends BaseActivity {
private Runnable runnable = new Runnable() {
@Override
public void run() {
sendBroadcast(broadcastIntent);
Log.e("TAG", "发送广播读取RFID");
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 1000);
}
};
@ -136,7 +144,7 @@ public class StoreCheckActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
handler=null;
runnable=null;
handler = null;
runnable = null;
}
}

@ -18,7 +18,8 @@ import androidx.appcompat.app.AppCompatActivity;
import com.example.beijing_daxing.R;
import com.google.gson.Gson;
import com.handheld.UHFLonger.UHFLongerManager;
import com.handheld.uhfr.*;
import com.uhf.api.cls.Reader;
import java.util.List;
@ -26,15 +27,14 @@ import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity {
// public static String url = "http://192.168.0.102:8090/api";
public static String url = "http://175.27.215.92:8090/api";
public static String url = "http://119.45.202.115:8090/api";
public ProgressDialog dialog;
public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
public UHFLongerManager uhfLongerManager;
public UHFRManager uhfLongerManager;
private MediaPlayer mediaPlayer;
public MyReceiver myReceiver;
public Intent broadcastIntent;
public MyReceiver myReceiver;
public Intent broadcastIntent;
@SuppressLint("UnspecifiedRegisterReceiverFlag")
@Override
@ -43,9 +43,9 @@ public abstract class BaseActivity extends AppCompatActivity {
gson = new Gson();
initDialog();
initSan();
Intent intent = new Intent();
broadcastIntent = new Intent("android.rfid.FUN_KEY");
broadcastIntent.putExtra("keydown", false);
// broadcastIntent.setComponent(new ComponentName("com.example.beijing_daxing",".base.BaseActivity$MyReceiver"));
}
// private long readTime = 0;
@ -55,19 +55,24 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
if (!keydown ) {
Log.e("TAG", "接收到广播:" + keydown);
if (!keydown) {
// readTime = System.currentTimeMillis();
List<String> strings = uhfLongerManager.inventoryRealTime();
Log.e("TAG", "驱动"+(uhfLongerManager==null) );
if (strings == null || strings.isEmpty()) {
return;
}
mediaPlayer.start();
sanRfid(strings);
sanEpc();
}
}
}
public void sanEpc(){
List<Reader.TAGINFO> strings = uhfLongerManager.tagInventoryRealTime();
Log.e("TAG", "驱动" + (uhfLongerManager == null));
if (strings == null || strings.isEmpty()) {
return;
}
mediaPlayer.start();
sanRfid(strings);
}
private void initDialog() {
dialog = new ProgressDialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -75,15 +80,20 @@ public abstract class BaseActivity extends AppCompatActivity {
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("请求网络...");
}
private void initSan(){
private void initSan() {
uhfLongerManager = MyApplication.getUhfLongerManager();
// intentFilter.addAction("android.intent.action.FUN_KEY");
uhfLongerManager.asyncStartReading();
myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY");
registerReceiver(myReceiver, intentFilter);
mediaPlayer = MediaPlayer.create(this, R.raw.msg);
}
@Override
protected void onDestroy() {
super.onDestroy();
@ -91,6 +101,5 @@ public abstract class BaseActivity extends AppCompatActivity {
}
protected abstract void sanRfid(List<String> epcs);
protected abstract void sanRfid(List<Reader.TAGINFO> epcs);
}

@ -1,9 +1,11 @@
package com.example.beijing_daxing.base;
import android.app.Application;
import android.util.Log;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.handheld.UHFLonger.UHFLongerManager;
import com.handheld.uhfr.UHFRManager;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
@ -28,7 +30,7 @@ import okhttp3.OkHttpClient;
public class MyApplication extends Application {
MyApplication application;
public static UHFLongerManager uhfLongerManager;
public static UHFRManager uhfLongerManager;
@Override
public void onCreate() {
super.onCreate();
@ -39,15 +41,16 @@ public class MyApplication extends Application {
getUhfLongerManager();
}
public static UHFLongerManager getUhfLongerManager() {
public static UHFRManager getUhfLongerManager() {
if (uhfLongerManager==null){
try {
uhfLongerManager = UHFLongerManager.getInstance();
uhfLongerManager.setOutPower((short) 30);
uhfLongerManager = UHFRManager.getInstance();
uhfLongerManager.setPower(33,33);
} catch (Exception e) {
e.printStackTrace();
}
}
return uhfLongerManager;
}
// OKGO 初始化

@ -107,12 +107,12 @@
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="20dp"
android:onClick="bf_submit"
style="@style/button_style"
android:text="标记报废"/>
android:text="标记报废" />
</LinearLayout>
</layout>

@ -29,9 +29,10 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:background="@color/white"
android:layout_weight="1"
android:padding="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:adapter="@{adapter}" />
@ -114,6 +115,7 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:text="提交"
android:onClick="in_submit"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4"

@ -27,9 +27,10 @@
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@color/white"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:adapter="@{adapter}"
android:padding="10dp" />
@ -79,8 +80,9 @@
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="55dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:onClick="out_submit"
android:text="提交" />
</LinearLayout>

@ -12,7 +12,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_height="50dp"
android:layout_marginTop="2dp"
android:background="#DEE3E6"
android:orientation="horizontal">

Loading…
Cancel
Save