随笔 - 2649  文章 - 2452  评论 - 0  阅读 - 74060

callDevice(Object req)

callDevice(Object req)

本接口为异步接口,返回 Promise 对象。

需插件 2.4.0 版本开始支持

从手机客户端的小程序呼叫 Linux 设备、RTOS 设备。调用此接口后,会创建 VoIP 房间。开发者应自行向设备端推送通话提醒。详情参考《手机微信呼叫设备(Linux 直连)》

本接口只能在微信客户端内使用,不可在 WMPF 内使用。建议先阅读接口介绍

参数

Object req

属性 类型 默认值 必填 说明 最低版本
roomType string 通话类型。voice: 音频通话;video: 视频通话
sn string 接听方设备 SN
modelId string 接听方设备 modelId
chargeType string 'license' 计费方式。duration: 时长计费;license:license 计费
timeLimit number 最大通话时长,需为 > 0 的数字
enableCallerCamera boolean true 拨打方是否启用摄像头
enableListenerCamera boolean true 接听方是否启用摄像头
nickName string 设备端显示的微信用户名称,仅记录
deviceName string 微信端显示的设备名称 2.4.1
isCloud boolean false 如果是呼叫 RTOS 设备,设置为 true 以触发消息回调
payload string 呼叫 RTOS 时,可以带 payload 到回调消息中
encodeVideoFixedLength number 0 编码的长边值,可取 320、480、640
encodeVideoRotation number 0 编码的视频旋转方向。1: 发出正向流. 2: 保持发出旋转流
encodeVideoRatio number 0 视频的比例, 宽/高*100
encodeVideoMaxFPS number 0 视频的最大 FPS, 8-15

返回值

本接口调用失败会抛出异常

Object

接口调用成功时,返回如下:

属性 类型 说明 最低版本
roomId string 本次通话的房间号

示例代码

const wmpfVoip = requirePlugin('wmpf-voip').default

try {
  const { roomId } = await wmpfVoip.callDevice({
    roomType: 'video',
    sn: '设备 SN',
    modelId: '设备 modelId',
    nickName: '设备端显示的微信用户名称',
  })

  if (/* 当前不在插件页面 */) {
    wx.redirectTo({
      url: wmpfVoip.CALL_PAGE_PATH,
    })
  }
} catch (e) {
  console.error('callDevice failed:', e)
  wx.showToast({
    title: '呼叫失败',
    icon: 'error',
  })
}
posted on   AtlasLapetos  阅读(3)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示