Langkah ke konten utama
Kembali ke Plugin
@capgo/capacitor-bluetooth-low-energy
Tutorial
@capgo/capacitor-bluetooth-low-energy

Bluetooth Low Energy

Plugin BLE yang lengkap untuk melakukan pemindaian, menghubungkan, membaca, menulis, dan menerima pemberitahuan dari perangkat Bluetooth

Panduan

Tutorial tentang Bluetooth Low Energy

Tes di perangkat

Unduh aplikasi Capgo terlebih dahulu, kemudian scan kode QR code.

Tautan QR Pratinjau Plugin code Bluetooth Low Energy

Menggunakan @capgo/capacitor-bluetooth-low-energy

Plugin Bluetooth Low Energy Capacitor untuk Komunikasi BLE.

Instal

bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync

Apa yang Dapat Diketahui Plugin Ini

  • initialize - Inisialisasi plugin BLE. Harus dipanggil sebelum metode lainnya.
  • shimWebBluetooth - Pasang shim Web Bluetooth Capacitor pada navigator.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari aplikasi native Capacitor.
  • isAvailable - Periksa apakah Bluetooth tersedia pada perangkat.
  • isEnabled - Periksa apakah Bluetooth telah diaktifkan pada perangkat.

Contoh Penggunaan

initialize

Initilize plugin BLE. Harus dipanggil sebelum metode lainnya.

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

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

shimWebBluetooth

Instal shim Web Bluetooth Capacitor pada 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 telah diaktifkan pada perangkat.

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

const { enabled } = await BluetoothLowEnergy.isEnabled();

Referensi Lengkap

Teruskan dari Menggunakan @capgo/capacitor-bluetooth-low-energy

If Anda menggunakan Menggunakan @capgo/capacitor-bluetooth-low-energy untuk merencanakan kerja plugin asli, hubungkan dengan @capgo/capacitor-bluetooth-low-energy untuk detail implementasi di @capgo/capacitor-bluetooth-low-energy, Panduan Pemula untuk detail implementasi di Panduan Pemula, Daftar Plugin @Capgo untuk alur kerja produk di Daftar Plugin @Capgo, Plugin @Capacitor oleh @Capgo untuk detail implementasi di Plugin @Capacitor oleh @Capgo, dan Menambahkan atau Mengupdate Plugin untuk detail implementasi di Menambahkan atau Mengupdate Plugin.