uniapp物联网无网络智能配对模块
# 引入致前
- 腾讯云技术文档:物联网开发平台 (opens new window) https://cloud.tencent.com/document/product/1081/40773 (opens new window)
- npm: https://www.npmjs.com/package/qcloud-iotexplorer-appdev-sdk (opens new window)
- demo: https://github.com/tencentyun/qcloud-iotexplorer-appdev-node-sdk (opens new window)
- 可以直接在github上搜索
qcloud-iotexplorer-appdev-sdk
- 可以直接在github上搜索
# 嵌入方法
- 新建
qcloud-iotexplorer-appdev-sdk.js
qcloud-iotexplorer-appdev-sdk.js (opens new window)
main.js
......
const {
QcloudIotExplorerAppDevSdk
} = require('@/utils/qcloud-iotexplorer-appdev-sdk');
Vue.use(uView);
......
var _sdk = new QcloudIotExplorerAppDevSdk({
debug: true,
appKey: '',
getAccessToken: () => {
console.log('getAccessToken...');
},
wsConfig: {}
});
Vue.prototype._sdk = _sdk
_sdk.init();
......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
- 使用
挂载到vue实例上就很好使用啦 通过打开手机gps,通过api接口获取wifi信息及填入的密码 以广播的形式发送 具体事项根据业务来 贴上我们产品的图
......
this._sdk.connectDevice({
connectType: 'smartconfig',
connectOpts: {
targetWifiInfo: wifiInfo,
bindDeviceToken: '123456789',
onProgress(progress) {
console.log('onProgress', progress);
},
onError(error) {
console.error('onError', error);
},
onComplete() {
console.log('onComplete');
// this.clearAllId();
}
}
});
......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
上次更新: 2022/05/04, 15:35:13