
使用示例,进行编译,vscode会有报错,但开发小程序工具上是能正常使用的。

我查看了api的代码,实际是返回一个void函数。

使用示例,进行编译,vscode会有报错,但开发小程序工具上是能正常使用的。

我查看了api的代码,实际是返回一个void函数。
图片挂了,再传一下?本身getDeviceInfo是返回一个void,需要在 success回调中获取设备信息数据。
Code: Select all
 /**
   * 获取设备的设备信息
   */
  export function getDeviceInfo(params: {
    /**
     * deviceId 设备id
     * 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取
     */
    deviceId: string
    /** dps */
    dps?: Record<string, {}>
    complete?: () => void
    success?: (params: {
      /** 设备所处房间名 */
      roomName?: string
      /** 产品信息,schema,功能定义都在里面 */
      schema: {}[]
      /**
       * dps
       * 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑
       */
      dps: Record<string, {}>
      /**
       * attribute
       * 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理
       */
      attribute: number
      /**
       * baseAttribute
       * 基础产品属性定义
       */
      baseAttribute: number
      /**
       * capability
       * 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分
       * 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理
       */
      capability: number
      /**
       * dpName
       * 自定义 dp 的名字,通常在面板里会使用到
       */
      dpName: Record<string, string>
      /**
       * ability
       * 目前业务很少使用,用于区分特殊类型的设备
       */
      ability: number
      /**
       * icon
       * 设备的 icon url
       */
      icon: string
      /**
       * devId
       * 设备的唯一 id
       */
      devId: string
      /**
       * verSw
       * 设备固件版本号
       */
      verSw: string
      /**
       * isShare
       * 是否为分享设备,true 则是分享设备
       */
      isShare: boolean
      /**
       * bv
       * 设备的基线版本号
       */
      bv: string
      /**
       * uuid
       * 设备的固件唯一标识
       */
      uuid: string
      /**
       * panelConfig
       * 产品面板里的配置项,通常在 IoT 平台上可以查看到对应的配置
       */
      panelConfig: Record<string, {}>
      /**
       * activeTime
       * 设备激活时间,时间戳
       */
      activeTime: number
      /**
       * devAttribute
       * 设备的业务能力拓展,二进制位的方式进行运算
       */
      devAttribute: number
      /**
       * pcc
       * Thing自研蓝牙 mesh 产品的分类标识
       */
      pcc: string
      /**
       * nodeId
       * 子设备的短地址
       */
      nodeId: string
      /**
       * parentId
       * 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理
       */
      parentId?: string
      /**
       * category
       * 产品的分类
       */
      category: string
      /**
       * standSchemaModel
       * 标准产品功能集定义模型
       */
      standSchemaModel?: {}
      /**
       * productId
       * 设备对应的产品 id
       */
      productId: string
      /**
       * bizAttribute
       * 业务属性能力
       */
      bizAttribute: number
      /**
       * meshId
       * 当前设备对应的蓝牙 mesh id
       */
      meshId: string
      /**
       * 【废弃】sigmeshId
       * 当前设备所属行业属性对应的蓝牙 mesh id
       */
      sigmeshId: string
      /**
       * meta
       * 设备自定义配置元属性,用于存放业务数据
       */
      meta: Record<string, {}>
      /**
       * isLocalOnline
       * 本地局域网是否在线
       */
      isLocalOnline: boolean
      /** 设备云端在线情况 */
      isCloudOnline: boolean
      /**
       * isOnline
       * 设备总的在线情况,只要一个情况在线,就是在线,复合在线情况
       */
      isOnline: boolean
      /**
       * name
       * 设备名称
       */
      name: string
      /** groupId */
      groupId: string
      /**
       * dpCodes
       * 标准功能集 code
       */
      dpCodes: Record<string, {}>
      /** 时区信息 */
      devTimezoneId: string
      /** 设备的功能点执行的时间 */
      dpsTime: Record<string, {}>
      /** 设备纬度 */
      latitude: string
      /** 设备经度 */
      longitude: string
      /** 设备ip地址 */
      ip?: string
      /** 是否为虚拟设备 */
      isVirtualDevice: boolean
      /** zigbeeInstallCode to the cloud to mark the gateway with installation code ability */
      isZigbeeInstallCode: boolean
      /** Activate sub-device capability flag. */
      protocolAttribute: number
      /** 连接状态,nearby状态 */
      connectionStatus: number
      /** 部分设备需要用mac进行唯一识别 ,比如mesh */
      mac?: string
      /** 蓝牙的设备能力值,由设备进行上报 */
      bluetoothCapability?: string
      /** 是否三方matter设备 */
      isTripartiteMatter: boolean
      /** 是否网关设备 */
      isGW: boolean
      /** 是否支持群组 */
      isSupportGroup: boolean
      /** 是否zigbee子设备 */
      isZigBeeSubDev: boolean
      /** cadv版本号 */
      cadv?: string
      /** 设备是否支持OTA */
      isSupportOTA: boolean
      /** 设备图标 */
      iconUrl: string
      /** 设备是否有Wi-Fi模块 */
      hasWifi: boolean
      /** 快捷控制dp */
      switchDp: number
      /** 快捷控制dp */
      switchDps: number[]
      /** 设备Wi-Fi模块的状态:1:不可用 2:可用 */
      wifiEnableState: number
      /** 设备产品配置 */
      configMetas: Record<string, {}>
      /** 是否为matter设备 */
      isMatter: boolean
      /** 设备是否支持双控 */
      isSupportLink: boolean
      /** 是否支持将设备添加到苹果家庭中 */
      isSupportAppleHomeKit?: boolean
      /**
       * attribute 格式化的二进制字符串
       * 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理
       */
      attributeString: string
    }) => void
    fail?: (params: {
      errorMsg: string
      errorCode: string | number
      innerError: {
        errorCode: string | number
        errorMsg: string
      }
    }) => void
  }): void 
   
   
   
   
   
   LGTM
  LGTM
