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.2 to 0.0.3

2

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

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

@@ -10,9 +10,5 @@ /* global EventEmitter2 */

function BluetoothHelper(options) {
if (options && (options.name || options.address)) {
this.name = options.name;
this.address = options.address;
bluetooth.addEventListener('attributechanged',
this._handleAttributechanged.bind(this));
}
function BluetoothHelper(name, address) {
this.name = name;
this.address = address;
}

@@ -45,12 +41,13 @@

BluetoothHelper.prototype.connect = function() {
return bluetooth.defaultAdapter.startDiscovery().catch(() => {
// Retry to connect the BLE server if failed.
this.connect();
}).then(discovery => {
discovery.addEventListener('devicefound',
this._handleDevicefound.bind(this));
}).catch(() => {
// Retry to connect the BLE server if failed.
this.connect();
});
if (bluetooth.defaultAdapter) {
return bluetooth.defaultAdapter.startDiscovery().then(discovery => {
discovery.addEventListener('devicefound',
this._handleDevicefound.bind(this));
}).catch(() => {
this.connect();
});
} else {
bluetooth.addEventListener('attributechanged',
this._handleAttributechanged.bind(this));
}
};

@@ -75,2 +72,4 @@

case 'defaultAdapter':
bluetooth.removeEventListener('attributechanged',
this._handleAttributechanged);
this.connect();

@@ -110,9 +109,4 @@ break;

});
if (this._notifyChar && Array.isArray(this._notifyChar.descriptors)) {
this.emit('connected');
this.isConnected = true;
} else {
// Retry to discover services if failed.
this._discoverServices();
}
this.emit('connected');
this.isConnected = true;
});

@@ -119,0 +113,0 @@ };

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

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

@@ -18,7 +18,8 @@ # bluetooth-helper

});
ble.connect();
```
### Send one byte data `EE` to BLE device.
### Send data to device after connected.
```js
ble.on('connected', function() {
// You need to send one byte or more data at one time.
// You need to send one byte or more data in HEX format at one time.
ble.send('EE');

@@ -25,0 +26,0 @@ });

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