Guía
Tutorial sobre Bluetooth Low Energy
Usando @capgo/capacitor-bluetooth-low-energy
Capacitor Plugin de Bluetooth Low Energy para comunicación BLE.
Instalar
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
Qué Exposa Este Plugin
initialize- Inicializar el plugin de BLE. Debe llamarse antes de cualquier otro método.shimWebBluetooth- Instalar el shim de Web Bluetooth de Capacitor ennavigator.bluetoothLlame a esto manualmente antes de usar el Web Bluetooth de API desde una aplicación nativa Capacitor.isAvailable- Verifique si el Bluetooth está disponible en el dispositivo.isEnabled- Verifique si el Bluetooth está habilitado en el dispositivo.
Ejemplo de uso
initialize
Inicialice el plugin de BLE. Debe llamarse antes de cualquier otro método.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Instale el shim de Web Bluetooth Capacitor en navigator.bluetoothLlame a esto manualmente antes de usar el Web Bluetooth API desde una aplicación nativa Capacitor.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();
isAvailable
Verifique si el Bluetooth está disponible en el dispositivo.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
Verifique si el Bluetooth está habilitado en el dispositivo.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();
Referencia completa
- GitHub: https://github.com/Cap-go/capacitor-energía-baja-del-bluetooth/
- Documentación: /docs/plugins/bluetooth-low-energy/