|
@@ -337,16 +337,25 @@ class bleManager {
|
|
|
}
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- wx.closeBLEConnection({
|
|
|
- deviceId: deviceId,
|
|
|
+ wx.getConnectedBluetoothDevices({
|
|
|
success: (res) => {
|
|
|
- that.publicDevice = null;
|
|
|
- console.log('断开连接成功:', res);
|
|
|
- resolve(res);
|
|
|
+ if (res.devices.length > 0) {
|
|
|
+ wx.closeBLEConnection({
|
|
|
+ deviceId: deviceId,
|
|
|
+ success: (res) => {
|
|
|
+ that.publicDevice = null;
|
|
|
+ resolve(res);
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ resolve(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ resolve(err);
|
|
|
+ }
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- console.error('断开连接失败:', err);
|
|
|
- reject(new Error('断开连接失败'));
|
|
|
+ resolve(err);
|
|
|
}
|
|
|
});
|
|
|
});
|