For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/device/bluetooth/makeBluetoothPair.md.

makeBluetoothPair

发起蓝牙配对。

扫码预览

扫码预览 makeBluetoothPair

使用限制

WARNING

iOS:豆包 iOS 的 makeBluetoothPair 固定返回不支持;iOS 上调用无法发起蓝牙配对。

支持版本

前端库版本不低于 0.0.25。

支持平台

平台支持情况
Android支持
iOS不支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

接入准备

权限要求

类型标识是否必须平台说明
系统权限蓝牙权限按条件Android发起配对需要系统蓝牙权限

授权行为

  • Android:依赖已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限

前置条件

  • Android:需先调用 openBluetoothAdapter 打开蓝牙适配器

使用说明

  • 该能力仅在 Android 生效,iOS 调用会返回不支持

调用方式

异步 API

makeBluetoothPair(params: MakeBluetoothPairParams): Promise<object>

入参

名称类型必填默认值约束说明
deviceIdstring是--蓝牙设备 ID。
pinstring是--配对 PIN 码。
timeoutnumber否20000-超时时间,单位毫秒。

调用示例

import { makeBluetoothPair } from '@doubao-dev/framework/api';

await makeBluetoothPair({
  deviceId: 'device-id',
  pin: '000000',
  timeout: 10000
});

成功返回

无返回字段。

返回示例

{}

错误处理

错误对象和通用错误码见 通用错误处理。

错误码

通用错误码

errNoerrMsg说明平台
102internal error内部错误Android
103feature not support当前环境不支持该能力iOS
104invalid parameter参数不合法Android
106system permission denied系统权限未授予Android
114operation cancelled操作已取消Android
115operation timeout操作超时Android
116resource not found资源不存在Android
118already exists资源已存在Android