All Projects → IjzerenHein → Node Web Bluetooth

IjzerenHein / Node Web Bluetooth

Licence: mit
Web Bluetooth API and interactive device picker for node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Web Bluetooth

Bluesmirf
RN-41/42 bluetooth module breakout boards, available from SparkFun Electronics
Stars: ✭ 9 (-85.94%)
Mutual labels:  bluetooth
Potato Library
Easy to use Utility library for Android
Stars: ✭ 45 (-29.69%)
Mutual labels:  bluetooth
Phony
Easy to use bluetooth hands free telephony, with python
Stars: ✭ 57 (-10.94%)
Mutual labels:  bluetooth
Roboticarmandroid
💪 + 📱 It's a simple project where you'll learn how to create a Robotic Arm with Arduino board, controlled by a Android smartphone using Bluetooth. (PT-BR: Um projeto simples onde você irá aprender como criar um braço robótico utilizando Arduino, e controlar ele via Bluetooth através de um aplicativo Android)
Stars: ✭ 14 (-78.12%)
Mutual labels:  bluetooth
Bluetoothserial
Cordova (PhoneGap) Plugin for Serial Communication over Bluetooth
Stars: ✭ 999 (+1460.94%)
Mutual labels:  bluetooth
Gjlightbluetooth
自己封装的基于CoreBluetooth的蓝牙开发库,内附CoreBluetooth使用demo。数据传递基本上使用Block,还使用了Runtime等技术。
Stars: ✭ 50 (-21.87%)
Mutual labels:  bluetooth
Fix Bt A2dp
Workaround fixing no A2DP when BT headphone reconnects automatically (after being paired)
Stars: ✭ 25 (-60.94%)
Mutual labels:  bluetooth
Drivety
Drivety: Smart App Assistant to Secure Inside Car Activity. #AndroidDevChallenge
Stars: ✭ 62 (-3.12%)
Mutual labels:  bluetooth
Eclipse Smarthome Bluetooth Binding
Eclipse SmartHome Bluetooth Binding
Stars: ✭ 44 (-31.25%)
Mutual labels:  bluetooth
Circulate
Reverse engineered iOS library for controlling the Anova 2 via Bluetooth
Stars: ✭ 56 (-12.5%)
Mutual labels:  bluetooth
Arek
AREK is a clean and easy way to request any kind of iOS permission (with some nifty features 🤖)
Stars: ✭ 947 (+1379.69%)
Mutual labels:  bluetooth
Bluetooth State View
Material design animated Bluetooth state view for Android
Stars: ✭ 36 (-43.75%)
Mutual labels:  bluetooth
Imbmw
BMW iBus .NET MF SDK and hardware
Stars: ✭ 50 (-21.87%)
Mutual labels:  bluetooth
Nativescript Headset Detection
Detect when a headphone (jack or bluetooth) is (dis)connected.
Stars: ✭ 11 (-82.81%)
Mutual labels:  bluetooth
Apple Family
A simple framework that brings Apple devices together - like a family
Stars: ✭ 59 (-7.81%)
Mutual labels:  bluetooth
Eaze
iOS Cleanflight Configurator
Stars: ✭ 8 (-87.5%)
Mutual labels:  bluetooth
Bluetoothstudy
android 传统蓝牙开发实践,详细开发步骤参考博客: http://blog.csdn.net/qiao_jim/article/details/73008695
Stars: ✭ 46 (-28.12%)
Mutual labels:  bluetooth
Qdomyos Zwift
Zwift bridge for smart treadmills and bike/cyclette
Stars: ✭ 63 (-1.56%)
Mutual labels:  bluetooth
Tastysnake
A two-player (Bluetooth) game on Android.
Stars: ✭ 61 (-4.69%)
Mutual labels:  bluetooth
Pytile
📡 A simple Python API for Tile® Bluetooth trackers
Stars: ✭ 56 (-12.5%)
Mutual labels:  bluetooth

node-web-bluetooth logo Build Status MIT licensed

Web Bluetooth API and interactive device picker for node.js, using the awesome noble package

Installation

npm install node-web-bluetooth

This will automatically install noble. Depending on your system environment and the tools installed, noble may or may not work out of the box. Please visit https://github.com/abandonware/noble on how to install all the prerequisites for noble.

Usage

const Bluetooth	= require('node-web-bluetooth');

async function connect() {
	const device = await Bluetooth.requestDevice({
		filters: [
			{services: ['heart_rate']}
		]
	});
	const server = await device.gatt.connect();
	const service = await server.getPrimaryService('heart_rate');
	const char = await service.getCharacteristic('heart_rate_measurement');
	await char.startNotifications();
	char.on('characteristicvaluechanged', (data) => {
		// parse heart-rate data here
	});
	...
	await char.stopNotifications();
	await server.disconnect();
}
connect();

node-web-bluetooth-request-device

Programmatically selecting a device

