修改 读取解析异常和东集分开读取

master
wangh 5 months ago
parent 730e2cfa3a
commit 4cad549e47

Binary file not shown.

@ -18,15 +18,14 @@
android:theme="@style/Theme.JinYuRFID" android:theme="@style/Theme.JinYuRFID"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".IPConfiguraActivity"
android:exported="false" />
<uses-library <uses-library
android:name="com.seuic.uhf" android:name="com.seuic.uhf"
android:required="false" /> android:required="false" />
<activity
android:name=".BlueToothServerActivity"
android:exported="true" />
<activity <activity
android:name=".AppLoginActivity" android:name=".AppLoginActivity"
@ -38,19 +37,18 @@
</activity> </activity>
<activity <activity
android:name=".ReadActivity" android:name=".ReadActivity"
android:exported="true"> android:exported="true"/>
<activity
android:name=".Read2Activity"
android:exported="true"/>
</activity>
<activity <activity
android:name=".ReadBlueToothActivity" android:name=".ReadBlueToothActivity"
android:exported="true" /> android:exported="true" />
<activity <activity
android:name=".WriteUserActivity" android:name=".WriteUserActivity"
android:exported="true"> android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name=".ConfigurationTableActivity" android:name=".ConfigurationTableActivity"
@ -58,10 +56,10 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true">
<!-- <intent-filter>--> <intent-filter>
<!-- <action android:name="android.intent.action.MAIN" />--> <action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" />--> <category android:name="android.intent.category.LAUNCHER" />
<!-- </intent-filter>--> </intent-filter>
</activity> </activity>
</application> </application>

@ -19,10 +19,9 @@ import java.util.Locale;
public class AppLoginActivity extends AppCompatActivity { public class AppLoginActivity extends AppCompatActivity {
private ActivityAppLoginBinding binding; private ActivityAppLoginBinding binding;
private Resources resources; private Resources resources;
private Configuration config; private Configuration config;
private Intent intent;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -36,6 +35,8 @@ public class AppLoginActivity extends AppCompatActivity {
// 工作模式 // 工作模式
var workmode = SharedPreferencesUtils.getInt("workmode", 0); var workmode = SharedPreferencesUtils.getInt("workmode", 0);
binding.mainWork.setSelection(workmode); binding.mainWork.setSelection(workmode);
intent=new Intent(this, IPConfiguraActivity.class);
} }
public void appLoginClick(View view) { public void appLoginClick(View view) {
@ -65,4 +66,8 @@ public class AppLoginActivity extends AppCompatActivity {
} }
resources.updateConfiguration(config, resources.getDisplayMetrics()); resources.updateConfiguration(config, resources.getDisplayMetrics());
} }
public void ipCon(View view){
startActivity(intent);
}
} }

