From fdae6eeedf6cb8b0d99d4841404e6a3cd268246e Mon Sep 17 00:00:00 2001
From: aihe <961836564@qq.com>
Date: Wed, 15 May 2024 01:00:36 +0800
Subject: [PATCH] uu
---
.../nativeBlueTooth.js | 20 +-
.../tpx-bluetooth-native.vue | 242 ++++++++++++
.../render-template-native.vue | 193 ++++++++++
.../tpx-bluetooth/tpx-bluetooth-native.vue | 359 ------------------
4 files changed, 447 insertions(+), 367 deletions(-)
rename components/{tpx-bluetooth => tpx-bluetooth-native}/nativeBlueTooth.js (94%)
create mode 100644 components/tpx-bluetooth-native/tpx-bluetooth-native.vue
create mode 100644 components/tpx-bluetooth-print/render-template-native.vue
delete mode 100644 components/tpx-bluetooth/tpx-bluetooth-native.vue
diff --git a/components/tpx-bluetooth/nativeBlueTooth.js b/components/tpx-bluetooth-native/nativeBlueTooth.js
similarity index 94%
rename from components/tpx-bluetooth/nativeBlueTooth.js
rename to components/tpx-bluetooth-native/nativeBlueTooth.js
index b15dd06..f645b75 100644
--- a/components/tpx-bluetooth/nativeBlueTooth.js
+++ b/components/tpx-bluetooth-native/nativeBlueTooth.js
@@ -128,7 +128,7 @@ var blueToothTool = {
try {
activity.unregisterReceiver(btFindReceiver);
} catch(e) {
-
+ console.log("turnOffBluetooth error=========", e)
}
btFindReceiver = null;
}
@@ -181,7 +181,7 @@ var blueToothTool = {
try {
activity.unregisterReceiver(btFindReceiver);
} catch(e) {
- console.error(e);
+ console.log("discoveryNewDevice error=========", e)
}
btFindReceiver = null;
this.cancelDiscovery();
@@ -231,7 +231,7 @@ var blueToothTool = {
try {
activity.unregisterReceiver(btStatusReceiver);
} catch(e) {
- console.error(e);
+ console.log("listenBluetoothStatus error=========", e)
}
btStatusReceiver = null;
}
@@ -295,7 +295,7 @@ var blueToothTool = {
let device = invoke(btAdapter, "getRemoteDevice", address);
btSocket = invoke(device, "createRfcommSocketToServiceRecord", MY_UUID);
} catch(e) {
- console.error(e);
+ console.error("连接失败,获取Socket失败!", e);
shortToast("连接失败,获取Socket失败!");
callback(false)
return false;
@@ -306,14 +306,14 @@ var blueToothTool = {
this.shortToast("连接成功");
callback(true)
} catch(e) {
- console.error(e);
+ console.error("connDevice error:========!", e);
this.shortToast("连接失败");
callback(false)
try {
btSocket.close();
btSocket = null;
} catch(e1) {
- console.error(e1);
+ console.error("btSocket.close error:========!", e1);
}
return false;
}
@@ -344,7 +344,7 @@ var blueToothTool = {
try {
btSocket.close();
} catch(e) {
- console.error(e);
+ console.log("closeBtSocket error=========", e)
btSocket = null;
}
},
@@ -376,7 +376,7 @@ var blueToothTool = {
btInStream = invoke(btSocket, "getInputStream");
btOutStream = invoke(btSocket, "getOutputStream");
} catch(e) {
- console.error(e);
+ console.error("readData error:========!", e);
this.shortToast("创建输入输出流失败!");
this.closeBtSocket();
return false;
@@ -400,6 +400,7 @@ var blueToothTool = {
try {
btOutStream.write([0b00]);
} catch(e) {
+ console.log("===connExceptionCallback===", e)
this.state.readThreadState = false;
this.options.connExceptionCallback && this.options.connExceptionCallback(e);
}
@@ -433,6 +434,7 @@ var blueToothTool = {
try {
btOutStream.write(bytes);
} catch(e) {
+ console.log("sendData error=========", e)
return false;
}
return true;
@@ -443,8 +445,10 @@ var blueToothTool = {
return;
}
try {
+ console.log("====byteData====", byteData)
btOutStream.write(byteData);
} catch(e) {
+ console.log("sendByteData error=========", e)
return false;
}
return true;
diff --git a/components/tpx-bluetooth-native/tpx-bluetooth-native.vue b/components/tpx-bluetooth-native/tpx-bluetooth-native.vue
new file mode 100644
index 0000000..42c5650
--- /dev/null
+++ b/components/tpx-bluetooth-native/tpx-bluetooth-native.vue
@@ -0,0 +1,242 @@
+
+
+
+
+
+
+
+ {{searchLoading?'搜索中...':'搜索周边设备'}}
+
+
+ 停止搜索
+
+
+
+
+ 连接信息
+
+
+
+
+ {{item.title}}
+
+
+ {{item.desc}}
+
+
+
+
+
+
+
+
+
+
+ 蓝牙设备列表
+
+
+
+ {{item.name }}
+
+
+ deviceId:{{item.deviceId}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/tpx-bluetooth-print/render-template-native.vue b/components/tpx-bluetooth-print/render-template-native.vue
new file mode 100644
index 0000000..8f16c63
--- /dev/null
+++ b/components/tpx-bluetooth-print/render-template-native.vue
@@ -0,0 +1,193 @@
+
+
+
+ 确认打印
+
+
+ 打印内容
+
+
+
+
+
+
+
+
+
+
+ 正在打印, 请勿退出页面, 如果卡住了请重连打印机重试
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/tpx-bluetooth/tpx-bluetooth-native.vue b/components/tpx-bluetooth/tpx-bluetooth-native.vue
deleted file mode 100644
index eb252bd..0000000
--- a/components/tpx-bluetooth/tpx-bluetooth-native.vue
+++ /dev/null
@@ -1,359 +0,0 @@
-
-
-
-
-
-
-
- {{searchLoading?'搜索中...':'搜索周边设备'}}
-
-
- 停止搜索
-
-
-
-
- 连接信息
-
-
-
-
- {{item.title}}
-
-
- {{item.desc}}
-
-
-
-
-
-
-
-
-
-
- 蓝牙设备列表
-
-
-
- {{item.name }}
-
-
- 信号强度: {{item.RSSI}}dBm ({{Math.max(100+item.RSSI,0)}}%)
-
-
- deviceId:{{item.deviceId}}
-
-
- Service数量: {{item.advertisServiceUUIDs.length || 0}}
-
-
-
-
-
-
- 服务列表
-
-
-
- uuid: {{item.uuid}}
-
-
-
-
-
-
- 特征值列表
-
-
-
- uuid: {{item.uuid}}
-
-
-
-
- write: {{item.properties.write}}
-
-
- notify: {{item.properties.notify}}
-
-
- indicate: {{item.properties.indicate}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file