智能小程序 Ray 开发智能设备模型面板 SDK —— API 接口汇总(二)

offInitialized

描述

取消监听智能设备模型初始化完毕事件

类型

export default class SmartDeviceModel<
  S extends ReadonlyDpSchemaList,
  A extends SmartDeviceModelAbility = SmartDeviceModelAbility,
> {
  static offInitialized: (id: number) => void;
}

请求参数

参数数据类型说明是否必填
idnumber初始化完毕回调事件 id

返回参数

请求示例-

import { SmartDeviceModel } from '@ray-js/panel-sdk';
 
const id = SmartDeviceModel.onInitialized(() => {
  console.log('智能设备初始化完毕!');
});
 
SmartDeviceModel.onInitialized(id);

返回示例

getDpSchema

描述

获取智能设备 DP Schema(DP 功能点描述)集合

类型

export default class SmartDeviceModel<
  S extends ReadonlyDpSchemaList,
  A extends SmartDeviceModelAbility = SmartDeviceModelAbility,
> {
  getDpSchema: () => GetSmartDeviceModelDpSchema<S>;
}

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。   

请求参数

返回参数

参数数据类型说明
result() => GetSmartDeviceModelDpSchema<S>智能设备 DP Schema(DP 功能点描述)集合

请求示例

const device = await SmartDeviceModel.init<Schema, LampAbilities>();
 
console.log('=== 当前智能设备 DP Schema: ', device.getDpSchema());

返回示例

{
  "power": {
    "attr": 0,
    "canTrigger": true,
    "code": "power",
    "defaultRecommend": false,
    "editPermission": false,
    "executable": true,
    "extContent": "",
    "iconname": "icon-dp_power2",
    "id": 1,
    "mode": "rw",
    "name": "开关",
    "property": {
      "type": "bool"
    },
    "type": "obj"
  },
  "mode": {
    "attr": 0,
    "canTrigger": true,
    "code": "mode",
    "defaultRecommend": false,
    "editPermission": false,
    "executable": true,
    "extContent": "",
    "iconname": "icon-dp_mode",
    "id": 3,
    "mode": "rw",
    "name": "清扫模式",
    "property": {
      "range": [
        "standby",
        "random",
        "smart",
        "wall_follow",
        "mop",
        "spiral",
        "left_spiral",
        "right_spiral",
        "right_bow",
        "left_bow",
        "partial_bow",
        "chargego"
      ],
      "type": "enum"
    },
    "type": "obj"
  }
}

getNetwork

描述

智能设备所处环境的网络状态,基于以下原子方法实现

类型

export interface SmartDeviceModelNetwork {
  /**
   * 是否已连接
   */
  isConnected: boolean;
  /**
   * 网络类型: WIFI | 5G | 4G | 3G | 2G | GPRS | UNKNOWN | NONE
   */
  networkType: string;
  /**
   * 信号强弱,单位 dbm
   */
  signalStrength: number;
}
 
export default class SmartDeviceModel<
  S extends ReadonlyDpSchemaList,
  A extends SmartDeviceModelAbility = SmartDeviceModelAbility,
> {
  getNetwork: () => SmartDeviceModelNetwork;
}

请求参数

返回参数

参数数据类型说明
result() => SmartDeviceModelNetwork智能设备所处环境的网络状态

请求示例

const device = await SmartDeviceModel.init<Schema, LampAbilities>();
 
console.log('=== 当前智能设备所处 App 网络状态: ', device.getNetwork());

返回示例

{
  "isConnected": true,
  "networkType": "WIFI",
  "signalStrength": 100
}

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。  

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoT砖家涂拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值