An __CAPGO_KEEP_0__ ansehen
Anleitung
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
Dieses Plugin enthüllt
initialize- Initialisieren Sie das BLE-Plugin. Muss vor der Verwendung jeder anderen Methode aufgerufen werden.shimWebBluetooth- Installieren Sie das Capacitor Web Bluetooth Shim aufnavigator.bluetooth. Ruf diese Methode manuell auf, bevor Sie das 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.
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.bluetooth . Rufen Sie diese 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
- GitHub: https://github.com/Cap-go/capacitor-bluetooth-low-energy/
- Dokumentation: /docs/plugins/bluetooth-low-energy/
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 Anleitung zum Starten für die Implementierungsdetails in Anleitung zum Starten 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