Petunjuk
Tutorial tentang Bluetooth Low Energy
Menggunakan @capgo/capacitor-bluetooth-low-energy
Capacitor Plugin Bluetooth Low Energy untuk komunikasi BLE.
Instal
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
Apa yang Dibuka oleh Plugin Ini
initialize- Inisialisasi plugin BLE. Harus dipanggil sebelum metode lainnya.shimWebBluetooth- Pasang shim Web Bluetooth Capacitor padanavigator.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari aplikasi native Capacitor.isAvailable- Periksa apakah Bluetooth tersedia pada perangkat.isEnabled- Periksa apakah Bluetooth diaktifkan pada perangkat.
Contoh Penggunaan
initialize
Inisialisasi plugin BLE. Harus dipanggil sebelum metode lainnya.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
Pasang shim Web Bluetooth Capacitor di navigator.bluetoothPanggil secara manual sebelum menggunakan Web Bluetooth API dari aplikasi native Capacitor.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();
isAvailable
Periksa apakah Bluetooth tersedia pada perangkat.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
Periksa apakah Bluetooth diaktifkan pada perangkat.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();
Referensi Lengkap
- GitHub: https://github.com/Cap-go/capacitor-bluetooth-low-energy/
- Dokumentasi: /docs/plugins/bluetooth-low-energy/