增加 永久锁定epc
parent
9b5f8cd6da
commit
0da5681b87
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<litepal>
|
||||||
|
<dbname value="write_tag_info" />
|
||||||
|
<version value="1" />
|
||||||
|
<list>
|
||||||
|
<mapping class="com.example.writeepc.been.WriteInfo"></mapping>
|
||||||
|
</list>
|
||||||
|
</litepal>
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
package com.example.writeepc;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
|
import com.example.writeepc.base.BaseActivity;
|
||||||
|
import com.example.writeepc.databinding.ActivityUserXuanchuanBinding;
|
||||||
|
import com.example.writeepc.utils.ASCIIUtil;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class UserXuanchuanActivity extends BaseActivity {
|
||||||
|
private ActivityUserXuanchuanBinding binding;
|
||||||
|
private int flag = 0;
|
||||||
|
private byte[] rdata;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_user_xuanchuan);
|
||||||
|
Locale locale = new Locale("es");
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
Configuration config = new Configuration();
|
||||||
|
config.locale = locale;
|
||||||
|
getBaseContext().getResources().updateConfiguration(config,
|
||||||
|
getBaseContext().getResources().getDisplayMetrics());
|
||||||
|
|
||||||
|
initReceiver();
|
||||||
|
initUHFRManager(33);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readTid(View view) {
|
||||||
|
flag = 1;
|
||||||
|
readTid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeUser(View view) {
|
||||||
|
String trim = binding.writeInfo.getText().toString().trim();
|
||||||
|
if (rdata == null) {
|
||||||
|
Toast.makeText(this, "请先读取TID", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (trim.isEmpty()) {
|
||||||
|
Toast.makeText(this, "请输入要写入的用户信息", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int length = trim.length();
|
||||||
|
// 32,128
|
||||||
|
if (length > 32 ) {
|
||||||
|
Toast.makeText(this, "长度不能超过32个字符", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String writeData = ASCIIUtil.str4Hex(trim);
|
||||||
|
int writeLenth = writeData.length();
|
||||||
|
Log.e("TAG", "数据长度:" + length + " ," + writeLenth);
|
||||||
|
if (writeLenth < 128) {
|
||||||
|
writeData = writeData+String.format("%0"+(128-writeLenth)+"d", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.e("TAG", "写入数据:" + writeData+" ,长度:" + writeData.length());
|
||||||
|
writeUserDataByTid(writeData, rdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readUser(View view) {
|
||||||
|
flag = 2;
|
||||||
|
readUser(64);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiverSan() {
|
||||||
|
super.receiverSan();
|
||||||
|
readUser(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readTidReault(boolean readState, String result, byte[] rdata) {
|
||||||
|
super.readTidReault(readState, result, rdata);
|
||||||
|
if (readState) {
|
||||||
|
if (flag == 1) {
|
||||||
|
binding.tidCode.setText(result);
|
||||||
|
this.rdata = rdata;
|
||||||
|
} else {
|
||||||
|
Log.e("TAG", "readTidReault:" + result);
|
||||||
|
String text = ASCIIUtil.hexTo4ZN(result);
|
||||||
|
binding.readInfo.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (uhfrManager != null) {
|
||||||
|
uhfrManager.close();
|
||||||
|
uhfrManager = null;
|
||||||
|
}
|
||||||
|
if (myReceiver != null) {
|
||||||
|
unregisterReceiver(myReceiver);
|
||||||
|
myReceiver = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.example.writeepc.been;
|
||||||
|
|
||||||
|
import org.litepal.crud.LitePalSupport;
|
||||||
|
|
||||||
|
public class WriteInfo extends LitePalSupport {
|
||||||
|
private int id;
|
||||||
|
private String tid;
|
||||||
|
private String writeInfo;
|
||||||
|
private String dateTime;
|
||||||
|
|
||||||
|
public WriteInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WriteInfo(String tid, String writeInfo, String dateTime) {
|
||||||
|
this.tid = tid;
|
||||||
|
this.writeInfo = writeInfo;
|
||||||
|
this.dateTime = dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTid() {
|
||||||
|
return tid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTid(String tid) {
|
||||||
|
this.tid = tid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWriteInfo() {
|
||||||
|
return writeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWriteInfo(String writeInfo) {
|
||||||
|
this.writeInfo = writeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDateTime() {
|
||||||
|
return dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateTime(String dateTime) {
|
||||||
|
this.dateTime = dateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<corners android:radius="6dp"/>
|
||||||
|
<solid android:color="@color/white"/>
|
||||||
|
</shape>
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@mipmap/test1"
|
||||||
|
tools:context=".UserXuanchuanActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@color/blue2"
|
||||||
|
android:letterSpacing="0.2"
|
||||||
|
android:text="RFID Tag writing"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="San TID:" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tid_code"
|
||||||
|
style="@style/san_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:onClick="readTid"
|
||||||
|
android:backgroundTint="@color/blue2"
|
||||||
|
android:text="Query TID" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="Input data:" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/write_info"
|
||||||
|
style="@style/info_text2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:minHeight="45dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@color/blue2"
|
||||||
|
android:onClick="writeUser"
|
||||||
|
android:text="Write data" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/read_info"
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@color/blue2"
|
||||||
|
android:onClick="readUser"
|
||||||
|
android:text="Scan RFID" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 292 KiB |
Loading…
Reference in New Issue