qcloud-iotexplorer-appdev-plugin-wificonf-blecombo
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,23 +0,14 @@ | ||
import { WifiConfOption } from 'qcloud-iotexplorer-appdev-plugin-wificonf-core'; | ||
import { BleComboLLSyncTaskOptions, BleComboEspTaskOptions, BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter } from './protocols'; | ||
import { AppDevPlugin, AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
interface BLEWifiConfOption extends WifiConfOption { | ||
deviceAdapter: any; | ||
bleComboProto: 'BLE_COMBO_ESP' | 'BLE_COMBO_LLSYNC'; | ||
export declare type BLEWifiConfOption = BleComboLLSyncTaskOptions | BleComboEspTaskOptions; | ||
declare module 'qcloud-iotexplorer-appdev-sdk' { | ||
interface AppDevPlugins { | ||
wifiConfBleCombo: { | ||
start(options: BLEWifiConfOption): Promise<void>; | ||
}; | ||
} | ||
} | ||
export interface TaskOptions extends BLEWifiConfOption { | ||
reporter: { | ||
info: (params: { | ||
code: string; | ||
detail?: Record<string, unknown>; | ||
}) => void; | ||
error: (err: any) => void; | ||
}; | ||
} | ||
export { BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter, }; | ||
export default class BleComboPlugin implements AppDevPlugin { | ||
static install(sdk: AppDevSdk): void; | ||
} | ||
export declare const BleComboProtocols: { | ||
BLE_COMBO_ESP: string; | ||
BLE_COMBO_LLSYNC: string; | ||
}; | ||
export * from './blueToothAdapter'; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboProtocols=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),blecombo_1=require("./blecombo"),constants_1=require("./constants"),llsyncBlecombo_1=require("./llsyncBlecombo"),delay=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,WifiConfStepDesp=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepDesp,getBleComboProtoHandler=function(e){var o=e.bleComboProto,t=e.deviceAdapter,r=o||t.protocol;if(!r)throw new Error("请提供配网协议字段 bleComboProto");switch(r){case constants_1.BLE_COMBO_ESP:return new blecombo_1.BleComboTask(e);case constants_1.BLE_COMBO_LLSYNC:return new llsyncBlecombo_1.LLSyncBleComboTask(e);default:throw console.warn("没有找到 bleComboProto: %s对应的处理函数,请确认插件是否支持该协议",o),new Error("没有找到 "+o+" 对应的处理函数")}},BleComboPlugin=function(){function e(){}return e.install=function(e){e.plugins.wifiConfBleCombo={start:function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,t,r,n,i,s,_,l,c,a,d,u,C,p,f=this;return tslib_1.__generator(this,(function(b){switch(b.label){case 0:o=e.onError,t=e.onProgress,r=e.onComplete,n=e.wifiConfToken,i=function(e){return void 0===e&&(e=1e3),tslib_1.__awaiter(f,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,delay(e)];case 1:return o.sent(),[2]}}))}))},t({code:WifiConfStepCode.PROTOCOL_START}),b.label=1;case 1:b.trys.push([1,13,,14]),s=Date.now(),_=getBleComboProtoHandler(tslib_1.__assign(tslib_1.__assign({},e),{reporter:{info:function(e,o){void 0===o&&(o={}),t({code:WifiConfStepCode.PROTOCOL_DETAIL,detail:{message:WifiConfStepCode.PROTOCOL_DETAIL+"("+WifiConfStepDesp[WifiConfStepCode.PROTOCOL_DETAIL]+": "+e+")",data:o}})},error:function(e){void 0===e&&(e={}),o({code:"PROTOCOL_FAIL",detail:{error:e}})}}})),b.label=2;case 2:return b.trys.push([2,4,,5]),[4,_.start()];case 3:return b.sent(),[3,5];case 4:throw l=b.sent(),console.error(l),tslib_1.__assign({code:"PROTOCOL_FAIL"},l);case 5:return t({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-s}}),[4,i()];case 6:b.sent(),t({code:WifiConfStepCode.BUSINESS_START}),t({code:"BLE_SEND_TOKEN_START",detail:{data:{wifiConfToken:n}}}),c=Date.now(),a=void 0,b.label=7;case 7:return b.trys.push([7,9,,10]),[4,_.sendToken()];case 8:return a=b.sent(),[3,10];case 9:throw d=b.sent(),tslib_1.__assign({code:"BLE_SEND_TOKEN_ERROR"},d);case 10:return[4,t({code:"BLE_SEND_TOKEN_SUCCESS",detail:{timeCost:Date.now()-c,response:a}})];case 11:return b.sent(),[4,i()];case 12:return b.sent(),u=a.productId,C=a.deviceName,r({productId:u,deviceName:C}),_.interrupt(),t({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:{timeCost:Date.now()-s}}),[3,14];case 13:return p=b.sent(),o({code:"",detail:{error:p}}),[3,14];case 14:return[2]}}))}))}}},e}();exports.default=BleComboPlugin,exports.BleComboProtocols={BLE_COMBO_ESP:constants_1.BLE_COMBO_ESP,BLE_COMBO_LLSYNC:constants_1.BLE_COMBO_LLSYNC},tslib_1.__exportStar(require("./blueToothAdapter"),exports); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboLLSyncDeviceAdapter=exports.BleComboEspDeviceAdapter=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),protocols_1=require("./protocols");Object.defineProperty(exports,"BleComboEspDeviceAdapter",{enumerable:!0,get:function(){return protocols_1.BleComboEspDeviceAdapter}}),Object.defineProperty(exports,"BleComboLLSyncDeviceAdapter",{enumerable:!0,get:function(){return protocols_1.BleComboLLSyncDeviceAdapter}});var BleComboTask_1=require("./protocols/BleComboTask"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),delay=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,WifiConfStepDesp=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepDesp,getBleComboProtoHandler=function(e){switch(e.bleComboProto){case BleComboTask_1.BleComboType.BLE_COMBO_ESP:return new protocols_1.BleComboEspTask(e);case BleComboTask_1.BleComboType.BLE_COMBO_LLSYNC:return new protocols_1.BleComboLLSyncTask(e);default:console.warn("没有找到 bleComboProto 对应的 bleComboHandler:",e.bleComboProto)}},BleComboPlugin=function(){function e(){}return e.install=function(e){e.plugins.wifiConfBleCombo={start:function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,t,r,i,n,s,l,a,c,_,d,p,u,C,f=this;return tslib_1.__generator(this,(function(b){switch(b.label){case 0:o=e.onError,t=e.onProgress,r=e.onComplete,i=e.wifiConfToken,n=function(e){return void 0===e&&(e=1e3),tslib_1.__awaiter(f,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,delay(e)];case 1:return o.sent(),[2]}}))}))},t({code:WifiConfStepCode.PROTOCOL_START}),b.label=1;case 1:b.trys.push([1,13,,14]),s=Date.now(),l=getBleComboProtoHandler(tslib_1.__assign(tslib_1.__assign({},e),{reporter:{info:function(e,o){void 0===o&&(o={}),t({code:WifiConfStepCode.PROTOCOL_DETAIL,detail:{message:WifiConfStepCode.PROTOCOL_DETAIL+"("+WifiConfStepDesp[WifiConfStepCode.PROTOCOL_DETAIL]+": "+e+")",data:o}})},error:function(e){o({code:"PROTOCOL_FAIL",detail:{error:e}})}}})),b.label=2;case 2:return b.trys.push([2,4,,5]),[4,l.start()];case 3:return b.sent(),[3,5];case 4:throw a=b.sent(),console.error(a),tslib_1.__assign({code:"PROTOCOL_FAIL"},a);case 5:return t({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-s}}),[4,n()];case 6:b.sent(),t({code:WifiConfStepCode.BUSINESS_START}),t({code:"BLE_SEND_TOKEN_START",detail:{data:{wifiConfToken:i}}}),c=Date.now(),_=void 0,b.label=7;case 7:return b.trys.push([7,9,,10]),[4,l.sendToken()];case 8:return _=b.sent(),[3,10];case 9:throw d=b.sent(),tslib_1.__assign({code:"BLE_SEND_TOKEN_ERROR"},d);case 10:return[4,t({code:"BLE_SEND_TOKEN_SUCCESS",detail:{timeCost:Date.now()-c,response:_}})];case 11:return b.sent(),[4,n()];case 12:return b.sent(),p=_.productId,u=_.deviceName,r({productId:p,deviceName:u}),l.interrupt(),t({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:{timeCost:Date.now()-s}}),[3,14];case 13:return C=b.sent(),o({code:"",detail:{error:C}}),[3,14];case 14:return[2]}}))}))}}},e}();exports.default=BleComboPlugin; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-blecombo", | ||
"version": "1.0.2", | ||
"description": "蓝牙辅助配网小程序sdk插件", | ||
"version": "1.1.0", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"keywords": [ | ||
"ble", | ||
"iot", | ||
"qcloud" | ||
], | ||
"scripts": { | ||
"start": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib -w", | ||
"build": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib && node ../../bin/minify.js -p plugin-wificonf-blecombo -t lib", | ||
"typing": "cd @types && tsc" | ||
"typing": "cd @types && tsc", | ||
"dev": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib --watch" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/tencentyun/qcloud-iotexplorer-appdev-miniprogram-sdk-demo/issues" | ||
}, | ||
"dependencies": { | ||
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^1.1.5", | ||
"qcloud-iotexplorer-appdev-sdk": "^1.1.5", | ||
"qcloud-iotexplorer-bluetooth-adapter": "^0.2.4", | ||
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^1.1.11", | ||
"qcloud-iotexplorer-appdev-sdk": "^1.1.10", | ||
"qcloud-iotexplorer-bluetooth-adapter": "^0.3.0", | ||
"qcloud-iotexplorer-bluetooth-adapter-llsync": "^1.1.0", | ||
"spark-md5": "^3.0.1", | ||
@@ -22,3 +26,6 @@ "tslib": "^2.0.1" | ||
"author": "", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/tencentyun/qcloud-iotexplorer-appdev-sdk/issues" | ||
} | ||
} |
@@ -24,7 +24,5 @@ # qcloud-iotexplorer-appdev-plugin-wificonf-blecombo | ||
```js | ||
import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
import BleComboPlug from 'qcloud-iotexplorer-appdev-plugin-wificonf-blecombo'; | ||
const sdk = new AppDevSdk(...); | ||
sdk.usePlugin(BleComboPlug); | ||
BleComboPlug.install(sdk); | ||
``` | ||
@@ -49,13 +47,8 @@ | ||
deviceAdapters: [ | ||
BleComboDeviceAdapter, | ||
StandardBleComboDeviceAdapter, | ||
// BleComboDeviceAdapter, 如果是BluFi方式配网,可以使用这个deviceAdapter | ||
], | ||
}); | ||
``` | ||
在实例化 blueToothAdapter时,我们需要传入想要支持设备的 DeviceAdapter。目前插件内置了两种`DeviceAdapter`: | ||
- BleComboDeviceAdapter: 支持通过[BluFi协议](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/blufi.html)进行蓝牙辅助配网 | ||
- StandardBleComboDeviceAdapter: 支持通过[LLSync协议](https://github.com/tencentyun/qcloud-iot-explorer-BLE-sdk-embedded/blob/master/docs/LLSync%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5%E5%8D%8F%E8%AE%AE.pdf)进行蓝牙辅助配网 | ||
您也可以借助[qcloud-iotexplorer-bluetooth-adapter](https://github.com/tencentyun/qcloud-iotexplorer-bluetooth-adapter),实现自己的DeviceAdapter,来支持其他协议 | ||
#### 2. 获取蓝牙设备列表 | ||
@@ -163,5 +156,4 @@ | ||
``` | ||
这段代码中的 bleComboProto 字段,表示采用哪种配网协议, `BLE_COMBO_ESP`表示 esp32 [自有的配网协议](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/blufi.html#uuid),`BLE_COMBO_LLSYNC`表示[LLsync配网协议](https://github.com/tencentyun/qcloud-iot-explorer-BLE-sdk-embedded/blob/master/docs/LLSync%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5%E5%8D%8F%E8%AE%AE.pdf); | ||
关于 bluetoothAdapter 的 API 更多介绍,请参考 https://github.com/tencentyun/qcloud-iotexplorer-bluetooth-adapter | ||
一个可用的蓝牙辅助配网 demo 请参考: [qcloud-iotexplorer-appdev-miniprogram-sdk-demo](https://github.com/tencentyun/qcloud-iotexplorer-appdev-miniprogram-sdk-demo) | ||
关于 bluetoothAdapter 的 api 更多介绍,请参考 https://github.com/tencentyun/qcloud-iotexplorer-bluetooth-adapter |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
7
57935
6
25
583
157
2
+ Addedevent-emitter-for-miniprogram@0.0.24(transitive)
+ Addedlodash.uniqwith@4.5.0(transitive)
+ Addedqcloud-iotexplorer-bluetooth-adapter@0.3.330.8.4(transitive)
+ Addedqcloud-iotexplorer-bluetooth-adapter-llsync@1.9.5(transitive)
+ Addedqcloud-iotexplorer-common-libs@0.0.190.9.4(transitive)
- Removedevent-emitter-for-miniprogram@0.0.12(transitive)
- Removedqcloud-iotexplorer-bluetooth-adapter@0.2.8(transitive)
Updatedqcloud-iotexplorer-appdev-plugin-wificonf-core@^1.1.11