Guide
Tutoriel sur le Bluetooth Low Energy
Utilisation de @capgo/capacitor-bluetooth-low-energy
Plugin Bluetooth Low Energy de Capacitor pour la communication BLE
Installation
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
Ce plugin expose les éléments suivants
initialize- Initialiser le plugin BLE. Doit être appelé avant toute autre méthode.shimWebBluetooth- Installer le Capacitor shim Web Bluetooth surnavigator.bluetoothAppeler manuellement avant d'utiliser le Bluetooth Web API à partir d'une application native Capacitor.isAvailable- Vérifier si le Bluetooth est disponible sur le dispositif.isEnabled- Vérifier si le Bluetooth est activé sur le dispositif.
Exemple d'utilisation
initialize
Initialiser le plugin BLE. Doit être appelé avant toute autre méthode.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Installer le Capacitor shim Web Bluetooth sur navigator.bluetoothAppeler manuellement avant d'utiliser le Bluetooth Web API à partir d'une application native Capacitor.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();
isAvailable
Vérifier si le Bluetooth est disponible sur le dispositif.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
Vérifiez si le Bluetooth est activé sur le dispositif.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();
Référence complète.
- GitHub. https://github.com/Cap-go/capacitor-low-energy-ble/
- Documentation : /docs/plugins/low-energy-ble/
Continuez à partir de l'utilisation de @capgo/capacitor-low-energy-ble
Si vous utilisez L'utilisation de @capgo/capacitor-low-energy-ble pour planifier le travail de plugin natif, connectez-le avec @capgo/capacitor-low-energy-ble pour les détails d'implémentation dans @capgo/capacitor-low-energy-ble, Démarrage pour les détails d'implémentation dans Getting Started, Capgo Répertoire de plugins pour le flux de travail du produit dans Capgo Répertoire de plugins, Capacitor Plugins par Capgo pour les détails d'implémentation dans Capacitor Plugins par Capgo, et Ajouter ou mettre à jour des plugins pour les détails d'implémentation dans Ajouter ou mettre à jour des plugins.