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 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 aufnavigator.bluetoothRufen Sie diese Funktion 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 der Verwendung 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 diese Funktion manuell vor der Verwendung des Web Bluetooth API aus einer 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/
Fortsetzen Sie mit Using @capgo/capacitor-bluetooth-low-energy
Wenn Sie Using verwenden Using @capgo/capacitor-bluetooth-low-energy für die native Plugin-Arbeit zu planen, verbinden Sie es mit @capgo/capacitor-Bluetooth-Low-Energie Für die Implementierungsdetails in @capgo/capacitor-Bluetooth-Low-Energie 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