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-fitur untuk memindai, menghubungkan, membaca, menulis, dan menerima pemberitahuan dari perangkat Bluetooth

Petunjuk

Tutorial tentang Bluetooth Low Energy

Menggunakan @capgo/capacitor-bluetooth-low-energy

Plugin Bluetooth Low Energy Capacitor untuk komunikasi BLE.

Instalasi

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. navigator.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari aplikasi Capacitor native.
  • isAvailable - Periksa jika Bluetooth tersedia pada perangkat.
  • isEnabled - Periksa jika 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. navigator.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari aplikasi Capacitor native.

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

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

Periksa jika Bluetooth tersedia pada perangkat.

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

const { available } = await BluetoothLowEnergy.isAvailable();

isEnabled

Periksa jika Bluetooth diaktifkan pada perangkat.

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

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

Referensi Lengkap

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

Jika Anda menggunakan Menggunakan @capgo/capacitor-bluetooth-low-energy untuk merencanakan pekerjaan plugin native, hubungkan dengan @capgo/capacitor-bluetooth-low-energy untuk detail implementasi di @capgo/capacitor-bluetooth-low-energy, Mulai Membuat untuk detail implementasi di Getting Started, Capgo Direktori Plugin untuk alur kerja produk di Capgo Direktori Plugin, Capacitor Plugin oleh Capgo untuk detail implementasi di Capacitor Plugin oleh Capgo, dan Menginstal atau Mengupdate Plugin untuk detail implementasi di Menginstal atau Mengupdate Plugin.