offInitialized
描述
取消监听智能设备模型初始化完毕事件
类型
export default class SmartDeviceModel<
S extends ReadonlyDpSchemaList,
A extends SmartDeviceModelAbility = SmartDeviceModelAbility,
> {
static offInitialized: (id: number) => void;
}
请求参数
参数 | 数据类型 | 说明 | 是否必填 |
---|---|---|---|
id | number | 初始化完毕回调事件 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 小程序开发。