更改 驱动版本

master
wangh 6 months ago
parent 2b9c76ddd4
commit c38cbed454

@ -43,8 +43,15 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0' implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation files('libs\\ModuleAPI_J.jar') implementation files('libs\\c5106\\App_Demo_API.jar')
implementation files('libs\\uhfr_v1.8.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' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 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" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.USB_PERMISSION" />
<application <application
android:name=".base.MyApplication" android:name=".base.MyApplication"
android:allowBackup="true" android:allowBackup="true"
@ -13,41 +17,37 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.JinYuRFID" android:theme="@style/Theme.JinYuRFID"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".ReadActivity"
android:exported="false" />
<receiver <receiver
android:name=".broadcast.ScanERCodeReceiver" android:name=".broadcast.ScanERCodeReceiver"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true"/>
<intent-filter>
<action android:name="com.rfid.SCAN1" />
</intent-filter>
</receiver>
<activity <activity
android:name=".WriteUserActivity" android:name=".ReadActivity"
android:exported="true"> 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>
<activity
android:name=".WriteUserActivity"
android:exported="false" />
<activity <activity
android:name=".ConfigurationTableActivity" android:name=".ConfigurationTableActivity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <intent-filter> --> <!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- <action android:name="android.intent.action.MAIN" /> --> <!-- </intent-filter>-->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity> </activity>
</application> </application>

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

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

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

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

@ -14,7 +14,13 @@ public interface DataReturnCall {
* @param state * @param state
* @param stateInfo * @param stateInfo
*/ */
void readEpcCodeInfo(String info, boolean state, String 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,20 +44,31 @@ public class C5106Device implements RFIDModel {
* int datalen, word * int datalen, word
* byte[] password, 访4byte * byte[] password, 访4byte
* short timeout * short timeout
*
* byte[] fdata, * byte[] fdata,
* int fbank, 1 :EPC,2: TID ,3: USER * int fbank, 1 :EPC,2: TID ,3: USER
* int fstartaddr, word * int fstartaddr, word
* boolean matching true:,false: * boolean matching true:,false:
*/ */
@Override @Override
public boolean writeUser(String writeStr,String tagEpc) { public boolean writeUser(String writeStr, String tagEpc) {
var bytes = Tools.HexString2Bytes(writeStr); var bytes = Tools.HexString2Bytes(writeStr);
var bytesF = Tools.HexString2Bytes(tagEpc); var bytesF = Tools.HexString2Bytes(tagEpc);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter( 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); 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()); Log.e("TAG", "writeUser:" + readerErr.toString());
return readerErr == Reader.READER_ERR.MT_OK_ERR; 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); void sanEpc(int len);
boolean writeUser(String writeStr, String tagEpc); boolean writeUser(String writeStr, String tagEpc);
void sanUser(int len);
} }

@ -8,6 +8,9 @@
<variable <variable
name="title" name="title"
type="String" /> type="String" />
<variable
name="adapter"
type="com.example.jinyu_rfid.adapter.ResultAdapter" />
</data> </data>
<LinearLayout <LinearLayout
@ -19,12 +22,21 @@
<include <include
layout="@layout/toolbar" layout="@layout/toolbar"
app:title="@{title}" /> app:title="@{title}" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="8dp" 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> </LinearLayout>
</layout> </layout>

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

Loading…
Cancel
Save