# sendBlueLuaRequest ^5.9.0

向向蓝牙设备发送控制指令(传输数据)。调用此方法之前要确保查询接口已返回全状态信息,否则会提示控制失败

# 请求参数

Prop Type Required Default Description
param Object Y {}
属性:
name:{
Type: String,
Default: N/A,
Description: 蓝牙名称 (可以使用getDeviceInfo中返回的ssid字段)
}
mac:{
Type: String,
Default: N/A,
Description: 蓝牙mac地址((可以使用getDeviceInfo中返回的mac字段))
}
applianceId:{
Type: String,
Default: N/A,
Description: 设备id(可以从getDeviceInfo中读取deviceId<)
}
}
data:{
Type: Object,
Default: {},
Description: 期望控制的设备属性和值
}
请求参数

# 接口调用示例

let params={
    mac:"xxxx",//12位蓝牙Mac地址
    name:"midea_xx_xxxx",//蓝牙名称
    applianceId:"xxx",
    data:{
        luaKey1:"xxx",(lua profile文件中定义的key和值)
        luaKey2:"xxx"
    }//期望控制
}
this.$bridge
    .sendBlueLuaRequest(params)
    .then(res => {    
    this.$alert(res)
    })
    .catch(err => {
    this.$toast(err)
    })
// 出参
// 当收到蓝牙数据时,APP通知插件结果:

receiveMessageFromApp({ messageType: "receiveSingleBlueLuaInfo", 
    messageBody: { 
        applianceId:"xxx", 
        data: {
            luaKey1:"xxx",
            luaKey2:"xxx" 
        }
    } 
})

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

# 返回参数

Prop Type Default Description
messageType String receiveSingleBlueLuaInfo H5用来判断消息类型
messageBody Object {}附表1 APP传递的JSON对象
  • 附表1:messageBody返回参数
Prop Type Value Description
applianceId String N/A 设备id
data Object {}
属性:
luaKey1:(lua profile文件中定义的key值){
Type: String,
Default: N/A,
Description: N/A
}
luaKey2:(lua profile文件中定义的key值){
Type: String,
Default: N/A,
Description: N/A
}
...{}
全状态数据

TIP

该接口基于mSmart 协议,底层由singleBlueToothModule单蓝牙支持

Last Updated: 3/9/2022, 1:30:33 PM