跳到主要内容

设备管理

更新时间:2025-09-26 11:01:11

设备管理,包括:设备列表等功能。

接口与类型定义详见sdk中dist目录下index.d.ts文件

/**
* 设备列表
* @param deviceListReq - 设备列表请求参数
* @returns
* @public
*/
declare function getDeviceList(deviceListReq: IDeviceListReq): Promise<IDeviceListResp>;

/**
* 获取网关子设备
* @param subListReq - 获取网关子设备列表请求参数
* @returns
* @public
*/
declare function getGatewaySubList(subListReq: GatewaySubListReq): Promise<IDeviceListResp>;

/**
* 获取设备详细
* 第三方可能用自己的设备列表,只有iotId,productKey,deviceName 需要请求数据用于后续业务开发
*
* @param deviceList - 基础设备列表 可能只有iotId,productKey,deviceName
* @public
*/
declare function getDeviceDetail(deviceList: PlayDeviceInfo[]): Promise<PlayDeviceInfo[]>;

export declare namespace RTCXDeviceMgr {
export {
getDeviceList,
getGatewaySubList,
getDeviceDetail,
}
}

设备列表

import {
RTCXDeviceMgr,
RTCXDeviceMgrTypes,
} from '@rtcx/websdk'

const deviceList = ref<RTCXDeviceMgrTypes.PlayDeviceInfo[]>([])

const params: RTCXDeviceMgrTypes.IDeviceListReq = {
pageNo: 1,
pageSize: 100,
}

RTCXDeviceMgr.getDeviceList(params).then((resp) => {
deviceList.value = resp.data
})
.catch(console.error)

网关子设备

获取网关子设备列表信息

import {
RTCXDeviceMgr,
RTCXDeviceMgrTypes,
} from '@rtcx/websdk'

const subDeviceList = ref<RTCXDeviceMgrTypes.PlayDeviceInfo[]>([])

const params: RTCXDeviceMgrTypes.GatewaySubListReq = {
deviceInfo,
pageNo: 1,
pageSize: 100,
}

RTCXDeviceMgr.getGatewaySubList(params).then((resp) => {
subDeviceList.value = resp.data
})
.catch(console.error)

设备详细

第三方可能用自己的设备列表,只有iotId,productKey,deviceName 需要请求数据用于后续业务开发。与设备列表接口返回的字段会少一些。

import {
RTCXDeviceMgr,
RTCXDeviceMgrTypes,
} from '@rtcx/websdk'

const deviceList = ref<RTCXDeviceMgrTypes.PlayDeviceInfo[]>([])

const sampleDeviceInfo: RTCXDeviceMgrTypes.ISampleDeviceInfo = {
iotId: deviceInfo.iotId,
productKey: deviceInfo.productKey,
deviceName: deviceInfo.deviceName,
}

return RTCXDeviceMgr.getDeviceDetail([params]).then((resp) => {
deviceList.value = resp.data
})
.catch(console.error)