bare-bluetooth-android
Reference overview for bare-bluetooth-android: Android Bluetooth Low Energy bindings for Bare, in the central (scanner/client) role.
bare-bluetooth-android provides Android Bluetooth Low Energy (BLE) bindings for Bare. It's a native addon and runs on Android only—on Apple platforms use bare-bluetooth-apple. This page is an overview; the surface is large, so see the repository README for the full API.
npm i bare-bluetooth-androidUsage
const { Central } = require('bare-bluetooth-android')
const central = new Central()
central.on('stateChange', (state) => {
if (state === 'on') central.startScan(['180D']) // Heart Rate service
})
central.on('discover', (peripheral) => {
console.log('Found:', peripheral.name, peripheral.id)
central.stopScan()
})API overview
Central— the BLE central (scanner/client) role. Drive scanning withcentral.startScan([serviceUUIDs])andcentral.stopScan(), and observe adapter state and discoveries via thestateChangeanddiscoverevents. Discovered peripherals can be connected to, with their services and characteristics read, written, and subscribed for notifications.
The module builds on bare-events and bare-stream. For the complete peripheral/service/characteristic API, refer to the repository.
See also
bare-bluetooth-apple—the Apple-platform counterpart.- Bare modules—the full
bare-*catalog. - One core, many platforms—using platform bindings from a native shell.