# @capgo/capacitor-bluetooth-low-energy 中文文档

规范地址：https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/

版本：8\.2\.7
npm 元数据更新时间：2026-10-15T01:59:41.771Z
中文译文更新时间：2026-11-09T03:37:24.430Z
软件包许可：MPL-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40capgo/capacitor-bluetooth-low-energy
原文对照：https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/?lang=original
项目主页：https://capgo.app/docs/plugins/bluetooth-low-energy/
源码仓库：https://github.com/Cap-go/capacitor-bluetooth-low-energy

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：709 kB，28 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：@capacitor/core \>=8\.0\.0
- 首次发布：2025-12-16T02:49:28.953Z
- 最新版本发布：2026-10-15T01:59:41.431Z
- 近 30 天下载量：45611（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：32（近 12 个月 32 个）

## 中文简介

蓝牙低能 (BLE) Capacitor 插件,支持扫描,连接,阅读,写作和通知.

## 安装

```sh
npm install @capgo/capacitor-bluetooth-low-energy
```

也可以使用：`pnpm add @capgo/capacitor-bluetooth-low-energy`、`yarn add @capgo/capacitor-bluetooth-low-energy`、`bun add @capgo/capacitor-bluetooth-low-energy`

## README

# @capgo/电容-蓝牙-低能

从 Capacitor app 中与 Bluetooth 低能设备交谈:扫描,连接,读取和写入特性,并订阅iOS,Android和网络上的通知. 在iOS和Android上也可以作为外围广告.

