Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webbluetooth

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webbluetooth - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

48

examples/heartrate.js

@@ -27,10 +27,4 @@ /*

var bluetooth = require('../').bluetooth;
var gattServer;
var heartChar;
function log(message) {
console.log(message);
}
log('Requesting Bluetooth Devices...');
console.log('Requesting Bluetooth Devices...');
bluetooth.requestDevice({

@@ -40,43 +34,27 @@ filters:[{ services:[ "heart_rate" ] }]

.then(device => {
log('Found device: ' + device.name);
console.log('Found device: ' + device.name);
return device.gatt.connect();
})
.then(server => {
gattServer = server;
log('Gatt server connected: ' + gattServer.connected);
return gattServer.getPrimaryService("heart_rate");
console.log('Gatt server connected: ' + server.connected);
return server.getPrimaryService("heart_rate");
})
.then(service => {
log('Primary service: ' + service.uuid);
console.log('Primary service: ' + service.uuid);
return service.getCharacteristic("heart_rate_measurement");
})
.then(characteristic => {
log('Characteristic: ' + characteristic.uuid);
heartChar = characteristic;
return heartChar.getDescriptors();
console.log('Characteristic: ' + characteristic.uuid);
return characteristic.startNotifications();
})
.then(descriptors => {
descriptors.forEach(descriptor => {
log('Descriptor: ' + descriptor.uuid);
.then(characteristic => {
console.log('Notifications started');
characteristic.addEventListener("characteristicvaluechanged", event => {
if (event.value.buffer.byteLength) console.log(event.value.getUint16(0));
});
return Array.apply(null, Array(10)).reduce(sequence => {
return sequence.then(() => {
return heartChar.readValue();
}).then(value => {
if (!value.buffer.byteLength) {
return log('No value');
}
log('Value: ' + value.getUint16(0));
});
}, Promise.resolve());
})
.then(() => {
gattServer.disconnect();
log('Gatt server connected: ' + gattServer.connected);
process.exit();
})
.catch(error => {
log(error);
console.log(error);
process.exit();
});
{
"name": "webbluetooth",
"version": "1.0.1",
"version": "1.0.2",
"description": "Node.js implementation of the Web Bluetooth Specification",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/thegecko/webbluetooth",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc