Passer à la navigation principale
Retour aux plugins
@capgo/capacitor-Bluetooth basse consommation d'énergie
Tutoriel
@capgo/capacitor-Bluetooth basse consommation d'énergie

Bluetooth basse consommation d'énergie

Plugin Bluetooth basse consommation d'énergie complet pour la recherche, la connexion, la lecture, l'écriture et la réception de notifications de périphériques Bluetooth

Guide

Tutoriel sur la faible consommation d'énergie Bluetooth

Tester sur appareil

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

Bluetooth Low Energy plugin preview QR code

Utilisation de @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. Il doit être appelé avant toute autre méthode.
  • shimWebBluetooth - Installer le shim Web Bluetooth Capacitor sur navigator.bluetooth- Appeler manuellement avant d'utiliser le Web Bluetooth API 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

Initialisez le plugin BLE.

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

await BluetoothLowEnergy.initialize({ mode: 'central' });

shimWebBluetooth

Installez le shim Web Bluetooth Capacitor sur navigator.bluetoothAppeler manuellement avant d'utiliser le Web Bluetooth 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

Continuez de l'étape Utilisation de @capgo/capacitor-bluetooth-low-energy

Si vous utilisez Utilisation de @capgo/capacitor-bluetooth-low-energy pour planifier le travail de plugin natif, connectez-le à @capgo/capacitor-low-energy-bluetooth pour les détails d'implémentation dans @capgo/capacitor-low-energy-bluetooth, Prise en main pour les détails d'implémentation dans Prise en main, Répertoire des plugins Capgo pour le flux de travail du produit dans Répertoire des plugins 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.