メインコンテンツにスキップ
プラグインに戻る
@capgo/capacitor-低消費電力Bluetooth
チュートリアル
github.com/Cap-go による

低消費電力Bluetooth

低消費電力Bluetooth デバイスからスキャン、接続、読み取り、書き込み、通知を受信するためのフル機能のBLE プラグイン

ガイド

Bluetooth Low Energyのチュートリアル

Using @capgo/capacitor-bluetooth-low-energy

Capacitor Bluetooth Low Energy プラグイン

インストール

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

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

  • initialize - BLE プラグインを初期化する。どの他のメソッドよりも先に呼び出す必要がある。
  • shimWebBluetooth - Capacitor Web Bluetooth shim をインストールする。 navigator.bluetooth. Capacitor ネイティブ アプリから Web Bluetooth API を使用する前に、手動で呼び出すこと。
  • isAvailable - __CAPGO_KEEP_0__ が利用可能かどうかを確認します。
  • isEnabled - __CAPGO_KEEP_0__ が有効かどうかを確認します。

例の使用

initialize

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

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

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

shimWebBluetooth

Capacitor Web Bluetooth シムをインストールします。 navigator.bluetoothAPI を Capacitor ネイティブ アプリから呼び出す前に、手動でこのメソッドを呼びます。

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

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

__CAPGO_KEEP_0__ が利用可能かどうかを確認します。

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

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

isEnabled

__CAPGO_KEEP_0__ が有効かどうかを確認します。

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

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

フル リファレンス