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 Bluetooth Low Energy

Tes di perangkat

Unduh aplikasi Capgo, kemudian scan kode QR code.

Pratinjau Tautan QR Plugin Bluetooth Low Energy code

Menggunakan @capgo/capacitor-bluetooth-low-energy

Capacitor Plugin Bluetooth Low Energy untuk Komunikasi BLE

Pasang

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

Penggunaan Contoh

initialize

Mulai plugin BLE. Harus dipanggil sebelum metode lainnya.

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

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

shimWebBluetooth

Instal shim Bluetooth Web Capacitor pada navigator.bluetoothPanggil secara manual sebelum menggunakan Bluetooth Web 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

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

Jika Anda menggunakan Menggunakan @capgo/capacitor-bluetooth-low-energy untuk merencanakan kerja plugin native, hubungkannya dengan @capgo/capacitor-bluetooth-low-energy untuk detail implementasi di @capgo/capacitor-bluetooth-low-energy, Mulai untuk detail implementasi di Mulai, 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.