Zum Hauptinhalt springen
Zurück zu Plugins
@capgo/capacitor-bluetooth-low-energy
Tutorial
von github.com/Cap-go

Bluetooth Low Energy

Vollwertiger BLE-Plugin für das Scannen, Verbinden, Lesen, Schreiben und Empfangen von Benachrichtigungen von Bluetooth-Geräten

Richtlinie

Tutorial zum Bluetooth Low Energy

Mit @capgo/capacitor-bluetooth-low-energy

Capacitor Bluetooth Low Energy-Plugin für BLE-Kommunikation.

Installieren

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

Was diese Erweiterung bereitstellt

  • initialize - Initialisiere das BLE-Plugin. Muss vor jeder anderen Methode aufgerufen werden.
  • shimWebBluetooth - Installiere das Capacitor Web Bluetooth-Stub auf navigator.bluetooth. Ruf diese Methode manuell auf, bevor du das Web Bluetooth-API aus einer Capacitor nativen App verwendest.
  • isAvailable - Überprüfe, ob Bluetooth auf dem Gerät verfügbar ist.
  • isEnabled - Überprüfe, ob Bluetooth auf dem Gerät aktiviert ist.

Beispiel für die Verwendung

initialize

- Initialisiere das BLE-Plugin. Muss vor jeder anderen Methode aufgerufen werden.

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

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

shimWebBluetooth

- Installiere das Capacitor Web Bluetooth-Stub auf navigator.bluetooth. Ruf diese Methode manuell auf, bevor du das Web Bluetooth-API aus einer Capacitor nativen App verwendest.

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

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

- Überprüfe, ob Bluetooth auf dem Gerät verfügbar ist.

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

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

isEnabled

- Überprüfe, ob Bluetooth auf dem Gerät aktiviert ist.

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

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

Vollständige Referenz

Weitermachen Sie mit der Verwendung von @capgo/capacitor-bluetooth-low-energy

Wenn Sie die Verwendung von Die Verwendung von @capgo/capacitor-bluetooth-low-energy um native Plugin-Arbeit zu planen, verbinden Sie es mit @capgo/capacitor-bluetooth-low-energy für die Implementierungsdetails in @capgo/capacitor-bluetooth-low-energy, Einstieg für die Implementierungsdetails in Einstieg, Capgo Plugin-Verzeichnis für den Produktworkflow in Capgo Plugin-Verzeichnis, Capacitor Plugins von Capgo für die Implementierungsdetails in Capacitor Plugins von Capgo, und Plugins hinzufügen oder aktualisieren für die Implementierungsdetails in Plugins hinzufügen oder aktualisieren.