qcloud-iotexplorer-bluetooth-adapter
Advanced tools
Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8
@@ -227,6 +227,4 @@ "use strict"; | ||
} | ||
else { | ||
// 当前不可用 | ||
throw { errCode: 10001 }; | ||
} | ||
// 当前不可用 | ||
throw { errCode: 10001 }; | ||
} | ||
@@ -278,3 +276,4 @@ await Promise.all([ | ||
this._bluetoothApi.offBluetoothDeviceFound(handleBlueToothDeviceFound); | ||
this._deviceAdapterStore.getAll().forEach((deviceAdapter) => { | ||
this._deviceAdapterStore.getAll() | ||
.forEach((deviceAdapter) => { | ||
if (deviceAdapter.isConnected) { | ||
@@ -613,14 +612,20 @@ this.onBleConnectionStateChange({ | ||
// 必须在这里挂载实例,因为连接设备时触发的一些回调是从 this._deviceMap 上去找 deviceAdapter 触发的 | ||
deviceAdapter = new DeviceAdapter({ | ||
deviceId, | ||
deviceName, | ||
// 标准蓝牙协议在设备里面是有productId写入的 | ||
productId, | ||
name, | ||
actions: this._actions, | ||
bluetoothApi: this._bluetoothApi, | ||
h5Websocket: this._h5Websocket, | ||
extendInfo, | ||
bluetoothAdapter: this, | ||
}); | ||
try { | ||
deviceAdapter = new DeviceAdapter({ | ||
deviceId, | ||
deviceName, | ||
// 标准蓝牙协议在设备里面是有productId写入的 | ||
productId, | ||
name, | ||
actions: this._actions, | ||
bluetoothApi: this._bluetoothApi, | ||
h5Websocket: this._h5Websocket, | ||
extendInfo, | ||
bluetoothAdapter: this, | ||
}); | ||
} | ||
catch (e) { | ||
console.log('是实例化错了吗', e); | ||
throw e; | ||
} | ||
this._deviceAdapterStore.set(deviceAdapter); | ||
@@ -676,13 +681,20 @@ deviceAdapter | ||
productId = productId || this._productIdMap[serviceId]; | ||
const deviceAdapter = this.instantiateDeviceAdapter({ | ||
deviceId, | ||
serviceId, | ||
deviceName, | ||
name, | ||
productId, | ||
extendInfo, | ||
}, { | ||
DeviceAdapter: SpecificDeviceAdapter, | ||
reuseAdapterInstance, | ||
}); | ||
let deviceAdapter; | ||
try { | ||
deviceAdapter = this.instantiateDeviceAdapter({ | ||
deviceId, | ||
serviceId, | ||
deviceName, | ||
name, | ||
productId, | ||
extendInfo, | ||
}, { | ||
DeviceAdapter: SpecificDeviceAdapter, | ||
reuseAdapterInstance, | ||
}); | ||
} | ||
catch (e) { | ||
console.log('猜测这里错了 instantiateDeviceAdapter', e); | ||
throw e; | ||
} | ||
if (deviceAdapter === null || deviceAdapter === void 0 ? void 0 : deviceAdapter.isConnected) { | ||
@@ -737,29 +749,27 @@ return deviceAdapter; | ||
} | ||
else { | ||
const deviceInfo = await this.searchDevice({ | ||
deviceId, | ||
serviceId, | ||
serviceIds, | ||
deviceName, | ||
productId, | ||
ignoreDeviceIds, | ||
timeout, | ||
extendInfo, | ||
ignoreWarning: true, | ||
disableCache, | ||
DeviceAdapter, | ||
}); | ||
if (!deviceInfo) { | ||
return Promise.reject({ code: 'DeviceNotFound', msg: `未搜索到设备 ${productId}/${deviceName}` }); | ||
} | ||
if (!deviceInfo.productId && productId) { | ||
deviceInfo.productId = productId; | ||
} | ||
deviceAdapter = await this.connectDevice(deviceInfo, { | ||
autoNotify, | ||
disableCache, | ||
DeviceAdapter, | ||
}); | ||
return deviceAdapter; | ||
const deviceInfo = await this.searchDevice({ | ||
deviceId, | ||
serviceId, | ||
serviceIds, | ||
deviceName, | ||
productId, | ||
ignoreDeviceIds, | ||
timeout, | ||
extendInfo, | ||
ignoreWarning: true, | ||
disableCache, | ||
DeviceAdapter, | ||
}); | ||
if (!deviceInfo) { | ||
return Promise.reject({ code: 'DeviceNotFound', msg: `未搜索到设备 ${productId}/${deviceName}` }); | ||
} | ||
if (!deviceInfo.productId && productId) { | ||
deviceInfo.productId = productId; | ||
} | ||
deviceAdapter = await this.connectDevice(deviceInfo, { | ||
autoNotify, | ||
disableCache, | ||
DeviceAdapter, | ||
}); | ||
return deviceAdapter; | ||
} | ||
@@ -766,0 +776,0 @@ async startScanAdvert() { |
{ | ||
"name": "qcloud-iotexplorer-bluetooth-adapter", | ||
"version": "3.0.0-alpha.7", | ||
"version": "3.0.0-alpha.8", | ||
"description": "", | ||
@@ -21,7 +21,7 @@ "bugs": { | ||
"dependencies": { | ||
"event-emitter-for-miniprogram": "3.0.0-alpha.7", | ||
"event-emitter-for-miniprogram": "3.0.0-alpha.8", | ||
"lodash.uniqwith": "^4.5.0", | ||
"qcloud-iotexplorer-appdev-sdk": "3.0.0-alpha.7", | ||
"qcloud-iotexplorer-common-libs": "3.0.0-alpha.7", | ||
"qcloud-iotexplorer-logger": "3.0.0-alpha.7", | ||
"qcloud-iotexplorer-appdev-sdk": "3.0.0-alpha.8", | ||
"qcloud-iotexplorer-common-libs": "3.0.0-alpha.8", | ||
"qcloud-iotexplorer-logger": "3.0.0-alpha.8", | ||
"tslib": "^2.1.0" | ||
@@ -33,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "2beee0b6e6dcf5f91d52e77b54f80d8312110cbd" | ||
"gitHead": "674e0cca069a33a99965f5bd2bc5ceaab04a3648" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
442246
6496
+ Addedevent-emitter-for-miniprogram@3.0.0-alpha.8(transitive)
+ Addedqcloud-iotexplorer-appdev-sdk@3.0.0-alpha.8(transitive)
+ Addedqcloud-iotexplorer-common-libs@3.0.0-alpha.8(transitive)
+ Addedqcloud-iotexplorer-logger@3.0.0-alpha.8(transitive)
- Removedevent-emitter-for-miniprogram@3.0.0-alpha.7(transitive)
- Removedqcloud-iotexplorer-appdev-sdk@3.0.0-alpha.7(transitive)
- Removedqcloud-iotexplorer-common-libs@3.0.0-alpha.7(transitive)
- Removedqcloud-iotexplorer-logger@3.0.0-alpha.7(transitive)