メインコンテンツにジャンプする
プラグインに戻る
@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 BLE 通信用の Bluetooth Low Energy プラグイン

インストール

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

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

  • initialize - BLE プラグインを初期化する。どのメソッドも呼び出す前に必ず実行する。
  • shimWebBluetooth - Capacitor Web Bluetooth シムを __CAPGO_KEEP_1__ にインストールする。 navigator.bluetoothこのメソッドは、Capacitor ネイティブ アプリから 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 シムをインストールしてください。 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 を使用している場合 Using @capgo/capacitor-bluetooth-low-energy native プラグインの作業を計画するには、接続する @capgo/capacitor-bluetooth-low-energy for the implementation detail in @capgo/capacitor-bluetooth-low-energy, Getting Started Getting Startedの実装詳細については Capgo プラグイン ディレクトリ Capgo プラグイン ディレクトリの製品ワークフローについては Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and プラグインの追加または更新 プラグインの追加または更新の実装詳細については