publishDps(params: Object)

版本要求:
DeviceKit≥1.2.6@ray-js/ray≥1.7.68
支持平台:
iOSAndroid
import { device } from '@ray-js/ray';

const { publishDps } = device;

// Promise 调用
try {
  const res = await publishDps({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

描述

发送 dps

参数

属性类型必填说明
deviceIdstring是设备id
是dps
modenumber是下发通道类型 0: 局域网 1: 网络 2: 自动
pipelinesnumber[]是下发通道的优先级 LAN = 0, // LAN MQTT = 1, // MQTT HTTP = 2, // Http BLE = 3, // Single Point Bluetooth SIGMesh = 4, // Sig Mesh BLEMesh = 5, // Thing Private Mesh BLEBeacon = 6, // Beacon
是预留下发逻辑配置标记,后续可以拓展,例如下发声音,下发操作后续动作等等
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)
否接口调用成功的回调函数
fail(params: Object) => void否接口调用失败的回调函数
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { device } from '@ray-js/ray'

device.publishDps({
  deviceId: "xx",
  dps: { "xx": {} },
  mode: 1,
  pipelines: [1],
  options: { "xx": {} },
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});