diff --git a/app/build.gradle b/app/build.gradle index bd3a23f..7b06329 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/libs/ModuleAPI_J.jar b/app/libs/ModuleAPI_J.jar deleted file mode 100644 index b231d74..0000000 Binary files a/app/libs/ModuleAPI_J.jar and /dev/null differ diff --git a/app/libs/c5106/App_Demo_API.jar b/app/libs/c5106/App_Demo_API.jar new file mode 100644 index 0000000..86e2275 Binary files /dev/null and b/app/libs/c5106/App_Demo_API.jar differ diff --git a/app/libs/c5106/DeviceAPIver20150204.jar b/app/libs/c5106/DeviceAPIver20150204.jar new file mode 100644 index 0000000..defdeb1 Binary files /dev/null and b/app/libs/c5106/DeviceAPIver20150204.jar differ diff --git a/app/libs/c5106/ModuleAPI_1.jar b/app/libs/c5106/ModuleAPI_1.jar new file mode 100644 index 0000000..81c554f Binary files /dev/null and b/app/libs/c5106/ModuleAPI_1.jar differ diff --git a/app/libs/c5106/UHF67_v3.6.jar b/app/libs/c5106/UHF67_v3.6.jar new file mode 100644 index 0000000..d88dc29 Binary files /dev/null and b/app/libs/c5106/UHF67_v3.6.jar differ diff --git a/app/libs/c5106/logutil-1.5.1.1.jar b/app/libs/c5106/logutil-1.5.1.1.jar new file mode 100644 index 0000000..59b3c16 Binary files /dev/null and b/app/libs/c5106/logutil-1.5.1.1.jar differ diff --git a/app/libs/c5106/reader(1).jar b/app/libs/c5106/reader(1).jar new file mode 100644 index 0000000..8179d15 Binary files /dev/null and b/app/libs/c5106/reader(1).jar differ diff --git a/app/libs/uhfr_v1.8.jar b/app/libs/uhfr_v1.8.jar deleted file mode 100644 index 44c1a70..0000000 Binary files a/app/libs/uhfr_v1.8.jar and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 75f76e2..5ef5eb3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,10 @@ + + + + - - - - - + android:exported="true"/> + + - - - - + + + + + + + - - - - - - + + diff --git a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java index abeadf9..72f58ee 100644 --- a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java @@ -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 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(); + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java index 3ec999e..6bc00e0 100644 --- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java @@ -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 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 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 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.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 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) { diff --git a/app/src/main/java/com/example/jinyu_rfid/adapter/ResultAdapter.java b/app/src/main/java/com/example/jinyu_rfid/adapter/ResultAdapter.java index 2588bbf..881521e 100644 --- a/app/src/main/java/com/example/jinyu_rfid/adapter/ResultAdapter.java +++ b/app/src/main/java/com/example/jinyu_rfid/adapter/ResultAdapter.java @@ -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; diff --git a/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java b/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java index afc3b9f..301507d 100644 --- a/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java +++ b/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java @@ -52,7 +52,12 @@ public class MyRecultCall extends AbsCallback { @Override public void onStart(Request request) { super.onStart(request); - dialog.show(); + try { + dialog.show(); + }catch (Exception e){ + + } + // Log.e("网络请求情况", "onStart:" ); } diff --git a/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java b/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java index 9b00254..aab53e6 100644 --- a/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java +++ b/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java @@ -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; } diff --git a/app/src/main/java/com/example/jinyu_rfid/callback/DataReturnCall.java b/app/src/main/java/com/example/jinyu_rfid/callback/DataReturnCall.java index 870241b..0dd5d45 100644 --- a/app/src/main/java/com/example/jinyu_rfid/callback/DataReturnCall.java +++ b/app/src/main/java/com/example/jinyu_rfid/callback/DataReturnCall.java @@ -14,7 +14,13 @@ public interface DataReturnCall { * @param state * @param stateInfo */ - void readEpcCodeInfo(String info, boolean state, String stateInfo ); - void readUserInfo(String user); - void readerCodeInfo(String erCode); + void readEpcCodeInfo(String info, boolean state, String stateInfo); + + default void readUserInfo(String user, boolean state, String stateInfo) { + + } + + default void readerCodeInfo(String erCode) { + + } } diff --git a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java index db90cf1..b2d0051 100644 --- a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java +++ b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java @@ -44,20 +44,31 @@ 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 * boolean matching 是否匹配,true:写与过滤数据相匹配的标签,false:写与过滤数据不相匹配的标签 */ @Override - public boolean writeUser(String writeStr,String tagEpc) { + public boolean writeUser(String writeStr, String tagEpc) { 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, + Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter( + (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()); + } } diff --git a/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java b/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java index 2663129..a905bb8 100644 --- a/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java +++ b/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java @@ -8,4 +8,6 @@ public interface RFIDModel { void sanEpc(int len); boolean writeUser(String writeStr, String tagEpc); + + void sanUser(int len); } diff --git a/app/src/main/jniLibs/arm64-v8a/libModuleAPIJni.so b/app/src/main/jniLibs/arm64-v8a/libModuleAPIJni.so index 4072ad2..9d41f26 100644 Binary files a/app/src/main/jniLibs/arm64-v8a/libModuleAPIJni.so and b/app/src/main/jniLibs/arm64-v8a/libModuleAPIJni.so differ diff --git a/app/src/main/jniLibs/arm64-v8a/libjni_rfid_driver.so b/app/src/main/jniLibs/arm64-v8a/libjni_rfid_driver.so new file mode 100644 index 0000000..6d66476 Binary files /dev/null and b/app/src/main/jniLibs/arm64-v8a/libjni_rfid_driver.so differ diff --git a/app/src/main/jniLibs/arm64-v8a/libserial_port.so b/app/src/main/jniLibs/arm64-v8a/libserial_port.so new file mode 100644 index 0000000..bbd2cce Binary files /dev/null and b/app/src/main/jniLibs/arm64-v8a/libserial_port.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libModuleAPIJni.so b/app/src/main/jniLibs/armeabi-v7a/libModuleAPIJni.so index 7e07755..8a031e4 100644 Binary files a/app/src/main/jniLibs/armeabi-v7a/libModuleAPIJni.so and b/app/src/main/jniLibs/armeabi-v7a/libModuleAPIJni.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libSerialPort.so b/app/src/main/jniLibs/armeabi-v7a/libSerialPort.so index d7eb1f9..dc3c956 100644 Binary files a/app/src/main/jniLibs/armeabi-v7a/libSerialPort.so and b/app/src/main/jniLibs/armeabi-v7a/libSerialPort.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libdevapi.so b/app/src/main/jniLibs/armeabi-v7a/libdevapi.so index 4ce4fc6..8a0ba8a 100644 Binary files a/app/src/main/jniLibs/armeabi-v7a/libdevapi.so and b/app/src/main/jniLibs/armeabi-v7a/libdevapi.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libirdaSerialPort.so b/app/src/main/jniLibs/armeabi-v7a/libirdaSerialPort.so index d1c5202..b8a8974 100644 Binary files a/app/src/main/jniLibs/armeabi-v7a/libirdaSerialPort.so and b/app/src/main/jniLibs/armeabi-v7a/libirdaSerialPort.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libjni_rfid_driver.so b/app/src/main/jniLibs/armeabi-v7a/libjni_rfid_driver.so new file mode 100644 index 0000000..4438c32 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libjni_rfid_driver.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libserial_port.so b/app/src/main/jniLibs/armeabi-v7a/libserial_port.so new file mode 100644 index 0000000..f240561 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libserial_port.so differ diff --git a/app/src/main/jniLibs/armeabi/libModuleAPIJni.so b/app/src/main/jniLibs/armeabi/libModuleAPIJni.so index e837b9d..8a031e4 100644 Binary files a/app/src/main/jniLibs/armeabi/libModuleAPIJni.so and b/app/src/main/jniLibs/armeabi/libModuleAPIJni.so differ diff --git a/app/src/main/jniLibs/armeabi/libModuleAPI_Android.so b/app/src/main/jniLibs/armeabi/libModuleAPI_Android.so new file mode 100644 index 0000000..b8c2f54 Binary files /dev/null and b/app/src/main/jniLibs/armeabi/libModuleAPI_Android.so differ diff --git a/app/src/main/jniLibs/armeabi/libdevapi.so b/app/src/main/jniLibs/armeabi/libdevapi.so index 4ce4fc6..8a0ba8a 100644 Binary files a/app/src/main/jniLibs/armeabi/libdevapi.so and b/app/src/main/jniLibs/armeabi/libdevapi.so differ diff --git a/app/src/main/jniLibs/armeabi/libjni_rfid_driver.so b/app/src/main/jniLibs/armeabi/libjni_rfid_driver.so new file mode 100644 index 0000000..4438c32 Binary files /dev/null and b/app/src/main/jniLibs/armeabi/libjni_rfid_driver.so differ diff --git a/app/src/main/jniLibs/armeabi/libserial_port.so b/app/src/main/jniLibs/armeabi/libserial_port.so new file mode 100644 index 0000000..f240561 Binary files /dev/null and b/app/src/main/jniLibs/armeabi/libserial_port.so differ diff --git a/app/src/main/res/layout/activity_read.xml b/app/src/main/res/layout/activity_read.xml index 9a0bc41..94256ec 100644 --- a/app/src/main/res/layout/activity_read.xml +++ b/app/src/main/res/layout/activity_read.xml @@ -8,6 +8,9 @@ + + + android:layout_weight="1" + android:adapter="@{adapter}" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> +