Langkah ke konten utama
Kembali ke plugin
@capgo/capacitor-low-energy-Bluetooth
Tutorial
oleh github.com/Cap-go

Low Energy Bluetooth

Plugin BLE yang lengkap untuk memindai, menghubungkan, membaca, menulis, dan menerima notifikasi dari perangkat Bluetooth

Panduan

Tutorial Menggunakan 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 di navigator.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari sebuah Capacitor aplikasi native.
  • isAvailable - Periksa apakah Bluetooth tersedia di perangkat.
  • isEnabled - Periksa apakah Bluetooth diaktifkan di 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.bluetooth. Panggil secara manual sebelum menggunakan Web Bluetooth API dari sebuah Capacitor aplikasi native.

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

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

Periksa apakah Bluetooth tersedia di perangkat.

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

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

isEnabled

Periksa apakah Bluetooth diaktifkan di perangkat.

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

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

Referensi Lengkap

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

Jika Anda menggunakan Menggunakan @capgo/capacitor-bluetooth-low-energy untuk merencanakan pekerjaan plugin native, hubungkannya dengan @capgo/capacitor-bluetooth-low-energy untuk detail implementasi di @capgo/capacitor-bluetooth-low-energy Pembelajaran Awal untuk detail implementasi di Pembelajaran Awal, Direktori Plugin Capgo untuk alur kerja produk di Direktori Plugin Capgo, Plugin-Plugin Capacitor oleh Capgo untuk detail implementasi di Plugin-Plugin Capacitor oleh Capgo, dan Menambahkan atau Mengupdate Plugin untuk detail implementasi di Menambahkan atau Mengupdate Plugin.