By default, Bluetooth.requestDevice shows an interactive list with all the discovered devices it has found. To programmatically control the selected device, you can pass in an instance of the RequestDeviceDelegate class.

const Bluetooth	= require('node-web-bluetooth');

class SelectFirstFoundDevice extends Bluetooth.RequestDeviceDelegate {

	// Select first device found
	onAddDevice(device) {
		this.resolve(device);
	}
	onUpdateDevice(device) {
		// Called whenever new advertisement data was received
		// for the device
	}

	// Time-out when device hasn't been found in 20 secs
	onStartScan() {
		this._timer = setTimeout(() => {
			this.reject(new Error('No device found'));
		}, 20000);
	}
	onStopScan() {
		if (this._timer) clearTimeout(this._timer);
	}
}

async function connect() {
	const device = await Bluetooth.requestDevice({
		filters: [
			{services: ['heart_rate']}
		],
		delegate: new SelectFirstFoundDevice()
	});
	...
}
connect();

Customizing the interactive device picker

The header-text and the formatting of the interactive device picker are customizable. To fully customize it, derive a class from it and override its methods.

const Bluetooth	= require('node-web-bluetooth');

const device = Bluetooth.requestDevice({
	delegate: new Bluetooth.InteractiveRequestDeviceDelegate({
		header: 'Set your custom header text here',
		format: (device) => `${device.id} - ${device.name}`
	})
});

navigator.bluetooth compatibility

In order to achieve full code compatibility with browser code, navigator.bluetooth is injected into the global scope. In case the navigator object already existed, it is extended with the bluetooth object. Causing this to work:

require('node-web-bluetooth');

navigator.bluetooth.requestDevice({
	...
});

Supported APIs

  • [x] Bluetooth.requestDevice()
  • [x] Bluetooth.getAvailability()
  • [x] Bluetooth.availabilitychanged
  • [ ] Bluetooth.referringDevice (not relevant)
  • [x] BluetoothDevice.id
  • [x] BluetoothDevice.name
  • [x] BluetoothDevice.gatt
  • [x] BluetoothDevice.uuids
  • [x] BluetoothDevice.gattserverdisconnected
  • [ ] BluetoothDevice.watchAdvertisements()
  • [ ] BluetoothDevice.advertisementreceived()
  • [x] BluetoothRemoteGATTServer.device
  • [x] BluetoothRemoteGATTServer.connected
  • [x] BluetoothRemoteGATTServer.connect()
  • [x] BluetoothRemoteGATTServer.disconnect()
  • [x] BluetoothRemoteGATTServer.getPrimaryService()
  • [x] BluetoothRemoteGATTServer.getPrimaryServices()
  • [x] BluetoothRemoteGATTService.uuid
  • [x] BluetoothRemoteGATTService.isPrimary
  • [x] BluetoothRemoteGATTService.device
  • [x] BluetoothRemoteGATTService.getCharacteristic()
  • [x] BluetoothRemoteGATTService.getCharacteristics()
  • [x] BluetoothRemoteGATTService.getIncludedService()
  • [x] BluetoothRemoteGATTService.getIncludedServices()
  • [ ] BluetoothRemoteGATTService.serviceadded
  • [ ] BluetoothRemoteGATTService.servicechanged
  • [ ] BluetoothRemoteGATTService.serviceremoved
  • [x] BluetoothRemoteGATTCharacteristic.service
  • [x] BluetoothRemoteGATTCharacteristic.uuid
  • [x] BluetoothRemoteGATTCharacteristic.properties
  • [x] BluetoothRemoteGATTCharacteristic.value
  • [x] BluetoothRemoteGATTCharacteristic.getDescriptor()
  • [x] BluetoothRemoteGATTCharacteristic.getDescriptors()
  • [x] BluetoothRemoteGATTCharacteristic.readValue()
  • [x] BluetoothRemoteGATTCharacteristic.writeValue()
  • [ ] BluetoothRemoteGATTCharacteristic.writeValueWithResponse()
  • [ ] BluetoothRemoteGATTCharacteristic.writeValueWithoutResponse()
  • [x] BluetoothRemoteGATTCharacteristic.startNotifications()
  • [x] BluetoothRemoteGATTCharacteristic.stopNotifications()
  • [x] BluetoothRemoteGATTCharacteristic.characteristicvaluechanged
  • [x] BluetoothRemoteGATTDescriptor.characteristic
  • [x] BluetoothRemoteGATTDescriptor.uuid
  • [x] BluetoothRemoteGATTDescriptor.value
  • [x] BluetoothRemoteGATTDescriptor.readValue
  • [x] BluetoothRemoteGATTDescriptor.writeValue
  • [x] Translate characteric names to UUIDs
  • [x] Translate descriptor names to UUIDs

Known issues

Due to an implementation restriction in noble, calling BluetoothRemoteGATTService.getCharacteristic(s) multiple times doesn't work correctly. If you need to obtain multiple characterstics, then do it using a single call to BluetoothRemoteGATTService.getCharacteristics.

Resources

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].