# setupBlueConnection ^5.9.0
根据蓝牙信息建立蓝牙连接,并且可以选择是否挂靠网桥(配网sdk充当网桥角色)
提示:扫描到设备之后再建立蓝牙连接
# 请求参数
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
param | Object | Y | {}属性: name:{Type: String, Default: N/A, Type: String, Default: N/A, Description: 鉴权密钥(长度32) (可以从getDeviceInfo中读取deviceBtToken<) mac:{Type: String, Default: N/A, Description: 蓝牙mac地址,((可以使用getDeviceInfo中返回的mac字段)) applianceId:{Type: String, Default: N/A, Description: 设备id,(可以从getDeviceInfo中读取deviceId<) moduleType:{Type: String, Default: 0, Description: (^7.3.0) 0:代表单蓝牙模组,1:ble+wireless network双模组。不传默认单蓝牙模组,2:(^7.6.0)表示单蓝牙模组,不支持token校验 } gateWayProxyType:Default: 0, Description: (^9.4.0) 0:无需代理,1:本地lua 代理,2:云端websocket代理 3:本地物模型代理 } optPermissionType:Default: 0, Description: (^10.1.0) 申请权限,2:强制申请权限(不传默认0) } | 请求参数 |
# 接口调用示例
let param={
name:"midea_xx_xxxx", //蓝牙名称,从getDeviceInfo中读取ssid
token:"xxxx", //鉴权密钥 长度32,从getDeviceInfo中读取deviceBtToken,
mac:"xxxx", //蓝牙mac地址,从getDeviceInfo中读取mac
applianceId:"xxx", //设备id, getDeviceInfo中读取deviceId
gateWayProxyType: 0, // 0:无需代理 1:本地lua 代理 2:云端websocket代理 3:本地物模型代理
optPermissionType: 0 // 0:申请权限,2:强制申请权限(不传默认0)
}
this.$bridge
.setupBlueConnection(params)
.then(res => {
this.$alert(res)
})
.catch(err => {
this.$toast(err)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 返回参数
通过监听 receiveMessageFromApp 获取
失败时返回
| Prop | Type | Default | Description |
|---|---|---|---|
errorCode | Number | N/A | 请求失败错误码:-1连接失败 / -2发现服务失败 / -3密钥协商失败/ -4token校验失败 / -510s超时 |
TIP
该接口基于mSmart 协议,底层由singleBlueToothModule单蓝牙支持