Aller directement au contenu principal
Retour aux plugins
@capgo/capacitor-Bluetooth faible consommation
Tutoriel
@capgo/capacitor-Bluetooth faible consommation

Bluetooth faible consommation

Plugin Bluetooth faible consommation complet pour la recherche, la connexion, la lecture, l'écriture et la réception de notifications des appareils Bluetooth

Guide

Tutoriel sur Bluetooth Low Energy

Tester sur appareil

Téléchargez l'application Capgo, puis scannez le code QR code.

Bluetooth Low Energy plugin preview QR code

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 sur navigator.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 le dispositif.
  • isEnabled - Vérifiez si le Bluetooth est activé sur le dispositif.

Exemple d'utilisation

initialize

Initialisez 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

Installez le Capacitor shim Web Bluetooth 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 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

Continuez de l'article Utilisation de @capgo/capacitor-low-energy-Bluetooth

Si vous utilisez Utilisation de @capgo/capacitor-low-energy-Bluetooth planer les travaux de plugin natif, connectez-le à @capgo/capacitor-Bluetooth basse consommation pour les détails d'implémentation dans @capgo/capacitor-Bluetooth basse consommation, Démarrage pour les détails d'implémentation dans Démarrage, Capgo Répertoire des plugins pour le flux de travail du produit dans Capgo Répertoire des plugins, Capacitor Plugins par Capgo pour les détails d'implémentation dans Capacitor Plugins par Capgo, et Ajouter ou Mettre à jour les plugins pour les détails d'implémentation dans Ajouter ou Mettre à jour les plugins.