[![Capgo - Build Capacitor apps with AI, ship updates instantly](https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-bluetooth-low-energy)](https://capgo.app/?ref=plugin_bluetooth_low_energy)

**队长**:在几分钟内将修正推给您的 Capacitor 用户,在没有Mac的情况下构建已签名的iOS和Android apps,并在一击中回滚.

## [\*免费开始\*](https://capgo.app/register/?ref=plugin_bluetooth_low_energy)

14天无限自由审判. 不需要信用卡

> 🤖 **建筑与AI编码代理?** 安装 [Capgo 技能](https://capgo.app/skills/?ref=plugin_bluetooth_low_energy) 所以克劳德代码,代码,光标,副驾驶,或双子座CLI知道如何安装和使用 `@capgo/capacitor-bluetooth-low-energy` 在您的电容应用程序中: `npx skills add Cap-go/capgo-skills`。然后问你的经纪人: _添加@capgo/电容-蓝牙-低能_ [代理设置指南](https://capgo.app/agents/?ref=plugin_bluetooth_low_energy) • 妇女 [主机磁共振](https://capgo.app/docs/ai/mcp/?ref=plugin_bluetooth_low_energy)

![@capgo/capacitor-bluetooth-low-energy for Capacitor apps](https://raw.githubusercontent.com/Cap-go/capacitor-bluetooth-low-energy/main/assets/github-social-preview.png)

## 主要特点

-   **扫描**数字 : `startScan()` 财务报告和审定财务报表 `stopScan()` 带有 `deviceScanned` 活动.
-   **连接**数字 : `connect()`, (中文(简体) ), `disconnect()`, (中文(简体) ), `getConnectedDevices()` 财务报告和审定财务报表 `deviceConnected` 或者说 `deviceDisconnected` 事件.
-   **关贸总协定准入**数字 : `discoverServices()`, (中文(简体) ), `getServices()`, (中文(简体) ), `readCharacteristic()` 财务报告和审定财务报表 `writeCharacteristic()`。 。 。 .
-   **通知**数字 : `startCharacteristicNotifications()` 与 `characteristicChanged` 活动.
-   **周边模式**数字 : `startAdvertising()` 将设备转换为 BLE 服务器,包含读写请求事件. 在网上不可用.
-   **设置助手**数字 : `isAvailable()`, (中文(简体) ), `isEnabled()`,权限,以及Android连接和设置快捷键.
-   **平台**:iOS,Android和Web. iOS使用Core Bluetooth,Android使用Bluetooth LE APIs,Web使用浏览器支持它的Web Bluetooth.

## 为什么是蓝牙公司低能?

综合的, **免费**,以及 **强力** BLE 插件 :

-   **全面支助** - 扫描、连接、阅读、写作和接收通知
-   **周边模式** - 作为BLE服务器和广告服务(Android/iOS)
-   **服务发现** - 自动发现服务、特征和说明
-   **背景支持** - Android的展望服务,iOS的背景模式
-   **权限处理** - Android 12+和iOS的内置许可管理
-   **现代软件包管理** - 支持Swift软件包管理器(SPM)和CocoaPods
-   **跨平台** - 在iOS、Android和Web(Chrome Web Bluetooth API)上工作
-   **网络蓝牙 shim** - 让浏览器风格的 BLE 代码继续使用 `navigator.bluetooth` 在本地 Capacitor 应用程序内, 使用一个手动调用

适合IOT应用,可穿戴,健康设备,智能家庭,以及任何BLE连接的外围设备.

## 文档

这里有最完整的医生: [https://capgo.app/docs/plugins/蓝牙-低能/](https://capgo.app/docs/plugins/bluetooth-low-energy/)

## 兼容性

| 插件版本 | 电容兼容性 | 维护 |
| --- | --- | --- |
| 联合国 | 联合国 | ✅ |
| 页:1 | 页:1 | 应要求 |
| 页:1 | 页:1 | ❌ |
| 页:1 | 页:1 | ❌ |

> **说明:** 此插件的主要版本沿用了Capacitor的主要版本. 使用匹配您的 Capacitor 安装的版本( 如 Capacitor 8 的插件 v8) 。 只有最新的主要版本得到积极维护.

## 安装

您可以使用我们的 AI 辅助设置安装插件 。 使用以下命令将 Capgo 技能添加到您的 AI 工具 :

```bash
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
```

然后使用下列提示:

```text
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-bluetooth-low-energy` plugin in my project.
```

如果您更喜欢手动设置,请通过运行以下命令来安装插件,并遵循下面的平台特定指令:

```bash
npm install @capgo/capacitor-bluetooth-low-energy
npx cap sync
```

## iOS系统

在您的 `Info.plist`数字 :

```xml
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to communicate with BLE devices.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth to communicate with BLE devices.</string>
```

对于背景的 BLE 支持,请在您的 `Info.plist`数字 :

```xml
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>
```

## 机器人

工作在盒子内。 插件会自动添加您所需的权限 `AndroidManifest.xml`。对于Android 12+,您可能需要在使用 BLE 特性之前请求运行时间权限:

```typescript
await BluetoothLowEnergy.requestPermissions();
```

## 网页

使用Web Bluetooth API在Chrome和Chromium的浏览器中工作. 注意Web Bluetooth需要HTTPS和用户交互扫描设备.

## 网络蓝牙 shim

在Capacitor本地语境中,呼叫 `BluetoothLowEnergy.shimWebBluetooth()` 在使用前 `navigator.bluetooth`安装 JS shim , 这样应用程序代码就可以继续使用Web Bluetooth API, 而电话被传送到本地的 BLE 执行中.

```typescript
BluetoothLowEnergy.shimWebBluetooth();

const device = await navigator.bluetooth.requestDevice({
  acceptAllDevices: true,
});

const server = await device.gatt.connect();
const service = await server.getPrimaryService('180d');
```

Shim住在插件 JS 捆绑中,自动初始化了中央模式的插件,并将关贸总协定通过Capacitor桥来读取,写出,描述和通知.

当前本地限制 : `requestDevice()` 解决第一个匹配的扫描设备,而不是打开浏览器选择器 UI。 如果您需要自定义拾取器或外围模式流,请继续使用直接插件 API.

## API 密码

-   [`initialize(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-initialize)
-   [`shimWebBluetooth()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-shimwebbluetooth)
-   [`isAvailable()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isavailable)
-   [`isEnabled()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isenabled)
-   [`isLocationEnabled()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-islocationenabled)
-   [`openAppSettings()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-openappsettings)
-   [`openBluetoothSettings()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-openbluetoothsettings)
-   [`openLocationSettings()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-openlocationsettings)
-   [`checkPermissions()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-checkpermissions)
-   [`requestPermissions()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestpermissions)
-   [`startScan(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startscan)
-   [`stopScan()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-stopscan)
-   [`connect(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-connect)
-   [`disconnect(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-disconnect)
-   [`createBond(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-createbond)
-   [`isBonded(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isbonded)
-   [`discoverServices(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-discoverservices)
-   [`getServices(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getservices)
-   [`getConnectedDevices()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getconnecteddevices)
-   [`readCharacteristic(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readcharacteristic)
-   [`writeCharacteristic(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-writecharacteristic)
-   [`startCharacteristicNotifications(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startcharacteristicnotifications)
-   [`stopCharacteristicNotifications(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-stopcharacteristicnotifications)
-   [`readDescriptor(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readdescriptor)
-   [`writeDescriptor(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-writedescriptor)
-   [`readRssi(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readrssi)
-   [`requestMtu(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestmtu)
-   [`requestConnectionPriority(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestconnectionpriority)
-   [`startAdvertising(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startadvertising)
-   [`stopAdvertising()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-stopadvertising)
-   [`addGattService(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addgattservice)
-   [`removeGattService(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-removegattservice)
-   [`setGattCharacteristicValue(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-setgattcharacteristicvalue)
-   [`notifyGattCharacteristicChanged(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-notifygattcharacteristicchanged)
-   [`startForegroundService(...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startforegroundservice)
-   [`stopForegroundService()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-stopforegroundservice)
-   [`getPluginVersion()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getpluginversion)
-   [`addListener('deviceScanned', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenerdevicescanned-)
-   [`addListener('deviceConnected', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenerdeviceconnected-)
-   [`addListener('deviceDisconnected', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenerdevicedisconnected-)
-   [`addListener('characteristicChanged', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenercharacteristicchanged-)
-   [`addListener('centralConnected', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenercentralconnected-)
-   [`addListener('centralDisconnected', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenercentraldisconnected-)
-   [`addListener('gattCharacteristicReadRequest', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenergattcharacteristicreadrequest-)
-   [`addListener('gattCharacteristicWriteRequest', ...)`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addlistenergattcharacteristicwriterequest-)
-   [`removeAllListeners()`](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-removealllisteners)
-   [接口](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-interfaces)
-   [类型异名](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-type-aliases)

蓝牙低能插件用于BLE通信.

### 初始化(...)

```typescript
initialize(options?: InitializeOptions | undefined) => Promise<void>
```

初始化 BLE 插件 . 一定要在任何其他方法之前叫出来.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[InitializeOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-initializeoptions)` | \- 初始化选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### shimWeb 蓝牙 ()

```typescript
shimWebBluetooth() => void
```

安装 Capacitor 网络蓝牙 shim `navigator.bluetooth`。 。 。 . 在使用来自 Capacitor 本地应用程序的Web Bluetooth API之前,手动调用此功能 .

**自:** 1.0.0 (单位:千美元)

* * *

### 易读 ()

```typescript
isAvailable() => Promise<IsAvailableResult>
```

检查设备是否有蓝牙可用 .

**回返情况:** `Promise<[IsAvailableResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isavailableresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 已启用

```typescript
isEnabled() => Promise<IsEnabledResult>
```

检查设备是否启用了蓝牙 .

**回返情况:** `Promise<[IsEnabledResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isenabledresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### isLocation 启用( )

```typescript
isLocationEnabled() => Promise<IsLocationEnabledResult>
```

检查位置服务是否启用( 只有Android) .

**回返情况:** `Promise<[IsLocationEnabledResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-islocationenabledresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 打开 AppSettings ()

```typescript
openAppSettings() => Promise<void>
```

打开应用程序设置页面 .

**自:** 1.0.0 (单位:千美元)

* * *

### 打开蓝牙设置( C)

```typescript
openBluetoothSettings() => Promise<void>
```

打开蓝牙设置页面(只有Android).

**自:** 1.0.0 (单位:千美元)

* * *

### 开放位置设置( C)

```typescript
openLocationSettings() => Promise<void>
```

打开位置设置页面( 只有Android) .

**自:** 1.0.0 (单位:千美元)

* * *

### 检查( )

```typescript
checkPermissions() => Promise<PermissionStatus>
```

检查当前权限状态 .

**回返情况:** `Promise<[PermissionStatus](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-permissionstatus)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 请求( )

```typescript
requestPermissions() => Promise<PermissionStatus>
```

请求蓝牙权限 .

**回返情况:** `Promise<[PermissionStatus](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-permissionstatus)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 启动扫描(...)

```typescript
startScan(options?: StartScanOptions | undefined) => Promise<void>
```

开始扫描BLE设备 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[StartScanOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startscanoptions)` | \- 扫描选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 停止扫描( C)

```typescript
stopScan() => Promise<void>
```

停止扫描 BLE 设备 .

**自:** 1.0.0 (单位:千美元)

* * *

### 连接(...)

```typescript
connect(options: ConnectOptions) => Promise<void>
```

连接到 BLE 设备 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[ConnectOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-connectoptions)` | \- 连接选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 断开(...)

```typescript
disconnect(options: DisconnectOptions) => Promise<void>
```

与 BLE 设备断开连接 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[DisconnectOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-disconnectoptions)` | \- 断开选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 创建Bond(...)

```typescript
createBond(options: CreateBondOptions) => Promise<void>
```

与 BLE 设备创建连接( 只有Android) .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[CreateBondOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-createbondoptions)` | \- 债券选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 为 Bonded (...)

```typescript
isBonded(options: IsBondedOptions) => Promise<IsBondedResult>
```

请检查date=中的日期值 (帮助) Android.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[IsBondedOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isbondedoptions)` | \- 债券检查选项 |

**回返情况:** `Promise<[IsBondedResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-isbondedresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 发现服务(...)

```typescript
discoverServices(options: DiscoverServicesOptions) => Promise<void>
```

在连接的设备上发现服务 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[DiscoverServicesOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-discoverservicesoptions)` | \- 发现选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 获取服务(...)

```typescript
getServices(options: GetServicesOptions) => Promise<GetServicesResult>
```

获取设备的发现服务 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[GetServicesOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getservicesoptions)` | \- 获得服务选项 |

**回返情况:** `Promise<[GetServicesResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getservicesresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 获取连接设备( )

```typescript
getConnectedDevices() => Promise<GetConnectedDevicesResult>
```

获取连接设备列表 .

**回返情况:** `Promise<[GetConnectedDevicesResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getconnecteddevicesresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 读取变异性(...)

```typescript
readCharacteristic(options: ReadCharacteristicOptions) => Promise<ReadCharacteristicResult>
```

读取特性值.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[ReadCharacteristicOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readcharacteristicoptions)` | \- 读取选项 |

**回返情况:** `Promise<[ReadCharacteristicResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readcharacteristicresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 写入特征(...)

```typescript
writeCharacteristic(options: WriteCharacteristicOptions) => Promise<void>
```

写一个值到一个特性.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[WriteCharacteristicOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-writecharacteristicoptions)` | \- 写选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 切换性通知(...)

```typescript
startCharacteristicNotifications(options: StartCharacteristicNotificationsOptions) => Promise<void>
```

启动特性通知 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[StartCharacteristicNotificationsOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startcharacteristicnotificationsoptions)` | \- 通知选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 通知(...)

```typescript
stopCharacteristicNotifications(options: StopCharacteristicNotificationsOptions) => Promise<void>
```

停止一个特征的通知 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[StopCharacteristicNotificationsOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-stopcharacteristicnotificationsoptions)` | \- 停止通知选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 已读描述器(...)

```typescript
readDescriptor(options: ReadDescriptorOptions) => Promise<ReadDescriptorResult>
```

读取描述值 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[ReadDescriptorOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readdescriptoroptions)` | \- 阅读描述选项 |

**回返情况:** `Promise<[ReadDescriptorResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readdescriptorresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 写入描述符(...)

```typescript
writeDescriptor(options: WriteDescriptorOptions) => Promise<void>
```

写一个值给描述符 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[WriteDescriptorOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-writedescriptoroptions)` | \- 撰写描述文件选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 读取 Rssi (...)

```typescript
readRssi(options: ReadRssiOptions) => Promise<ReadRssiResult>
```

读取连接设备的RSSI(信号强度).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[ReadRssiOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readrssioptions)` | \- 阅读 RSSI 选项 |

**回返情况:** `Promise<[ReadRssiResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-readrssiresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 请求Mtu (...)

```typescript
requestMtu(options: RequestMtuOptions) => Promise<RequestMtuResult>
```

请求更改 MTU 大小( 只有Android) .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[RequestMtuOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestmtuoptions)` | \- 请求 MTU 选项 |

**回返情况:** `Promise<[RequestMtuResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestmturesult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 请求优先级(...)

```typescript
requestConnectionPriority(options: RequestConnectionPriorityOptions) => Promise<void>
```

请求连接优先级(只有Android).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[RequestConnectionPriorityOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-requestconnectionpriorityoptions)` | \- 请求优先选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 开始广告(...)

```typescript
startAdvertising(options: StartAdvertisingOptions) => Promise<void>
```

开始广告作为外围(BLE服务器).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[StartAdvertisingOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startadvertisingoptions)` | \- 广告选择 |

**自:** 1.0.0 (单位:千美元)

* * *

### 停止广告 ()

```typescript
stopAdvertising() => Promise<void>
```

停止广告.

**自:** 1.0.0 (单位:千美元)

* * *

### 添加 Gatt 服务(...)

```typescript
addGattService(options: AddGattServiceOptions) => Promise<void>
```

在本地的关贸总协定服务器上添加具有特性的关贸总协定服务. 在开始广告前, 必须在外围模式下呼叫 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[AddGattServiceOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-addgattserviceoptions)` | \- 《关贸总协定》服务定义 |

**自:** 8.2.0 (中文(简体) )

* * *

### 删除 GattService (...)

```typescript
removeGattService(options: RemoveGattServiceOptions) => Promise<void>
```

从本地关贸总协定服务器中删除关贸总协定服务.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[RemoveGattServiceOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-removegattserviceoptions)` | \- 服务删除选项 |

**自:** 8.2.0 (中文(简体) )

* * *

### 设置GattCharacteristic Vale (...)

```typescript
setGattCharacteristicValue(options: SetGattCharacteristicValueOptions) => Promise<void>
```

设定本地关贸总协定特征的值.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[SetGattCharacteristicValueOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-setgattcharacteristicvalueoptions)` | \- 特征值选项 |

**自:** 8.2.0 (中文(简体) )

* * *

### 通知 Gatt 变换(...)

```typescript
notifyGattCharacteristicChanged(options: NotifyGattCharacteristicChangedOptions) => Promise<void>
```

通知连接的中心,关贸总协定的当地特征价值发生了变化.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[NotifyGattCharacteristicChangedOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-notifygattcharacteristicchangedoptions)` | \- 通知选项 |

**自:** 8.2.0 (中文(简体) )

* * *

### 启动前景服务(...)

```typescript
startForegroundService(options: StartForegroundServiceOptions) => Promise<void>
```

启动一个前景服务,以维护背景中的 BLE 连接(仅Android).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[StartForegroundServiceOptions](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-startforegroundserviceoptions)` | \- 前景服务选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 站点前端服务( C)

```typescript
stopForegroundService() => Promise<void>
```

停止前景服务(仅限Android).

**自:** 1.0.0 (单位:千美元)

* * *

### 获取 PluginVersion ()

```typescript
getPluginVersion() => Promise<GetPluginVersionResult>
```

获取本地 Capacitor 插件版本 .

**回返情况:** `Promise<[GetPluginVersionResult](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-getpluginversionresult)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 添加倾听器( “ 扫描” )..

```typescript
addListener(eventName: 'deviceScanned', listenerFunc: (event: DeviceScannedEvent) => void) => Promise<PluginListenerHandle>
```

为设备扫描事件添加一个听众 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'deviceScanned'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [DeviceScannedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-devicescannedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 添加倾听器( “ 已连接 ” )..

```typescript
addListener(eventName: 'deviceConnected', listenerFunc: (event: DeviceConnectedEvent) => void) => Promise<PluginListenerHandle>
```

为设备连接的事件添加一个收听器 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'deviceConnected'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [DeviceConnectedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-deviceconnectedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 添加倾听器( “ 已断开 ” )..

```typescript
addListener(eventName: 'deviceDisconnected', listenerFunc: (event: DeviceDisconnectedEvent) => void) => Promise<PluginListenerHandle>
```

添加设备断开事件的收听器 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'deviceDisconnected'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [DeviceDisconnectedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-devicedisconnectedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 添加倾听器( “ 特征变化 ” ,...)

```typescript
addListener(eventName: 'characteristicChanged', listenerFunc: (event: CharacteristicChangedEvent) => void) => Promise<PluginListenerHandle>
```

为特性变化的事件添加一个收听器 .

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'characteristicChanged'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [CharacteristicChangedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-characteristicchangedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 1.0.0 (单位:千美元)

* * *

### 添加倾听器( “ 中央连接” ,...)

```typescript
addListener(eventName: 'centralConnected', listenerFunc: (event: CentralConnectedEvent) => void) => Promise<PluginListenerHandle>
```

为中央连接的事件(周边模式)添加一个收听器.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'centralConnected'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [CentralConnectedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-centralconnectedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 8.2.0 (中文(简体) )

* * *

### 添加倾听器( “ 中央断开连接 ” ,...)

```typescript
addListener(eventName: 'centralDisconnected', listenerFunc: (event: CentralDisconnectedEvent) => void) => Promise<PluginListenerHandle>
```

为中央断开的事件添加一个收听器(周边模式).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'centralDisconnected'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [CentralDisconnectedEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-centraldisconnectedevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 8.2.0 (中文(简体) )

* * *

### 添加倾听器( “ gartCharacteristic Read request ” ,...)

```typescript
addListener(eventName: 'gattCharacteristicReadRequest', listenerFunc: (event: GattCharacteristicReadRequestEvent) => void) => Promise<PluginListenerHandle>
```

增加关贸总协定特征的收听器为请求(周边模式).

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'gattCharacteristicReadRequest'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [GattCharacteristicReadRequestEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-gattcharacteristicreadrequestevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 8.2.0 (中文(简体) )

* * *

### 添加倾听器( “ gattCharacteristic Write request ” ,...)

```typescript
addListener(eventName: 'gattCharacteristicWriteRequest', listenerFunc: (event: GattCharacteristicWriteRequestEvent) => void) => Promise<PluginListenerHandle>
```

为 GATT 特性写请求(周边模式)添加一个收听器.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`eventName`** | `'gattCharacteristicWriteRequest'` | \- 活动名称 |
| **`listenerFunc`** | `(event: [GattCharacteristicWriteRequestEvent](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-gattcharacteristicwriterequestevent)) => void` | \- 听众的功能 |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-pluginlistenerhandle)>`

**自:** 8.2.0 (中文(简体) )

* * *

### 删除所有收听器( )

```typescript
removeAllListeners() => Promise<void>
```

删除此插件的所有听众 .

**自:** 1.0.0 (单位:千美元)

* * *

### 接口

#### 初始化选项

插件的初始化选项 .

| Prop | 类型 | 说明 | 默认 | 自兹 |
| --- | --- | --- | --- | --- |
| **`mode`** | `'central' | 'peripheral'` | 插件初始化的模式 。 -"中央":作为BLE中心(客户)——"周边": 充当BLE外围(服务器) | `'central'` | 1.0.0 (单位:千美元) |
| **`showPowerAlert`** | `boolean` | IOS是否应该在蓝牙关机时显示系统蓝牙功率警报(仅iOS). | `true` | 8.0.7 联合国 |

#### 易伤性结果

由可操作方法产生.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`available`** | `boolean` | 设备是否有蓝牙可用 . | 1.0.0 (单位:千美元) |

#### 已启用结果

可用方法的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`enabled`** | `boolean` | 设备是否启用了蓝牙 . | 1.0.0 (单位:千美元) |

#### 启用结果

异能方法的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`enabled`** | `boolean` | 设备是否启用位置服务 . | 1.0.0 (单位:千美元) |

#### 权限状态

蓝牙和位置的授权状态 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`bluetooth`** | `[PermissionState](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-permissionstate)` | 蓝牙许可状态 . | 1.0.0 (单位:千美元) |
| **`location`** | `[PermissionState](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-permissionstate)` | 位置许可状态(仅限Android). | 1.0.0 (单位:千美元) |

#### 开始扫描选项

开始扫描的选项 .

| Prop | 类型 | 说明 | 默认 | 自兹 |
| --- | --- | --- | --- | --- |
| **`services`** | `string[]` | 要过滤的服务 UUID 列表 。 只有宣传这些服务的设备才会被退回. |  | 1.0.0 (单位:千美元) |
| **`timeout`** | `number` | 扫描超时( 毫秒) 。 设定为 0 不超时 . | `0` | 1.0.0 (单位:千美元) |
| **`allowDuplicates`** | `boolean` | 是否允许重复扫描结果 . | `false` | 1.0.0 (单位:千美元) |

#### 连接选项

连接设备的选项 .

| Prop | 类型 | 说明 | 默认 | 自兹 |
| --- | --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID(Android上的MAC地址,iOS上的UUID). |  | 1.0.0 (单位:千美元) |
| **`autoConnect`** | `boolean` | 设备可用时是否自动连接 . | `false` | 1.0.0 (单位:千美元) |

#### 断开选项

从设备中断开的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 要断开的设备 ID . | 1.0.0 (单位:千美元) |

#### 创建 Bond 选项

创建债券的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID与连接. | 1.0.0 (单位:千美元) |

#### 是Bonded结果

结果是 Bonded 方法.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`bonded`** | `boolean` | 设备是否捆绑 . | 1.0.0 (单位:千美元) |

#### 是Bonded选项

检查债券状态的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 要检查的设备ID. | 1.0.0 (单位:千美元) |

#### 发现服务选项

发现服务的选项.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 用于发现服务的设备ID . | 1.0.0 (单位:千美元) |

#### 获取服务

获取服务方法的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`services`** | `BleService[]` | 已发现服务列表. | 1.0.0 (单位:千美元) |

#### 服务

一个BLE服务.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`uuid`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristics`** | `BleCharacteristic[]` | 本服务中的特点列表. | 1.0.0 (单位:千美元) |

#### 分解主义

一个BLE特征.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`uuid`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |
| **`properties`** | `[CharacteristicProperties](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-characteristicproperties)` | 此特性之属性. | 1.0.0 (单位:千美元) |
| **`descriptors`** | `BleDescriptor[]` | 这一特征的描述词列表. | 1.0.0 (单位:千美元) |

#### 特征

BLE特性的属性.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`broadcast`** | `boolean` | 特性是否支持广播. | 1.0.0 (单位:千美元) |
| **`read`** | `boolean` | 特性是否支持读取 . | 1.0.0 (单位:千美元) |
| **`writeWithoutResponse`** | `boolean` | 特性是否支持不回复的写入 . | 1.0.0 (单位:千美元) |
| **`write`** | `boolean` | 特性是否支持写入 . | 1.0.0 (单位:千美元) |
| **`notify`** | `boolean` | 特性是否支持通知 . | 1.0.0 (单位:千美元) |
| **`indicate`** | `boolean` | 特性支持是否表示 . | 1.0.0 (单位:千美元) |
| **`authenticatedSignedWrites`** | `boolean` | 特性是否支持经认证的签名写作 . | 1.0.0 (单位:千美元) |
| **`extendedProperties`** | `boolean` | 特性是否扩展了属性 . | 1.0.0 (单位:千美元) |

#### 描述符

BLE描述器.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`uuid`** | `string` | 描述符 UUID. | 1.0.0 (单位:千美元) |

#### 获取服务选项

获得服务的选项.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 获取服务的设备ID . | 1.0.0 (单位:千美元) |

#### 获取连接Devices 结果

获得ConnectedDevices方法的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`devices`** | `BleDevice[]` | 连接设备列表 . | 1.0.0 (单位:千美元) |

#### 布莱德维采

一个BLE设备.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID(Android上的MAC地址,iOS上的UUID). | 1.0.0 (单位:千美元) |
| **`name`** | `string | null` | 设备名称( 如不可用, 可能无效 ) . | 1.0.0 (单位:千美元) |
| **`rssi`** | `number` | 发现时的RSSI(信号强度). | 1.0.0 (单位:千美元) |
| **`manufacturerData`** | `string` | 由广告获得的制造商数据(以十六进制字符串表示). | 1.0.0 (单位:千美元) |
| **`serviceUuids`** | `string[]` | 设备所广告的服务UUID. | 1.0.0 (单位:千美元) |

#### 读取特征结果

阅读一个特征的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`value`** | `number[]` | 作为字节数组的特征值. | 1.0.0 (单位:千美元) |

#### 读取特性选项

读取特性的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |

#### 写入特性选项

写入特性的选项 .

| Prop | 类型 | 说明 | 默认 | 自兹 |
| --- | --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. |  | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. |  | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. |  | 1.0.0 (单位:千美元) |
| **`value`** | `number[]` | 作为字节数组写入的值 . |  | 1.0.0 (单位:千美元) |
| **`type`** | `'withResponse' | 'withoutResponse'` | 写作类型. | `'withResponse'` | 1.0.0 (单位:千美元) |

#### 选择

启动特征通知的备选方案.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |

#### 选择

停止特征通知的选项.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |

#### 阅读描述器结果

读出一个描述符的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`value`** | `number[]` | 描述值为字节数组. | 1.0.0 (单位:千美元) |

#### 阅读描述符选项

读取描述符的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |
| **`descriptor`** | `string` | 描述符 UUID. | 1.0.0 (单位:千美元) |

#### 书面描述选项

写入描述符的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |
| **`descriptor`** | `string` | 描述符 UUID. | 1.0.0 (单位:千美元) |
| **`value`** | `number[]` | 作为字节数组写入的值 . | 1.0.0 (单位:千美元) |

#### 读取Rssi结果

阅读RSSI的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`rssi`** | `number` | RSSI 值以 dBm 为单位. | 1.0.0 (单位:千美元) |

#### 读取 Rssi 选项

阅读 RSSI 的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |

#### 请求Mtu结果

请求MTU的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`mtu`** | `number` | 商谈的MTU尺寸. | 1.0.0 (单位:千美元) |

#### 请求Mtu 选项

请求 MTU 的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`mtu`** | `number` | 请求的 MTU 大小 . | 1.0.0 (单位:千美元) |

#### 请求连接优先选项

请求连接优先级的选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`priority`** | `'low' | 'balanced' | 'high'` | 请求的连接优先级 . | 1.0.0 (单位:千美元) |

#### 开始广告选项

开始广告的选项.

| Prop | 类型 | 说明 | 默认 | 自兹 |
| --- | --- | --- | --- | --- |
| **`name`** | `string` | 广告的装置名称. 在Android上,通过在广告的同时临时设置蓝牙适配器名来实施本地名的广告,然后在停止广告时恢复之前的适配器名. |  | 1.0.0 (单位:千美元) |
| **`services`** | `string[]` | 服务UUUID发布广告. |  | 1.0.0 (单位:千美元) |
| **`includeName`** | `boolean` | 是否在广告中包含设备名称 . | `true` | 1.0.0 (单位:千美元) |
| **`includeTxPowerLevel`** | `boolean` | 是否在广告中包含 TX 功率级别 . | `false` | 1.0.0 (单位:千美元) |

#### 添加 Gatt 服务选项

增加关贸总协定服务的选择.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |
| **`characteristics`** | `GattCharacteristicDefinition[]` | 本服务中要曝光的特征. | 8.2.0 (中文(简体) ) |

#### 定义

当地关贸总协定服务器的关贸总协定特征定义.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`uuid`** | `string` | 特征UUID. | 8.2.0 (中文(简体) ) |
| **`properties`** | `[CharacteristicProperties](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-characteristicproperties)` | 此特性之属性. | 8.2.0 (中文(简体) ) |
| **`value`** | `number[]` | 初始值为字节数组 . | 8.2.0 (中文(简体) ) |
| **`descriptors`** | `GattDescriptorDefinition[]` | 这一特征的可选说明. | 8.2.0 (中文(简体) ) |

#### Gatt 描述定义

关贸总协定对当地关贸总协定服务器的描述定义.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`uuid`** | `string` | 描述符 UUID. | 8.2.0 (中文(简体) ) |
| **`value`** | `number[]` | 初始值为字节数组 . | 8.2.0 (中文(简体) ) |

#### 删除 Gatt 服务选项

取消关贸总协定服务的选择.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |

#### SetGatt 特征变量

设定当地关贸总协定特征值的选项.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |
| **`characteristic`** | `string` | 特征UUID. | 8.2.0 (中文(简体) ) |
| **`value`** | `number[]` | 作为字节数组的值 . | 8.2.0 (中文(简体) ) |

#### 通知 Gatt 变换式

通知连接中心特性变化的选项.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |
| **`characteristic`** | `string` | 特征UUID. | 8.2.0 (中文(简体) ) |
| **`value`** | `number[]` | 作为字节数组的值 . | 8.2.0 (中文(简体) ) |
| **`deviceId`** | `string` | 可选中央设备ID. 省略时,会通知所有订阅的中心. | 8.2.0 (中文(简体) ) |

#### 启动前景服务选项

启动前景服务选项 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`title`** | `string` | 通知标题. | 1.0.0 (单位:千美元) |
| **`body`** | `string` | 通知机构. | 1.0.0 (单位:千美元) |
| **`smallIcon`** | `string` | 通知小图标资源名 . | 1.0.0 (单位:千美元) |

#### 获取 PluginVersion 结果

获取PluginVersion的结果.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`version`** | `string` | 插件版本 . | 1.0.0 (单位:千美元) |

#### 插件听筒

| Prop | 类型 |
| --- | --- |
| **`remove`** | `() => Promise<void>` |

#### 设备扫描事件

设备扫描时发射的事件 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`device`** | `[BleDevice](https://npmcn.com/package/%40capgo/capacitor-bluetooth-low-energy/#readme-bledevice)` | 扫描器. | 1.0.0 (单位:千美元) |

#### 设备连接事件

设备连接时释放的事件 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |

#### 设备断开连接事件

设备断开时发生事件 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |

#### 特性变化后事件

当特性值变化时会释放出事件 .

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 设备ID. | 1.0.0 (单位:千美元) |
| **`service`** | `string` | 服务UUUID. | 1.0.0 (单位:千美元) |
| **`characteristic`** | `string` | 特征UUID. | 1.0.0 (单位:千美元) |
| **`value`** | `number[]` | 作为字节数组的新值 . | 1.0.0 (单位:千美元) |

#### 中央连接事件

当中央连接到当地关贸总协定服务器时,事件会释放出.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 中央设备ID. | 8.2.0 (中文(简体) ) |

#### 中央断开事件

当中央与本地关贸总协定服务器断开时,事件会释放出.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 中央设备ID. | 8.2.0 (中文(简体) ) |

#### 读取请求

当中心读取关贸总协定的当地特征时,即引起事件.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 中央设备ID. | 8.2.0 (中文(简体) ) |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |
| **`characteristic`** | `string` | 特征UUID. | 8.2.0 (中文(简体) ) |

#### GattCharcteristic Write 请求事件

中央写给当地关贸总协定特征时引发的事件.

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`deviceId`** | `string` | 中央设备ID. | 8.2.0 (中文(简体) ) |
| **`service`** | `string` | 服务UUUID. | 8.2.0 (中文(简体) ) |
| **`characteristic`** | `string` | 特征UUID. | 8.2.0 (中文(简体) ) |
| **`value`** | `number[]` | 以字节数组的形式写入值 . | 8.2.0 (中文(简体) ) |

### 类型异名

#### 权限状态

`'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'`

## 常见问题

### @capgo/capacitor-bluetooth-low-energy 是什么？

蓝牙低能 \(BLE\) Capacitor 插件,支持扫描,连接,阅读,写作和通知\.

### 如何安装 @capgo/capacitor-bluetooth-low-energy？

在项目目录运行 npm install @capgo/capacitor-bluetooth-low-energy，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@capacitor/core（\>=8\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @capgo/capacitor-bluetooth-low-energy 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @capgo/capacitor-bluetooth-low-energy 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @capgo/capacitor-bluetooth-low-energy 可以商用吗？

@capgo/capacitor-bluetooth-low-energy 使用 MPL-2\.0 许可。弱 Copyleft：可以商用，也可以和闭源代码一起使用；但如果分发时修改了 MPL 授权的文件，这些文件的修改需以 MPL 开源。以上为概括，不构成法律意见，请以许可原文为准。

### @capgo/capacitor-bluetooth-low-energy 的下载量有多少？

根据 npm 官方下载统计，@capgo/capacitor-bluetooth-low-energy 在 2026/10/09 – 2026/11/07 这 30 天内被下载 45,611 次，日均约 1,520 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @capgo/capacitor-bluetooth-low-energy 还在维护吗？

最新版本 8\.2\.7 发布于 2026/10/15（25 天前）；至今共发布 32 个版本，其中过去 12 个月发布了 32 个；首次发布于 2025/12/16。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

