更改 驱动版本

master
wangh 6 months ago
parent 2b9c76ddd4
commit c38cbed454

@ -43,8 +43,15 @@ 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\\ModuleAPI_J.jar')
implementation files('libs\\uhfr_v1.8.jar')
implementation files('libs\\c5106\\App_Demo_API.jar')
implementation files('libs\\c5106\\DeviceAPIver20150204.jar')
implementation files('libs\\c5106\\logutil-1.5.1.1.jar')
implementation files('libs\\c5106\\ModuleAPI_1.jar')
implementation files('libs\\c5106\\reader(1).jar')
implementation files('libs\\c5106\\UHF67_v3.6.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.

@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.USB_PERMISSION" />
<application
android:name=".base.MyApplication"
android:allowBackup="true"
@ -13,39 +17,35 @@
android:supportsRtl="true"
android:theme="@style/Theme.JinYuRFID"
tools:targetApi="31">
<activity
android:name=".ReadActivity"
android:exported="false" />
<receiver
android:name=".broadcast.ScanERCodeReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.rfid.SCAN1" />
</intent-filter>
</receiver>
android:exported="true"/>
<activity
android:name=".WriteUserActivity"
android:name=".ReadActivity"
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>
<activity
android:name=".WriteUserActivity"
android:exported="false" />
<activity
android:name=".ConfigurationTableActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

@ -1,14 +1,69 @@
package com.example.jinyu_rfid;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
public class ReadActivity extends AppCompatActivity {
import com.example.jinyu_rfid.adapter.ResultAdapter;
import com.example.jinyu_rfid.base.BaseActivity;
import com.example.jinyu_rfid.been.ReadTyreNoResult;
import com.example.jinyu_rfid.callback.DataReturnCall;
import com.example.jinyu_rfid.databinding.ActivityReadBinding;
import com.example.jinyu_rfid.rfid.C5106Device;
import com.example.jinyu_rfid.rfid.RFIDModel;
import com.example.jinyu_rfid.uitls.ASCIIUtil;
import java.util.ArrayList;
import java.util.List;
public class ReadActivity extends BaseActivity implements DataReturnCall {
private ResultAdapter adapter;
private RFIDModel rfidModel;
private String[] stringArray;
private List<ReadTyreNoResult> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read);
ActivityReadBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_read);
binding.setTitle(getString(R.string.go_read));
adapter = new ResultAdapter(this);
binding.setAdapter(adapter);
// 名称
stringArray = getResources().getStringArray(R.array.project_list);
rfidModel = new C5106Device(this);
list = new ArrayList<>(11);
adapter.setList(list);
}
public void readInfo(View view) {
rfidModel.sanUser(80);
}
@Override
public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
}
@SuppressLint("NotifyDataSetChanged")
@Override
public void readUserInfo(String user, boolean state, String stateInfo) {
list.clear();
if (state) {
music.start();
String info = ASCIIUtil.hex2Str(user);
Log.e("TAG", "readUserInfo:" + info);
var infos = info.split("~");
for (int i = 0; i < 12; i++) {
list.add( new ReadTyreNoResult(i,stringArray[i],infos[i]));
}
}
adapter.notifyDataSetChanged();
}
}

