局域网 API
ty.device.publishLanMessage
通过 局域网 消息通道下发消息
需引入
DeviceKit,且在>=2.1.6版本才可使用
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| message | string |
是 | 消息内容 | |
| deviceId | string |
是 | 设备 id | |
| protocol | number |
是 | 协议号 | |
| options | any |
否 | 预留下发逻辑配置标记,后续可以拓展,例如下发声音,下发操作后续动作等等 | |
| complete | function |
否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
| success | function |
否 | 接口调用成功的回调函数 | |
| fail | function |
否 | 接口调用失败的回调函数 |
MQTT API
ty.device.getMqttConnectState
获取 mqtt 连接状态 回调返回当前连接情况
需引入
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 } |
ty.device.offMqttConnectState
取消监听:mqtt 连接状态变化事件
需引入
DeviceKit,且在>=2.5.1版本才可使用
参数<

最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=136644563&d=1&t=3&u=303fdc980d164ae582fff15a8fca33e4)
1038

被折叠的 条评论
为什么被折叠?