@ -1,102 +0,0 @@
package com.example.jinyu_rfid;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
public class BlueToothServerActivity extends AppCompatActivity {
private BluetoothServerSocket serverSocket;
private BluetoothSocket socket;
@RequiresApi(api = Build.VERSION_CODES.S)
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blue_tooth_server);
// 0000110a-0000-1000-8000-00805f9b34fb
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.BLUETOOTH_CONNECT}, 1);
}
// Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
// D:for (BluetoothDevice bluetoothDevice : devices) {
// Log.e("TAG", bluetoothDevice.getName() + ":" + bluetoothDevice.getUuids()[0].toString());
// /* // if (bluetoothDevice.getAddress().toString().equals("FC:0F:E7:B6:15:2F")) {
// if (bluetoothDevice.getName().equals("AUTOID UTouch")) {
// mmDevice = bluetoothDevice;
// Log.e("TAG", "连接成功");
// break D;
// }*/
// }
try {
// 创建一个BluetoothServerSocket来监听连接请求
serverSocket = bluetoothAdapter.listenUsingRfcommWithServiceRecord(
"abc",
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
// 无限循环以接受连接请求
while (true) {
socket = serverSocket.accept();
// 接收数据
receiveData(socket);
// 关闭socket
socket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void receiveData(BluetoothSocket socket) {
try {
InputStream inputStream = socket.getInputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
// 处理接收到的数据
// (buffer, 0, bytesRead) 是接收到的数据
String receivedData = new String(buffer, 0, bytesRead);
Toast.makeText(this, receivedData, Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void stopServer() {
try {
if (serverSocket != null) {
serverSocket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
stopServer();
}
}

@ -0,0 +1,46 @@
package com.example.jinyu_rfid;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.example.jinyu_rfid.base.BaseActivity;
import com.example.jinyu_rfid.been.IPConfigurationVM;
import com.example.jinyu_rfid.databinding.ActivityIpconfiguraBinding;
import com.example.jinyu_rfid.uitls.SharedPreferencesUtils;
public class IPConfiguraActivity extends BaseActivity {
private IPConfigurationVM vm;
private ActivityIpconfiguraBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil. setContentView(this,R.layout.activity_ipconfigura);
binding.setTitle(getString(R.string.activity_name_configuration));
}
@Override
protected void onResume() {
super.onResume();
if (url==null){
vm=new IPConfigurationVM();
}else {
vm=new IPConfigurationVM(url);
}
binding.setVm(vm);
}
public void urlSeve(View view) {
var ip = vm.getIp();
var port = vm.getPort();
if(ip==null||port==null||ip.isEmpty()|| port.isEmpty()) return;
SharedPreferencesUtils.putstring("url",vm.getUrl());
finish();
}
}

@ -39,7 +39,7 @@ public class MainActivity extends BaseActivity {
private Resources resources; private Resources resources;
private Configuration config; private Configuration config;
private int index; private int index;
private Intent intent;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -59,6 +59,7 @@ public class MainActivity extends BaseActivity {
} }
binding.setUser(loginVm); binding.setUser(loginVm);
intent=new Intent(this, IPConfiguraActivity.class);
} }
@ -92,7 +93,7 @@ public class MainActivity extends BaseActivity {
map.put("token", "123456"); map.put("token", "123456");
map.put("Language", index + ""); map.put("Language", index + "");
if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return; if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
OkGo.<MyResult>post(url + "/login") OkGo.<MyResult>post("http://"+url + "/rfid/login")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map))) .upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
.execute(new MyRecultCall(dialog, this) { .execute(new MyRecultCall(dialog, this) {
@Override @Override
@ -129,4 +130,7 @@ public class MainActivity extends BaseActivity {
} }
}); });
} }
public void ipConMain(View view){
startActivity(intent);
}
} }

