bare-bluetooth-android
Reference overview for bare-bluetooth-android: Android Bluetooth Low Energy bindings for Bare, covering both the central (scanner/client) and peripheral (GATT server) roles.
bare-bluetooth-android provides Android Bluetooth Low Energy (BLE) bindings for Bare, covering both the central (scanner/client) role and the peripheral (GATT server) role. 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. -
Server— the BLE peripheral (GATT server) role. Supports advertising, service registration, characteristic read/write request handling, value updates with subscriber notifications, and L2CAP connection-oriented channel publishing. See the repository README for the fullServerAPI.
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.