@ -51,13 +51,12 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
rfidModel = new C5106Device(this);
intent1 = new Intent(this, ConfigurationTableActivity.class);
intent1 = new Intent(this, ReadActivity.class);
intent2 = new Intent(this, ConfigurationTableActivity.class);
ScanERCodeReceiver scanERCodeReceiver = new ScanERCodeReceiver(this);
registerReceiver(scanERCodeReceiver, new IntentFilter("com.rfid.SCAN"));
adapter = new ResultAdapter(this);
binding.setAdapter(adapter);
popupMenu = new PopupMenu(this, binding.writeMenu);
popupMenu.setOnMenuItemClickListener(this);
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
@ -78,17 +77,18 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
// EPC编码~胎号~品牌~规格~花纹~层级~轮胎名称~速度级别~负荷指数~轮辋直径~扁平比~销售区域
List<ConfigurationTable> tagList = LitePal.findAll(ConfigurationTable.class);
StringBuilder tagUserStr = new StringBuilder(tagList.get(0).isState() ? epcStr : "_");
tagUserStr.append("~");
for (int i = 1; i < 12; i++) {
var configuration = tagList.get(i);
var state = configuration.isState();
tagUserStr.append("~");
if (state) {
/* if (state) {
Optional<ReadTyreNoResult> optionalResult = Optional.ofNullable(list.get(i - 1));
String propertyContent = optionalResult.map(ReadTyreNoResult::getPropertyContent).orElse("_");
tagUserStr.append(propertyContent);
} else {
tagUserStr.append("_");
}
}*/
if (state) {
try {
var result = list.get(i - 1);
@ -100,24 +100,23 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
} else {
tagUserStr.append("_");
}
tagUserStr.append("~");
}
String user = ASCIIUtil.str2Hex(tagUserStr.toString());
Log.e("TAG", "writeUser:" + user);
Log.e("TAG", "writeUser:" + user.length());
Log.e("TAG", "名文:" + tagUserStr);
Log.e("TAG", "ASCII:" + user);
Log.e("TAG", "写入长度:" + user.length());
if (!writeUserState) {
Log.e("TAG", "writeUser:" + 1);
// writeUserState = rfidModel.writeUser(user, epcStr);
writeUserState = true;
writeUserState = rfidModel.writeUser(user, epcStr);
Toast.makeText(context, getString(writeUserState ? R.string.write_success : R.string.write_failed), Toast.LENGTH_SHORT).show();
}
if (writeUserState) {
Map<String, String> map = new HashMap<>();
map.put("EpcCode", "1231");
map.put("TyreNo", "1231");
map.put("EpcCode", epcStr);
map.put("TyreNo", list.get(0).getPropertyContent());
map.put("token", "123456");
Log.e("TAG", "writeUser:" + 2);
OkGo.<MyResult>post(url + "/write")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
@ -126,7 +125,6 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getSaveFlag().equals("1")) {
list.clear();
@ -134,6 +132,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
binding.writeEpcCode.setText(null);
binding.writeTire.setText(null);
Toast.makeText(WriteUserActivity.this, getString(R.string.binding_success), Toast.LENGTH_SHORT).show();
writeUserState=false;
return;
}
Toast.makeText(WriteUserActivity.this, body.getSaveMessage(), Toast.LENGTH_SHORT).show();
@ -141,7 +140,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
});
}
// writeUserState=false;
}
@ -162,10 +161,6 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
// Log.e("TAG", "读取状态:" + stateInfo);
}
@Override
public void readUserInfo(String user) {
}
@Override
public void readerCodeInfo(String erCode) {

@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.example.jinyu_rfid.BR;
import com.example.jinyu_rfid.R;
import com.example.jinyu_rfid.been.ConfigurationData;

@ -52,7 +52,12 @@ public class MyRecultCall extends AbsCallback<MyResult> {
@Override
public void onStart(Request<MyResult, ? extends Request> request) {
super.onStart(request);
try {
dialog.show();
}catch (Exception e){
}
// Log.e("网络请求情况", "onStart:" );
}

@ -14,6 +14,15 @@ public class ReadTyreNoResult {
private String PropertyName, PropertyContent;
private int PropertyIndex;
public ReadTyreNoResult() {
}
public ReadTyreNoResult( int propertyIndex, String propertyName, String propertyContent) {
PropertyName = propertyName;
PropertyContent = propertyContent;
PropertyIndex = propertyIndex;
}
public String getPropertyName() {
return PropertyName;
}

@ -15,6 +15,12 @@ public interface DataReturnCall {
* @param stateInfo
*/
void readEpcCodeInfo(String info, boolean state, String stateInfo);
void readUserInfo(String user);
void readerCodeInfo(String erCode);
default void readUserInfo(String user, boolean state, String stateInfo) {
}
default void readerCodeInfo(String erCode) {
}
}

@ -44,7 +44,7 @@ public class C5106Device implements RFIDModel {
* int datalen, word
* byte[] password, 访4byte
* short timeout
*
* byte[] fdata,
* int fbank, 1 :EPC,2: TID ,3: USER
* int fstartaddr, word
@ -55,9 +55,20 @@ public class C5106Device implements RFIDModel {
var bytes = Tools.HexString2Bytes(writeStr);
var bytesF = Tools.HexString2Bytes(tagEpc);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter(
(char) 3, 0, bytes, bytes.length, accessBytes, (short) 200,
(char) 3, 0, bytes, bytes.length, accessBytes, (short) 500,
bytesF ,1,2,true);
/* Reader.READER_ERR readerErr = uhfrManager.writeTagData(
(char) 3, 0, bytes, bytes.length, accessBytes, (short) 500);*/
Log.e("TAG", "writeUser:" + readerErr.toString());
return readerErr == Reader.READER_ERR.MT_OK_ERR;
}
@Override
public void sanUser(int len) {
byte[] rdata = new byte[len * 2];
Reader.READER_ERR readerErr = uhfrManager.getTagData(3, 0, len, rdata, accessBytes, (short) 200);
call.readUserInfo(Tools.Bytes2HexString(rdata, rdata.length), readerErr == Reader.READER_ERR.MT_OK_ERR, readerErr.toString());
}
}

@ -8,4 +8,6 @@ public interface RFIDModel {
void sanEpc(int len);
boolean writeUser(String writeStr, String tagEpc);
void sanUser(int len);
}

@ -8,6 +8,9 @@
<variable
name="title"
type="String" />
<variable
name="adapter"
type="com.example.jinyu_rfid.adapter.ResultAdapter" />
</data>
<LinearLayout
@ -19,12 +22,21 @@
<include
layout="@layout/toolbar"
app:title="@{title}" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
android:layout_weight="1"
android:adapter="@{adapter}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="10dp"
android:textSize="18sp"
android:onClick="readInfo"
android:text="@string/go_read" />
</LinearLayout>
</layout>

@ -114,6 +114,7 @@
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:onClick="writeReadEPC"
android:textSize="16sp"
android:text="@string/read_epc" />
<Button
@ -122,6 +123,7 @@
android:layout_marginStart="8dp"
android:layout_weight="1"
android:onClick="writeUser"
android:textSize="16sp"
android:text="@string/write_in" />
</LinearLayout>

Loading…
Cancel
Save