@ -11,8 +11,7 @@ import com.example.jinyu_rfid.adapter.ResultAdapter;
import com.example.jinyu_rfid.base.BaseActivity; import com.example.jinyu_rfid.base.BaseActivity;
import com.example.jinyu_rfid.been.ReadTyreNoResult; import com.example.jinyu_rfid.been.ReadTyreNoResult;
import com.example.jinyu_rfid.callback.DataReturnCall; import com.example.jinyu_rfid.callback.DataReturnCall;
import com.example.jinyu_rfid.databinding.ActivityAutoidReadBinding; import com.example.jinyu_rfid.databinding.ActivityRead2Binding;
import com.example.jinyu_rfid.databinding.ActivityAutoidReadBindingImpl;
import com.example.jinyu_rfid.databinding.ActivityReadBinding; import com.example.jinyu_rfid.databinding.ActivityReadBinding;
import com.example.jinyu_rfid.rfid.AutoID9UDevice; import com.example.jinyu_rfid.rfid.AutoID9UDevice;
import com.example.jinyu_rfid.rfid.RFIDModel; import com.example.jinyu_rfid.rfid.RFIDModel;
@ -21,18 +20,18 @@ import com.example.jinyu_rfid.uitls.ASCIIUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AutoIDReadActivity extends BaseActivity implements DataReturnCall { public class Read2Activity extends BaseActivity implements DataReturnCall {
private ResultAdapter adapter; private ResultAdapter adapter;
private RFIDModel rfidModel; private RFIDModel rfidModel;
private String[] stringArray; private String[] stringArray;
private List<ReadTyreNoResult> list; private List<ReadTyreNoResult> list;
private ActivityAutoidReadBinding binding; private ActivityRead2Binding binding;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_autoid_read); binding = DataBindingUtil.setContentView(this, R.layout.activity_read2);
binding.setTitle(getString(R.string.go_read)); binding.setTitle(getString(R.string.go_read));
adapter = new ResultAdapter(this); adapter = new ResultAdapter(this);
list = new ArrayList<>(11); list = new ArrayList<>(11);
@ -47,11 +46,13 @@ public class AutoIDReadActivity extends BaseActivity implements DataReturnCall {
// 读取user区 // 读取user区
public void readInfo(View view) { public void read2Info(View view) {
rfidModel.sanUser(80); var id = binding.writeEpcCode.getText().toString();
if (id.isEmpty()) return;
rfidModel.sanUser(80, id);
} }
public void readEPCInfo(View view) { public void read2EPC(View view) {
rfidModel.sanEpc(6); rfidModel.sanEpc(6);
} }
@ -59,11 +60,9 @@ public class AutoIDReadActivity extends BaseActivity implements DataReturnCall {
@Override @Override
public void readEpcCodeInfo(String info, boolean state, String stateInfo) { public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
if (state) { if (state) {
binding.readTextEpc.setText(info);
music.start(); music.start();
return;
} }
binding.readTextEpc.setText(null); binding.writeEpcCode.setText(info);
} }
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")

@ -64,8 +64,8 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
binding.setAdapter(adapter); binding.setAdapter(adapter);
// 名称 // 名称
stringArray = getResources().getStringArray(R.array.project_list); stringArray = getResources().getStringArray(R.array.project_list);
// rfidModel = new C5106Device(this,this); rfidModel = new C5106Device(this,this);
rfidModel=new AutoID9UDevice(this,this); // rfidModel=new AutoID9UDevice(this,this);
} }
@ -94,10 +94,15 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
music.start(); music.start();
String info = ASCIIUtil.hex2Str(user); String info = ASCIIUtil.hex2Str(user);
Log.e("TAG", "readUserInfo:" + user); Log.e("TAG", "readUserInfo:" + user);
var infos = info.split("~"); try {
for (int i = 0; i < 12; i++) { var infos = info.split("~");
list.add(new ReadTyreNoResult(i, stringArray[i], infos[i])); for (int i = 0; i < 12; i++) {
list.add(new ReadTyreNoResult(i, stringArray[i], infos[i]));
}
}catch (Exception e){
Toast.makeText(context, getString(R.string.activity_name_configuration), Toast.LENGTH_SHORT).show();
} }
} else { } else {
binding.readText.setText(null); binding.readText.setText(null);
} }

