Zum Hauptinhalt springen
Zurück zu Plugins
@capgo/capacitor-bluetooth-low-energy
Tutorial
@capgo/capacitor-bluetooth-low-energy

Bluetooth Low Energy

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

Anleitung

Tutorial zum Bluetooth Low Energy

Gerät testen

Herunterladen Sie die Capgo-App, dann scannen Sie das QR-code.

Bluetooth Low Energy plugin preview QR code

Verwendung von @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 Plugin-Exposition enthält

  • initialize - Initialisieren Sie das BLE-Plugin. Muss vor der Verwendung jeder anderen Methode aufgerufen werden.
  • shimWebBluetooth - Installieren Sie den Capacitor Web Bluetooth Shim auf navigator.bluetooth. Ruf diese Methode manuell auf, bevor Sie die Web Bluetooth API aus einer Capacitor nativen App verwenden.
  • isAvailable - Überprüfen Sie, ob Bluetooth auf dem Gerät verfügbar ist.
  • isEnabled - Überprüfen Sie, ob Bluetooth auf dem Gerät aktiviert ist.

Beispielische Verwendung

initialize

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

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

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

shimWebBluetooth

Installieren Sie das Capacitor Web-Bluetooth-Wrapper auf navigator.bluetooth. Ruf diese Funktion manuell vor der Verwendung des Web-Bluetooth-API aus einem Capacitor nativen App auf.

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

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

Überprüfen Sie, ob Bluetooth auf dem Gerät verfügbar ist.

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

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

isEnabled

Überprüfen Sie, ob Bluetooth auf dem Gerät aktiviert ist.

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

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

Vollständige Referenz

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

If Sie Bluetooth Low Energy verwenden Verwendung von @capgo/capacitor-bluetooth-low-energy Um native Plugin-Arbeit zu planen, verbinden Sie es mit @capgo/capacitor-bluetooth-low-energy zur Implementierungsdetail in @capgo/capacitor-bluetooth-low-energy Anleitung zum Starten zur Implementierungsdetail in Anleitung zum Starten Capgo Plugin-Verzeichnis zur Produktworkflow in Capgo Plugin-Verzeichnis Capacitor Plugins von Capgo zur Implementierungsdetail in Capacitor Plugins von Capgo, und Plugins hinzufügen oder aktualisieren Für die Implementierungsdetails in der Hinzufügung oder Aktualisierung von Plugins.