getMqttConnectState
获取 mqtt 连接状态 回调返回当前连接情况
引入
import { getMqttConnectState } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.5.1
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
object.success 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
connectState | number | mqtt 连接状态 0 连接失败 1 连接成功 |
object.fail 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
offMqttConnectState
取消监听:mqtt 连接状态变化事件
引入
import { offMqttConnectState } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.5.1
版本才可使用
参数
function callback
取消监听:mqtt 连接状态变化事件的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
connectState | number | 是 | mqtt 连接状态 0 连接失败 1 连接成功 |
offMqttMessageReceived
取消监听:MQTT 消息通道消息上报
引入
import { offMqttMessageReceived } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.1.6
版本才可使用
参数
function callback
取消监听:MQTT 消息通道消息上报的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 否 | 设备 id | |
message | any | 是 | 原始消息数据 | |
messageData | any | 是 | 双端抹平后的消息数据 | |
type | string | 是 | 消息类型 | |
protocol | number | 是 | 协议号 | |
topic | string | 否 | topic |
onMqttConnectState
mqtt 连接状态变化事件
引入
import { onMqttConnectState } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.5.1
版本才可使用
参数
function callback
mqtt 连接状态变化事件的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
connectState | number | 是 | mqtt 连接状态 0 连接失败 1 连接成功 |
onMqttMessageReceived
MQTT 消息通道消息上报
引入
import { onMqttMessageReceived } from '@ray-js/ray';
需引入
DeviceKit
,且在>=1.2.6
版本才可使用
参数
function callback
MQTT 消息通道消息上报的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 否 | 设备 id | |
message | any | 是 | 原始消息数据 | |
messageData | any | 是 | 双端抹平后的消息数据 | |
type | string | 是 | 消息类型 | |
protocol | number | 是 | 协议号 | |
topic | string | 否 | topic |
publishMqttMessage
通过 MQTT 消息通道下发消息
引入
import { publishMqttMessage } from '@ray-js/ray';
需引入
DeviceKit
,且在>=1.2.6
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
message | any | 是 | 消息内容 | |
deviceId | string | 是 | 设备 id | |
protocol | number | 是 | 协议号 | |
options | any | 是 | 预留下发逻辑配置标记,后续可以拓展,例如下发声音,下发操作后续动作等等 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
registerMQTTDeviceListener
注册设备的 MQTT 信息监听
引入
import { registerMQTTDeviceListener } from '@ray-js/ray';
需引入
DeviceKit
,且在>=2.3.1
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | deviceId 设备 id 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。