@ -234,7 +234,7 @@ public class ReadBlueToothActivity extends BaseActivity {
map.put("EpcCode", info); map.put("EpcCode", info);
map.put("token", "123456"); map.put("token", "123456");
map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0")); map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0"));
OkGo.<MyResult>post(url + "/readEPCCode") OkGo.<MyResult>post("http://"+url + "/rfid/readEPCCode")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map))) .upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
.execute(new MyRecultCall(dialog, this) { .execute(new MyRecultCall(dialog, this) {
@Override @Override

@ -51,15 +51,20 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user); binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
intent1 = new Intent(this, ReadActivity.class);
intent2 = new Intent(this, ConfigurationTableActivity.class); intent2 = new Intent(this, ConfigurationTableActivity.class);
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());
// rfidModel = new C5106Device(this,this); rfidModel = new C5106Device(this,this);
rfidModel=new AutoID9UDevice(this,this); // rfidModel=new AutoID9UDevice(this,this);
if (rfidModel instanceof C5106Device){
intent1 = new Intent(this, ReadActivity.class);
}else {
intent1 = new Intent(this, Read2Activity.class);
}
} }
@ -110,7 +115,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
map.put("token", "123456"); map.put("token", "123456");
map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0")); map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0"));
Log.e("TAG", "writeUser:" + 2); Log.e("TAG", "writeUser:" + 2);
OkGo.<MyResult>post(url + "/write").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) { OkGo.<MyResult>post("http://"+url + "/rfid/write").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override
public void onSuccess(Response<MyResult> response) { public void onSuccess(Response<MyResult> response) {
@ -121,12 +126,12 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
writeUserState = true; writeUserState = true;
return; return;
} }
tipDialog.shouDialog(false, body.getSaveMessage()); tipDialog.shouDialog(false, body.getSaveMessage());
} }
}); });
} //writeUserState = true; }
//writeUserState = true;
if (writeUserState){ if (writeUserState){
Log.e("TAG", "写入"); Log.e("TAG", "写入");
var writeState = rfidModel.writeUser(validateDataLength(user), epcStr); var writeState = rfidModel.writeUser(validateDataLength(user), epcStr);
@ -155,7 +160,6 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
} }
return paddedData.toString(); return paddedData.toString();
} }
return data; return data;
} }
@ -179,14 +183,13 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
map.put("TyreNo", erCode); map.put("TyreNo", erCode);
map.put("token", "123456"); map.put("token", "123456");
map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0")); map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0"));
OkGo.<MyResult>post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) { OkGo.<MyResult>post("http://"+url + "/rfid/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@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.getResultFlag().equals("1")) { if (body.getResultFlag().equals("1")) {
list = gson.fromJson(body.getJson(), new TypeToken<List<ReadTyreNoResult>>() { list = gson.fromJson(body.getJson(), new TypeToken<List<ReadTyreNoResult>>() {
}.getType()); }.getType());
list.remove(0); list.remove(0);

@ -26,6 +26,7 @@ import androidx.core.content.FileProvider;
import com.example.jinyu_rfid.R; import com.example.jinyu_rfid.R;
import com.example.jinyu_rfid.dialog.TipDialog; import com.example.jinyu_rfid.dialog.TipDialog;
import com.example.jinyu_rfid.uitls.SharedPreferencesUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -42,7 +43,7 @@ import okhttp3.MediaType;
public class BaseActivity extends AppCompatActivity { public class BaseActivity extends AppCompatActivity {
public static String url = "http://rfidtest.jinyutyres.com:8199/rfid"; public static String url /*= "http://rfidtest.jinyutyres.com:8199/rfid"*/;
public ProgressDialog dialog; public ProgressDialog dialog;
public Gson gson; public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
@ -63,6 +64,13 @@ public class BaseActivity extends AppCompatActivity {
} }
@Override
protected void onResume() {
super.onResume();
url= SharedPreferencesUtils.getstring("url", null);
}
public class MyReceiver extends BroadcastReceiver { public class MyReceiver extends BroadcastReceiver {
@Override @Override

@ -0,0 +1,45 @@
package com.example.jinyu_rfid.been;
import androidx.databinding.BaseObservable;
/**
* @author wanghao
* @date 2024/5/15 15:02
*/
public class IPConfigurationVM extends BaseObservable {
private String ip, port;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public IPConfigurationVM() {
}
public IPConfigurationVM(String url) {
var split = url.split(":");
ip = split[0];
port = split[1];
notifyChange();
}
public String getUrl() {
return ip + ":" + port;
}
}

@ -32,7 +32,7 @@ public class AutoID9UDevice implements RFIDModel {
this.call = call; this.call = call;
this.context = context; this.context = context;
uhfService = UHFService.getInstance(); uhfService = UHFService.getInstance();
uhfService.setParameters(UHFService.PARAMETER_INVENTORY_SESSION,0); uhfService.setParameters(UHFService.PARAMETER_INVENTORY_SESSION, 0);
if (!uhfService.isopen()) { if (!uhfService.isopen()) {
uhfService.open(); uhfService.open();
} }
@ -74,57 +74,60 @@ public class AutoID9UDevice implements RFIDModel {
var bytes = AutoID9UUtil.getHexByteArray(writeStr); var bytes = AutoID9UUtil.getHexByteArray(writeStr);
Log.e("TAG", "writeUser:" + tagEpc); Log.e("TAG", "writeUser:" + tagEpc);
var b = uhfService.writeTagData(AutoID9UUtil.getHexByteArray(tagEpc), password, var b = uhfService.writeTagData(AutoID9UUtil.getHexByteArray(tagEpc), password, 3, 0, bytes.length, bytes);
3, 0, bytes.length, bytes);
return b; return b;
} }
String id = null;
@Override
public void sanUser(int len, String id) {
var i = len * 2;
byte[] data = new byte[i];
String info = null;
var result = uhfService.readTagData(AutoID9UUtil.getHexByteArray(id), password, 3, 0, i, data);
Log.e("TAG", "按长度读取:" + result);
if (result) {
info = Tools.Bytes2HexString(data, data.length);
}
call.readUserInfo(info, result, null);
}
@Override @Override
public void sanUser(int len) { public void sanUser(int len) {
var power = uhfService.getPower(); var power = uhfService.getPower();
Log.e("TAG", "设备功率:" + power); Log.e("TAG", "开始读取,检查设备功率:" + power);
if (power==0){ if (power == 0) {
uhfService.close(); // uhfService.close();
uhfService = UHFService.getInstance(); uhfService = UHFService.getInstance();
uhfService.open(); uhfService.open();
Log.e("TAG", "设备功率:" + uhfService.getPower()); Log.e("TAG", "重启设备功率:" + uhfService.getPower());
}
if (id==null){
String info = null;
EPC epc=new EPC();
var result = uhfService.inventoryOnce(epc, 100);
Log.e("TAG", "单次寻卡:" + result);
Log.e("TAG", "epcid:" + epc.getId());
id=epc.getId();
return;
} }
String info = null;
// if (result) { EPC epc = new EPC();
var result = uhfService.inventoryOnce(epc, 100);
Log.e("TAG", "单次寻卡:" + result);
Log.e("TAG", "epcid:" + epc.getId());
var id = epc.getId();
if (result) {
var i = len * 2; var i = len * 2;
byte[] data = new byte[i]; byte[] data = new byte[i];
var result = uhfService.readTagData(AutoID9UUtil.getHexByteArray(id), password, 3, 0, i, data); result = uhfService.readTagData(AutoID9UUtil.getHexByteArray(id), password, 3, 0, i, data);
Log.e("TAG", "按长度读取:" + result); Log.e("TAG", "按长度读取:" + result);
if (result) { if (result) {
var info = Tools.Bytes2HexString(data, data.length); info = Tools.Bytes2HexString(data, data.length);
} }
// } }
// call.readUserInfo(info,result,null); call.readUserInfo(info, result, null);
} }
@Override @Override
public void close() { public void close() {
Log.e("TAG", "设备关闭!");
uhfService.close(); uhfService.close();
context.unregisterReceiver(scanERCodeReceiver); context.unregisterReceiver(scanERCodeReceiver);
} }
//
// @Override
// public void loading() {
// uhfService.close();
// uhfService.open();
// Log.e("TAG", "loading:" + uhfService.getPower());
// }
class AutoIDdeviceScanERCodeReceiver extends BroadcastReceiver { class AutoIDdeviceScanERCodeReceiver extends BroadcastReceiver {

@ -10,5 +10,10 @@ public interface RFIDModel {
boolean writeUser(String writeStr, String tagEpc); boolean writeUser(String writeStr, String tagEpc);
void sanUser(int len); void sanUser(int len);
default void sanUser(int len, String id) {
}
void close(); void close();
} }

@ -79,5 +79,16 @@
android:text="@string/login_button_name" android:text="@string/login_button_name"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:layout_marginTop="8dp"
android:layout_marginRight="30dp"
android:layout_width="140dp"
android:layout_height="30dp"
android:text="@string/activity_name_configuration"
android:textSize="18sp"
android:gravity="right"
android:onClick="ipCon"
android:textColor="#2196F3"
android:layout_gravity="right"/>
</LinearLayout> </LinearLayout>
</layout> </layout>

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BlueToothServerActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
<variable
name="vm"
type="com.example.jinyu_rfid.been.IPConfigurationVM" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".IPConfiguraActivity">
<include
android:id="@+id/include"
layout="@layout/toolbar"
app:layout_constraintTop_toTopOf="parent"
app:title="@{title}"/>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include">
<TextView
style="@style/text_name"
android:layout_width="120dp"
android:layout_height="match_parent"
android:text="@string/service_addr"
/>
<EditText
style="@style/text_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/san_text"
android:text="@={vm.ip}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<TextView
style="@style/text_name"
android:layout_width="120dp"
android:layout_height="match_parent"
android:text="@string/server_port" />
<EditText
style="@style/text_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/san_text"
android:text="@={vm.port}"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:onClick="urlSeve"
android:text="@string/configuration_save"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

@ -111,6 +111,17 @@
android:text="@string/login_button_name" android:text="@string/login_button_name"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:layout_marginTop="8dp"
android:layout_marginRight="30dp"
android:layout_width="140dp"
android:layout_height="30dp"
android:text="@string/activity_name_configuration"
android:textSize="18sp"
android:gravity="right"
android:onClick="ipConMain"
android:textColor="#2196F3"
android:layout_gravity="right"/>
</LinearLayout> </LinearLayout>
</layout> </layout>

@ -14,6 +14,7 @@
type="com.example.jinyu_rfid.adapter.ResultAdapter" /> type="com.example.jinyu_rfid.adapter.ResultAdapter" />
<import type="android.view.View" /> <import type="android.view.View" />
</data> </data>
@ -21,12 +22,11 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ReadActivity"> tools:context=".Read2Activity">
<include <include
layout="@layout/toolbar" layout="@layout/toolbar"
app:title="@{title}" /> app:title="@{title}" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
@ -40,17 +40,16 @@
android:text="@string/epc_code" /> android:text="@string/epc_code" />
<TextView <TextView
android:id="@+id/read_text_epc" android:id="@+id/write_epcCode"
style="@style/text_name" style="@style/text_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/san_text" /> android:background="@drawable/san_text" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_marginTop="10dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"> android:layout_marginEnd="8dp">
<TextView <TextView
@ -74,22 +73,22 @@
android:adapter="@{adapter}" android:adapter="@{adapter}"
android:padding="8dp" android:padding="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<Button <Button
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="50dp"
android:layout_marginTop="10dp" android:layout_marginEnd="8dp"
android:layout_marginLeft="10dp" android:layout_marginStart="8dp"
android:layout_marginRight="10dp" android:onClick="read2EPC"
android:onClick="readID" android:textSize="16sp"
android:text="@string/read_epc" android:text="@string/read_epc" />
android:textSize="18sp" />
<Button <Button
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="50dp"
android:layout_margin="10dp" android:layout_marginLeft="8dp"
android:onClick="readInfo" android:layout_marginRight="8dp"
android:onClick="read2Info"
android:text="@string/go_read" android:text="@string/go_read"
android:textSize="18sp" /> android:textSize="18sp" />

@ -37,4 +37,7 @@
<string name="dialog_button_text">I see</string> <string name="dialog_button_text">I see</string>
<string name="bluetooth_open_state">Bluetooth not connected, program exits</string> <string name="bluetooth_open_state">Bluetooth not connected, program exits</string>
<string name="bluetooth_open_secess">Connection successful</string> <string name="bluetooth_open_secess">Connection successful</string>
<string name="service_addr">service address</string>
<string name="server_port">service port</string>
<string name="label_error">Label error, unable to parse</string>
</resources> </resources>

@ -38,4 +38,7 @@
<string name="dialog_button_text">Tôi biết rồi</string> <string name="dialog_button_text">Tôi biết rồi</string>
<string name="bluetooth_open_state">Bluetooth không kết nối, chương trình thoát</string> <string name="bluetooth_open_state">Bluetooth không kết nối, chương trình thoát</string>
<string name="bluetooth_open_secess">Kết nối thành công</string> <string name="bluetooth_open_secess">Kết nối thành công</string>
<string name="service_addr">Địa chỉ dịch vụ</string>
<string name="server_port">Cổng dịch vụ</string>
<string name="label_error">Lỗi thẻ, không thể giải quyết</string>
</resources> </resources>

@ -36,5 +36,8 @@
<string name="scanning_area">扫描区域</string> <string name="scanning_area">扫描区域</string>
<string name="dialog_button_text">我知道了</string> <string name="dialog_button_text">我知道了</string>
<string name="bluetooth_open_state">蓝牙未连接,程序退出</string> <string name="bluetooth_open_state">蓝牙未连接,程序退出</string>
<string name="bluetooth_open_secess">蓝牙连接成功</string>> <string name="bluetooth_open_secess">蓝牙连接成功</string>
<string name="service_addr">服务地址</string>
<string name="server_port">服务端口</string>
<string name="label_error">标签错误,无法解析</string>>
</resources> </resources>
Loading…
Cancel
Save