qcloud-iotexplorer-bluetooth-adapter
Advanced tools
Comparing version 3.0.0-alpha.8 to 3.0.0-alpha.9
@@ -227,4 +227,6 @@ "use strict"; | ||
} | ||
// 当前不可用 | ||
throw { errCode: 10001 }; | ||
else { | ||
// 当前不可用 | ||
throw { errCode: 10001 }; | ||
} | ||
} | ||
@@ -276,4 +278,3 @@ await Promise.all([ | ||
this._bluetoothApi.offBluetoothDeviceFound(handleBlueToothDeviceFound); | ||
this._deviceAdapterStore.getAll() | ||
.forEach((deviceAdapter) => { | ||
this._deviceAdapterStore.getAll().forEach((deviceAdapter) => { | ||
if (deviceAdapter.isConnected) { | ||
@@ -612,20 +613,14 @@ this.onBleConnectionStateChange({ | ||
// 必须在这里挂载实例,因为连接设备时触发的一些回调是从 this._deviceMap 上去找 deviceAdapter 触发的 | ||
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; | ||
} | ||
deviceAdapter = new DeviceAdapter({ | ||
deviceId, | ||
deviceName, | ||
// 标准蓝牙协议在设备里面是有productId写入的 | ||
productId, | ||
name, | ||
actions: this._actions, | ||
bluetoothApi: this._bluetoothApi, | ||
h5Websocket: this._h5Websocket, | ||
extendInfo, | ||
bluetoothAdapter: this, | ||
}); | ||
this._deviceAdapterStore.set(deviceAdapter); | ||
@@ -681,20 +676,13 @@ deviceAdapter | ||
productId = productId || this._productIdMap[serviceId]; | ||
let deviceAdapter; | ||
try { | ||
deviceAdapter = this.instantiateDeviceAdapter({ | ||
deviceId, | ||
serviceId, | ||
deviceName, | ||
name, | ||
productId, | ||
extendInfo, | ||
}, { | ||
DeviceAdapter: SpecificDeviceAdapter, | ||
reuseAdapterInstance, | ||
}); | ||
} | ||
catch (e) { | ||
console.log('猜测这里错了 instantiateDeviceAdapter', e); | ||
throw e; | ||
} | ||
const deviceAdapter = this.instantiateDeviceAdapter({ | ||
deviceId, | ||
serviceId, | ||
deviceName, | ||
name, | ||
productId, | ||
extendInfo, | ||
}, { | ||
DeviceAdapter: SpecificDeviceAdapter, | ||
reuseAdapterInstance, | ||
}); | ||
if (deviceAdapter === null || deviceAdapter === void 0 ? void 0 : deviceAdapter.isConnected) { | ||
@@ -749,27 +737,29 @@ 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}` }); | ||
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; | ||
} | ||
if (!deviceInfo.productId && productId) { | ||
deviceInfo.productId = productId; | ||
} | ||
deviceAdapter = await this.connectDevice(deviceInfo, { | ||
autoNotify, | ||
disableCache, | ||
DeviceAdapter, | ||
}); | ||
return deviceAdapter; | ||
} | ||
@@ -776,0 +766,0 @@ async startScanAdvert() { |
{ | ||
"name": "qcloud-iotexplorer-bluetooth-adapter", | ||
"version": "3.0.0-alpha.8", | ||
"version": "3.0.0-alpha.9", | ||
"description": "", | ||
@@ -21,7 +21,7 @@ "bugs": { | ||
"dependencies": { | ||
"event-emitter-for-miniprogram": "3.0.0-alpha.8", | ||
"event-emitter-for-miniprogram": "3.0.0-alpha.9", | ||
"lodash.uniqwith": "^4.5.0", | ||
"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", | ||
"qcloud-iotexplorer-appdev-sdk": "3.0.0-alpha.9", | ||
"qcloud-iotexplorer-common-libs": "3.0.0-alpha.9", | ||
"qcloud-iotexplorer-logger": "3.0.0-alpha.9", | ||
"tslib": "^2.1.0" | ||
@@ -33,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "674e0cca069a33a99965f5bd2bc5ceaab04a3648" | ||
"gitHead": "bfa873f67554763526e400c2c2cde89686e46ff8" | ||
} |
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
441747
6486
+ Addedevent-emitter-for-miniprogram@3.0.0-alpha.9(transitive)
+ Addedqcloud-iotexplorer-appdev-sdk@3.0.0-alpha.9(transitive)
+ Addedqcloud-iotexplorer-common-libs@3.0.0-alpha.9(transitive)
+ Addedqcloud-iotexplorer-logger@3.0.0-alpha.9(transitive)
- Removedevent-emitter-for-miniprogram@3.0.0-alpha.8(transitive)
- Removedqcloud-iotexplorer-appdev-sdk@3.0.0-alpha.8(transitive)
- Removedqcloud-iotexplorer-common-libs@3.0.0-alpha.8(transitive)
- Removedqcloud-iotexplorer-logger@3.0.0-alpha.8(transitive)