Ke halaman utama
Kembali ke plugin
@capgo/capacitor-bluetooth-low-energy
Tutorial
@capgo/capacitor-bluetooth-low-energy

Bluetooth Low Energy

Plugin BLE yang lengkap untuk melakukan pencarian, koneksi, membaca, menulis, dan menerima notifikasi dari perangkat Bluetooth

Petunjuk

Tutorial tentang 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 Dibuka oleh 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

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 jika Bluetooth tersedia di perangkat.

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

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

isEnabled

Periksa jika Bluetooth diaktifkan di 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, hubungkannya dengan @capgo/capacitor-Bluetooth Low Energy untuk detail implementasi di @capgo/capacitor-Bluetooth Low Energy, Mengawali Mulai untuk detail implementasi di Mengawali Mulai, 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.