Zum Hauptinhalt springen
Zurück zu plugins
@capgo/capacitor-bluetooth-low-energy
Anleitung
@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

Testen auf Gerät

Laden Sie die Capgo-App herunter, dann scannen Sie die QR-code.

Bluetooth Low Energy Plugin Vorschau 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 jeder anderen Methode aufgerufen werden.
  • shimWebBluetooth - Installieren Sie das Capacitor Web Bluetooth Shim auf navigator.bluetooth- . Rufen Sie diese manuell vor der Verwendung des Web Bluetooth API aus einer Capacitor nativen App auf.
  • 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.

Beispielhafte 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 den Capacitor Web Bluetooth Shim auf navigator.bluetoothRufen Sie diesen 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

Weitermachen von Using @capgo/capacitor-bluetooth-low-energy

Wenn Sie Using @capgo/capacitor-bluetooth-low-energy für die Planung von native Plugin-Arbeiten, 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.