Guide
Tutoriel sur Bluetooth Low Energy
En utilisant @capgo/capacitor-bluetooth-low-energy
Capacitor Plugin Bluetooth Low Energy pour la communication BLE.
Installer
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
Ce que ce plugin expose
initialize- Initialiser le plugin BLE. Doit être appelé avant toute autre méthode.shimWebBluetooth- Installer le shim Web Bluetooth Capacitor surnavigator.bluetoothAppelez cela manuellement avant d'utiliser le Web Bluetooth API à partir d'une application native Capacitor.isAvailable- Vérifiez si le Bluetooth est disponible sur l'appareil.isEnabled- Vérifiez si le Bluetooth est activé sur l'appareil.
Exemple d'utilisation
initialize
Initialisez le plugin BLE. Il doit être appelé avant toute autre méthode.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Installez le shim Web Bluetooth Capacitor sur navigator.bluetoothAppelez manuellement cela 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érifiez si le Bluetooth est disponible sur le appareil.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
Vérifiez si le Bluetooth est activé sur le appareil.
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-bluetooth/
- Docs: /docs/plugins/bluetooth-low-energy/
Continuez à partir de l'utilisation de @capgo/capacitor-low-energy-bluetooth
Si vous utilisez Utilisation de @capgo/capacitor-low-energy-bluetooth pour planifier le travail de plugin natif, connectez-le à @capgo/capacitor-Bluetooth faible consommation pour les détails d'implémentation dans @capgo/capacitor-Bluetooth faible consommation, Démarrage pour les détails d'implémentation dans Démarrage, Répertoire de plugin Capgo pour le flux de travail du produit dans Répertoire de plugin Capgo, Plugins Capacitor par Capgo pour les détails d'implémentation dans Plugins Capacitor par Capgo, et Ajouter ou mettre à jour des plugins pour les détails d'implémentation dans Ajouter ou mettre à jour des plugins.