全機能のBLEプラグイン - スキャン、接続、読み取り、書き込み、Bluetoothデバイスから通知を受信 -リアルタイムで更新を管理
プラグインに戻る
@capgo/capacitor-bluetooth-low-energy
チュートリアル
@capgo/capacitor-bluetooth-low-energy

Bluetooth Low Energy

Bluetooth Low Energy プラグインは、Bluetooth デバイスからスキャン、接続、読み取り、書き込み、通知を受信するためのフル機能のBLE プラグインです。

ガイド

Bluetooth Low Energyのチュートリアル

デバイスでテスト

Download the Capgo app, then scan the QR code.

Bluetooth Low Energy プラグインのプレビュー QR code

@capgo/capacitor-bluetooth-low-energy を使用する

Capacitor Bluetooth Low Energy プラグイン (BLE 通信用)

インストール

bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync

このプラグインが公開するもの

  • initialize - BLE プラグインを初期化する。どの他のメソッドも呼び出す前に必ず実行する。
  • shimWebBluetooth - Capacitor Web Bluetooth シムを __CAPGO_KEEP_1__ にインストールする。 navigator.bluetoothCapacitor に Web Bluetooth シムを手動で呼び出す前に、Web Bluetooth API を使用する。
  • isAvailable - デバイス上の Bluetooth が利用可能かどうかを確認する。
  • isEnabled - デバイス上の Bluetooth が有効かどうかを確認する。

使用例

initialize

BLE プラグインを初期化します。どの他のメソッドよりも前に呼び出す必要があります。

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

await BluetoothLowEnergy.initialize({ mode: 'central' });

shimWebBluetooth

Capacitor Web Bluetooth shim をインストールしてください。 navigator.bluetooth。Web Bluetooth API を使用する前に、Capacitor ネイティブ アプリから手動で呼び出してください。

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

デバイス上の Bluetooth が利用可能かどうかを確認します。

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

const { available } = await BluetoothLowEnergy.isAvailable();

isEnabled

デバイス上の Bluetooth が有効かどうかを確認します。

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

const { enabled } = await BluetoothLowEnergy.isEnabled();

フル リファレンス

Using @capgo/capacitor-bluetooth-low-energy を使用している場合

Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-bluetooth-low-energy @capgo/capacitor-bluetooth-low-energy を使用して進みましょう native プラグインの作業計画に接続する @capgo/capacitor-bluetooth-low-energy @capgo/capacitor-bluetooth-low-energyの実装詳細 Getting Started Getting Startedの実装詳細 Capgo プラグイン ディレクトリ Capgo プラグイン ディレクトリの製品ワークフロー Capacitor Plugins by Capgo Capacitor プラグインの Capgo __CAPGO_KEEP_0__ プラグインの __CAPGO_KEEP_1__の実装詳細 プラグインの追加または更新