시작하기
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 명령어를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-bluetooth-low-energy`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/bluetooth-low-energy/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
bun add @capgo/capacitor-bluetooth-low-energybunx cap syncImport
Import 섹션import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';API 개요
API 개요 섹션initialize
__CAPGO_KEEP_0__ 섹션BLE 플러그인을 초기화합니다. 이 메소드는 다른 메소드를 호출하기 전에 반드시 호출해야 합니다.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });shimWebBluetooth
__CAPGO_KEEP_0__ Web Bluetooth shim을 __CAPGO_KEEP_0__에 설치합니다.
__CAPGO_KEEP_1__ 네이티브 앱에서 Web Bluetooth __CAPGO_KEEP_0__을 사용하기 전에 수동으로 호출하세요.Install the Capacitor Web Bluetooth shim on navigator.bluetooth.
Call this manually before using the Web Bluetooth API from a Capacitor native app.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();isAvailable
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();isEnabled
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();isLocationEnabled
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isLocationEnabled();openAppSettings
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.openAppSettings();openBluetoothSettings
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.openBluetoothSettings();openLocationSettings
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.openLocationSettings();checkPermissions
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { bluetooth, location } = await BluetoothLowEnergy.checkPermissions();requestPermissions
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { bluetooth, location } = await BluetoothLowEnergy.requestPermissions();startScan
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.startScan({ services: ['180D'], // Heart Rate Service timeout: 10000});stopScan
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.stopScan();connect
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.connect({ deviceId: 'AA:BB:CC:DD:EE:FF' });disconnect
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.disconnect({ deviceId: 'AA:BB:CC:DD:EE:FF' });createBond
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.createBond({ deviceId: 'AA:BB:CC:DD:EE:FF' });isBonded
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { bonded } = await BluetoothLowEnergy.isBonded({ deviceId: 'AA:BB:CC:DD:EE:FF' });discoverServices
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.discoverServices({ deviceId: 'AA:BB:CC:DD:EE:FF' });getServices
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { services } = await BluetoothLowEnergy.getServices({ deviceId: 'AA:BB:CC:DD:EE:FF' });getConnectedDevices
__CAPGO_KEEP_1__ (연결된 기기 목록)__CAPGO_KEEP_2__ (연결된 기기 목록)
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { devices } = await BluetoothLowEnergy.getConnectedDevices();readCharacteristic
__CAPGO_KEEP_1__ (특성값 읽기)__CAPGO_KEEP_2__ (특성값을 읽습니다.)
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { value } = await BluetoothLowEnergy.readCharacteristic({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A37'});writeCharacteristic
__CAPGO_KEEP_1__ (특성값 쓰기)__CAPGO_KEEP_2__ (특성값을 쓰세요.)
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.writeCharacteristic({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A39', value: [0x01]});startCharacteristicNotifications
__CAPGO_KEEP_1__ (특성값 알림 시작)__CAPGO_KEEP_2__ (특성값 알림을 시작합니다.)
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.startCharacteristicNotifications({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A37'});stopCharacteristicNotifications
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.stopCharacteristicNotifications({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A37'});readDescriptor
__CAPGO_KEEP_3____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { value } = await BluetoothLowEnergy.readDescriptor({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A37', descriptor: '2902'});writeDescriptor
__CAPGO_KEEP_5____CAPGO_KEEP_0__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.writeDescriptor({ deviceId: 'AA:BB:CC:DD:EE:FF', service: '180D', characteristic: '2A37', descriptor: '2902', value: [0x01, 0x00]});readRssi
__CAPGO_KEEP_0____CAPGO_KEEP_7__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { rssi } = await BluetoothLowEnergy.readRssi({ deviceId: 'AA:BB:CC:DD:EE:FF' });requestMtu
MTU 요청 섹션Android에서 MTU 크기 변경 요청.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { mtu } = await BluetoothLowEnergy.requestMtu({ deviceId: 'AA:BB:CC:DD:EE:FF', mtu: 512});requestConnectionPriority
연결 우선순위 요청 섹션Android에서 연결 우선순위 요청.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.requestConnectionPriority({ deviceId: 'AA:BB:CC:DD:EE:FF', priority: 'high'});startAdvertising
블루투스 LE 서버로 광고 시작클립보드 복사
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.startAdvertising({ name: 'MyDevice', services: ['180D']});stopAdvertising
클립보드 복사Stop advertising.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.stopAdvertising();startForegroundService
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.startForegroundService({ title: 'BLE Connection', body: 'Maintaining connection...'});stopForegroundService
__CAPGO_KEEP_3____CAPGO_KEEP_4__
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.stopForegroundService();__CAPGO_KEEP_5__
__CAPGO_KEEP_6__InitializeOptions
__CAPGO_KEEP_7____CAPGO_KEEP_8__
export interface InitializeOptions { /** * The mode to initialize the plugin in. * - 'central': Act as a BLE central (client) * - 'peripheral': Act as a BLE peripheral (server) * * @default 'central' * @since 1.0.0 */ mode?: 'central' | 'peripheral';}IsAvailableResult
__CAPGO_KEEP_0____CAPGO_KEEP_1__
export interface IsAvailableResult { /** * Whether Bluetooth is available on the device. * * @since 1.0.0 */ available: boolean;}IsEnabledResult
__CAPGO_KEEP_0____CAPGO_KEEP_1__
export interface IsEnabledResult { /** * Whether Bluetooth is enabled on the device. * * @since 1.0.0 */ enabled: boolean;}IsLocationEnabledResult
__CAPGO_KEEP_0____CAPGO_KEEP_1__
export interface IsLocationEnabledResult { /** * Whether location services are enabled on the device. * * @since 1.0.0 */ enabled: boolean;}PermissionStatus
__CAPGO_KEEP_0____CAPGO_KEEP_1__
export interface PermissionStatus { /** * Bluetooth permission status. * * @since 1.0.0 */ bluetooth: PermissionState;
/** * Location permission status (Android only). * * @since 1.0.0 */ location: PermissionState;}StartScanOptions
StartScanOptions 섹션스캔 시작을 위한 옵션.
export interface StartScanOptions { /** * List of service UUIDs to filter by. * Only devices advertising these services will be returned. * * @since 1.0.0 */ services?: string[];
/** * Scan timeout in milliseconds. * Set to 0 for no timeout. * * @default 0 * @since 1.0.0 */ timeout?: number;
/** * Whether to allow duplicate scan results. * * @default false * @since 1.0.0 */ allowDuplicates?: boolean;}ConnectOptions
ConnectOptions 섹션장치에 연결을 위한 옵션.
export interface ConnectOptions { /** * The device ID (MAC address on Android, UUID on iOS). * * @since 1.0.0 */ deviceId: string;
/** * Whether to automatically connect when the device becomes available. * * @default false * @since 1.0.0 */ autoConnect?: boolean;}DisconnectOptions
DisconnectOptions 섹션장치에서 연결을 끊는 옵션.
export interface DisconnectOptions { /** * The device ID to disconnect from. * * @since 1.0.0 */ deviceId: string;}CreateBondOptions
CreateBondOptions 섹션장치와의 결합을 위한 옵션.
export interface CreateBondOptions { /** * The device ID to bond with. * * @since 1.0.0 */ deviceId: string;}IsBondedOptions
IsBondedOptions결제 상태 확인 옵션
export interface IsBondedOptions { /** * The device ID to check. * * @since 1.0.0 */ deviceId: string;}IsBondedResult
IsBondedResult결제 상태 확인 결과
export interface IsBondedResult { /** * Whether the device is bonded. * * @since 1.0.0 */ bonded: boolean;}DiscoverServicesOptions
DiscoverServicesOptions서비스 검색 옵션
export interface DiscoverServicesOptions { /** * The device ID to discover services on. * * @since 1.0.0 */ deviceId: string;}실질적 진실
Source Of Truth이 페이지는 플러그인의 데이터에서 생성되었습니다. src/definitions.ts. Re-run the sync when the public API changes upstream.
Getting Started로 계속하기
Getting Started로 계속하기란?Capgo를 사용하고 계신가요? Getting Started Capgo를 사용하여 대시보드와 API를 계획하고 관리하려면 Capacitor를 사용하여 @capgo/capacitor-bluetooth-low-energy Capacitor를 사용하여 @capgo/capacitor-bluetooth-low-energy의 네이티브 기능 API 개요 API 개요의 구현 세부 정보 소개 소개의 구현 세부 정보 API 키 implementation 세부 정보에 대한 API 키 장치 implementation 세부 정보에 대한 장치.