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

bluetooth-helper

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluetooth-helper - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

bower.json
{
"name": "bluetooth-helper",
"version": "0.0.6",
"version": "0.0.7",
"homepage": "https://github.com/evanxd/bluetooth-helper",

@@ -5,0 +5,0 @@ "authors": [

@@ -1,2 +0,2 @@

/* global EventEmitter2 */
/* global Bluetooth, EventEmitter2 */
'use strict';

@@ -12,12 +12,6 @@

['writeCharacteristic', 'notifyCharacteristic'].forEach(function(item) {
Object.defineProperty(BluetoothDevice.prototype, item, {
set: function(value) {
this['_' + item] = value;
},
get: function() {
return this['_' + item];
}
});
});
BluetoothDevice.prototype.gatt = null;
BluetoothDevice.prototype.writeCharacteristic = null;
BluetoothDevice.prototype.notifyCharacteristic = null;
BluetoothDevice.prototype._isNotificationsStarted = false;

@@ -29,2 +23,30 @@ BluetoothDevice.prototype.send = function(data) {

BluetoothDevice.prototype.startNotifications = function() {
if (this._isNotificationsStarted) {
return;
} else {
this._isNotificationsStarted = true;
}
var characteristic = this.notifyCharacteristic;
this.gatt.addEventListener('characteristicchanged', (evt) => {
this.emit('data', evt.characteristic.value);
});
characteristic.startNotifications();
var descriptor = characteristic.descriptors.find(function(descriptor) {
return descriptor.uuid === Bluetooth.CCCD_UUID;
});
if (descriptor) {
var arrayBuffer = new ArrayBuffer(2);
var uint8Array = new Uint8Array(arrayBuffer);
uint8Array[0] = 0x01;
uint8Array[1] = 0x00;
descriptor.writeValue(arrayBuffer);
}
};
BluetoothDevice.prototype.stopNotifications = function() {
this._isNotificationsStarted = false;
this.notifyCharacteristic.stopNotifications();
};
BluetoothDevice.prototype._parseHexString = function(str) {

@@ -31,0 +53,0 @@ var arrayBuffer = new ArrayBuffer(Math.ceil(str.length / 2));

@@ -17,2 +17,3 @@ /* global BluetoothDevice */

BluetoothHelper.CONNECTING_TIMEOUT = 1000;
BluetoothHelper.prototype.CCCD_UUID = '00002902-0000-1000-8000-00805f9b34fb';

@@ -91,2 +92,3 @@ BluetoothHelper.prototype._scan = null;

// XXX: Workaround to connect multiple devices correctly.
devcie.gatt = gatt;
setTimeout(() => {

@@ -93,0 +95,0 @@ gatt.connect().then(() => {

{
"name": "bluetooth-helper",
"version": "0.0.6",
"version": "0.0.7",
"homepage": "https://github.com/evanxd/bluetooth-helper",

@@ -5,0 +5,0 @@ "authors": [

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