0.0.1 • Published 8 months ago

capacitor-plugin-bluetoothbleconnection v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

bluetooth

Plugin to connect with BLE IoT devices and perform required operations

Install

npm install capacitor-plugin-bluetoothbleconnection
npx cap sync

API

Interface for interacting with Bluetooth devices in a Capacitor plugin.

checkPermissions()

checkPermissions() => Promise<void>

Checks if Bluetooth permissions are granted on the device. If not, it will request the necessary permissions.


scanForDevices()

scanForDevices() => Promise<{ devices: { name: string; address: string; }[]; }>

Scans for nearby Bluetooth devices. This method returns a list of discovered devices with their name and address.

Returns: Promise<{ devices: { name: string; address: string; }[]; }>


connectToDevice(...)

connectToDevice(options: { deviceAddress: string; }) => Promise<{ batteryLevel: number; manufacturerName: string; }>

Connects to a Bluetooth device using its device address. After successfully connecting, it retrieves the battery level and manufacturer name.

ParamTypeDescription
options{ deviceAddress: string; }The options for connecting to a device, including the device's address.

Returns: Promise<{ batteryLevel: number; manufacturerName: string; }>


disconnectDevice()

disconnectDevice() => Promise<void>

Disconnects the currently connected Bluetooth device.