Guida
Tutorial sul Bluetooth Low Energy
Usando @capgo/capacitor-low-energia-bluetooth
Capacitor Plugin di bassa energia Bluetooth per la comunicazione BLE.
Installa
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
Cosa Questo Plugin Espone
initialize- Inizializza il plugin BLE. Deve essere chiamato prima di qualsiasi altro metodo.shimWebBluetooth- Installa il shim di Web Bluetooth Capacitor sunavigator.bluetoothChiamalo manualmente prima di utilizzare il Web Bluetooth API da un'app nativa Capacitor.isAvailable- Controlla se il Bluetooth è disponibile sul dispositivo.isEnabled- Controlla se il Bluetooth è abilitato sul dispositivo.
Esempio di Utilizzo
initialize
Inizializza il plugin BLE. Deve essere chiamato prima di qualsiasi altro metodo.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Installa il shim di Web Bluetooth Capacitor su navigator.bluetooth. Chiama questo manualmente prima di utilizzare il Bluetooth Web API da un'app nativa Capacitor.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();
isAvailable
Verifica se il Bluetooth è disponibile sul dispositivo.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
Verifica se il Bluetooth è abilitato sul dispositivo.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();
Riferimento Completo
- GitHub: https://github.com/Cap-go/capacitor-low-energy-bluetooth/
- Documentazione: /docs/plugins/bluetooth-low-energy/