@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__ ネイティブ アプリから Web Bluetooth Capacitor を使用する前に、手動で呼び出す。navigator.bluetooth. Call this manually before using the Web Bluetooth API from a Capacitor native app.isAvailable- デバイス上の Bluetooth が有効かどうかを確認する。isEnabled使用例
__CAPGO_KEEP_0__
initialize
BLE プラグインを初期化する。どの他のメソッドよりも前に呼び出す必要がある。
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Capacitor Web Bluetooth シムをインストールする。 navigator.bluetooth. API を使用する前に、Capacitor ネイティブ アプリから API を手動で呼び出す。
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();
フル リファレンス
- GitHub: https://github.com/Cap-go/capacitor-bluetooth-low-energy/
- ドキュメント: /docs/plugins/bluetooth-low-energy/
Using @capgo/capacitor-bluetooth-low-energy
@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-bluetooth-low-energy を使用している場合 @capgo/capacitor-bluetooth-low-energy を使用 ネイティブ プラグインの作業を計画するには、接続する @capgo/capacitor-bluetooth-low-energy for the implementation detail in @capgo/capacitor-bluetooth-low-energy, Getting Started Getting Startedの実装詳細については Capgo プラグイン ディレクトリ Capgo プラグイン ディレクトリの製品ワークフローについては Capacitor プラグインズ by Capgo Capacitor-Bluetooth Low Energyの実装詳細やCapacitor プラグインズ by Capgoの実装詳細については プラグインの追加または更新 プラグインの追加または更新の実装詳細については