图片用手机编辑一下,目前确定的是用微信自带的截图上传是不成功的
Muzzzhi 2024年 May 27日 10:00图片挂了,再传一下?本身getDeviceInfo是返回一个void,需要在 success回调中获取设备信息数据。
Code: Select all
/** * 获取设备的设备信息 */ export function getDeviceInfo(params: { /** * deviceId 设备id * 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取 */ deviceId: string /** dps */ dps?: Record<string, {}> complete?: () => void success?: (params: { /** 设备所处房间名 */ roomName?: string /** 产品信息,schema,功能定义都在里面 */ schema: {}[] /** * dps * 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑 */ dps: Record<string, {}> /** * attribute * 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理 */ attribute: number /** * baseAttribute * 基础产品属性定义 */ baseAttribute: number /** * capability * 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分 * 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理 */ capability: number /** * dpName * 自定义 dp 的名字,通常在面板里会使用到 */ dpName: Record<string, string> /** * ability * 目前业务很少使用,用于区分特殊类型的设备 */ ability: number /** * icon * 设备的 icon url */ icon: string /** * devId * 设备的唯一 id */ devId: string /** * verSw * 设备固件版本号 */ verSw: string /** * isShare * 是否为分享设备,true 则是分享设备 */ isShare: boolean /** * bv * 设备的基线版本号 */ bv: string /** * uuid * 设备的固件唯一标识 */ uuid: string /** * panelConfig * 产品面板里的配置项,通常在 IoT 平台上可以查看到对应的配置 */ panelConfig: Record<string, {}> /** * activeTime * 设备激活时间,时间戳 */ activeTime: number /** * devAttribute * 设备的业务能力拓展,二进制位的方式进行运算 */ devAttribute: number /** * pcc * Thing自研蓝牙 mesh 产品的分类标识 */ pcc: string /** * nodeId * 子设备的短地址 */ nodeId: string /** * parentId * 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理 */ parentId?: string /** * category * 产品的分类 */ category: string /** * standSchemaModel * 标准产品功能集定义模型 */ standSchemaModel?: {} /** * productId * 设备对应的产品 id */ productId: string /** * bizAttribute * 业务属性能力 */ bizAttribute: number /** * meshId * 当前设备对应的蓝牙 mesh id */ meshId: string /** * 【废弃】sigmeshId * 当前设备所属行业属性对应的蓝牙 mesh id */ sigmeshId: string /** * meta * 设备自定义配置元属性,用于存放业务数据 */ meta: Record<string, {}> /** * isLocalOnline * 本地局域网是否在线 */ isLocalOnline: boolean /** 设备云端在线情况 */ isCloudOnline: boolean /** * isOnline * 设备总的在线情况,只要一个情况在线,就是在线,复合在线情况 */ isOnline: boolean /** * name * 设备名称 */ name: string /** groupId */ groupId: string /** * dpCodes * 标准功能集 code */ dpCodes: Record<string, {}> /** 时区信息 */ devTimezoneId: string /** 设备的功能点执行的时间 */ dpsTime: Record<string, {}> /** 设备纬度 */ latitude: string /** 设备经度 */ longitude: string /** 设备ip地址 */ ip?: string /** 是否为虚拟设备 */ isVirtualDevice: boolean /** zigbeeInstallCode to the cloud to mark the gateway with installation code ability */ isZigbeeInstallCode: boolean /** Activate sub-device capability flag. */ protocolAttribute: number /** 连接状态,nearby状态 */ connectionStatus: number /** 部分设备需要用mac进行唯一识别 ,比如mesh */ mac?: string /** 蓝牙的设备能力值,由设备进行上报 */ bluetoothCapability?: string /** 是否三方matter设备 */ isTripartiteMatter: boolean /** 是否网关设备 */ isGW: boolean /** 是否支持群组 */ isSupportGroup: boolean /** 是否zigbee子设备 */ isZigBeeSubDev: boolean /** cadv版本号 */ cadv?: string /** 设备是否支持OTA */ isSupportOTA: boolean /** 设备图标 */ iconUrl: string /** 设备是否有Wi-Fi模块 */ hasWifi: boolean /** 快捷控制dp */ switchDp: number /** 快捷控制dp */ switchDps: number[] /** 设备Wi-Fi模块的状态:1:不可用 2:可用 */ wifiEnableState: number /** 设备产品配置 */ configMetas: Record<string, {}> /** 是否为matter设备 */ isMatter: boolean /** 设备是否支持双控 */ isSupportLink: boolean /** 是否支持将设备添加到苹果家庭中 */ isSupportAppleHomeKit?: boolean /** * attribute 格式化的二进制字符串 * 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理 */ attributeString: string }) => void fail?: (params: { errorMsg: string errorCode: string | number innerError: { errorCode: string | number errorMsg: string } }) => void }): void
图片重新上传了,我看过原函数,使用success是可以获取数据的,但开发文档里用的是.then方法,虽然编译器会报错,但实际是有数据打印出来,所以有了疑问,为什么void函数能通过.then方法返回数据,而且在代码里可知,这里是返回一个void函数,但是实际在小程序开发者工具里是打印出来却是一个promise。
好的,谢谢。