From de8c0011d11e878d7dc36c9f2b25bb970347d77e Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Fri, 7 Jun 2024 09:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20user=E5=8C=BA=E8=AF=BB?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jinyu_rfid/ReadBlueToothActivity.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/example/jinyu_rfid/ReadBlueToothActivity.java b/app/src/main/java/com/example/jinyu_rfid/ReadBlueToothActivity.java index ebeaecf..32d433a 100644 --- a/app/src/main/java/com/example/jinyu_rfid/ReadBlueToothActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/ReadBlueToothActivity.java @@ -46,7 +46,6 @@ import okhttp3.RequestBody; public class ReadBlueToothActivity extends BaseActivity { private ResultAdapter adapter; - private String[] stringArray; private List list; private ActivityBluetoothReadBinding binding; @@ -154,13 +153,23 @@ public class ReadBlueToothActivity extends BaseActivity { @Override public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); - String receivedData = (String) msg.obj; - if (receivedData.substring(0, 2).equals("GR")) { - var trim = receivedData.substring(2, receivedData.length()).trim(); + String receivedData = msg.obj.toString().trim(); + if (receivedData.equals("N1")){ + if (activityType) { + readInfo(null); + }else { + readEPCInfo(null); + } + return; + } + + + if (receivedData.startsWith("GR")) { + var trim = receivedData.substring(2); if (activityType) { if (user == null) { user = trim; - // Log.e("TAG", "handleMessage1:" + user); + Log.e("TAG", "handleMessage1:" + user); try { outputStream.write("GR301F3E\r".getBytes()); } catch (IOException e) { @@ -170,9 +179,9 @@ public class ReadBlueToothActivity extends BaseActivity { } return; } - user += receivedData.substring(2, receivedData.length()).trim(); - // Log.e("TAG", "handleMessage-:" + "4532383036463132303030303030303234314632323541337E33323433323034303634307E4A494E59557E3338352F36355232322E357E4A593539387E323450527E3338352F36355232322E35203136344B2032345052204A5935393820424C34454A597E4B7E3136347E3535352E307E5F7E5F7E"); - // Log.e("TAG", "handleMessage2:" + user); + user += receivedData.substring(2).trim(); + Log.e("TAG", "handleMessage-:" + "4532383036463132303030303030303234314632323541337E33323433323034303634307E4A494E59557E3338352F36355232322E357E4A593539387E323450527E3338352F36355232322E35203136344B2032345052204A5935393820424C34454A597E4B7E3136347E3535352E307E5F7E5F7E"); + Log.e("TAG", "handleMessage2:" + user); readUserInfo(user); user = null; } else { @@ -198,7 +207,7 @@ public class ReadBlueToothActivity extends BaseActivity { public void readInfo(View view) { user = null; try { - outputStream.write("GR300218\r".getBytes()); + outputStream.write("GR30003E\r".getBytes()); } catch (IOException e) { // e.printStackTrace(); Toast.makeText(context, getString(R.string.bluetooth_open_state), Toast.LENGTH_SHORT).show();