New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bluetooth-serial-port

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluetooth-serial-port - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

90

lib/bluetooth-serial-port.js

@@ -36,7 +36,7 @@ /*

this.found = function (address, name) {
self.emit('found', address, name);
self.emit('found', address, name);
}
this.finish = function () {
self.emit('finished');
self.emit('finished');
}

@@ -149,3 +149,4 @@ }

_SERIAL_PORT_PROFILE_UUID = '1101',
_DEFAULT_SERVER_CHANNEL = 1;
_DEFAULT_SERVER_CHANNEL = 1,
_ERROR_CLIENT_CLOSED_CONNECTION = 'Error: Connection closed by the client';

@@ -165,4 +166,5 @@ /**

var _options = {};
if(errorCallback &&
typeof errorCallback !== 'function'){
typeof errorCallback !== 'function'){
_options = errorCallback;

@@ -172,2 +174,12 @@ errorCallback = null;

if(successCallback &&
typeof successCallback !== 'function'){
if(errorCallback)
errorCallback("successCallback must be a function!");
else
this.emit("failure", "successCallback must be a function!");
return;
}
options = options || _options;

@@ -177,38 +189,35 @@ options.uuid = options.uuid || _SERIAL_PORT_PROFILE_UUID;

var self = this,
read = function () {
process.nextTick(function () {
if (self.server) {
self.server.read(function (err, buffer) {
if (!err && buffer) {
self.emit('data', buffer);
} else {
self.close();
self.emit('failure', err);
}
});
}
});
},
server = new btSerial.BTSerialPortBindingServer(function (clientAddress) {
self.server = server;
self.on('data', function (buffer) {
if (buffer.length <= 0) {
// we are done reading. The remote device might have closed the device
// or we have closed it ourself. Lets cleanup our side anyway...
self.close();
} else {
read();
}
});
read();
successCallback(clientAddress);
}, function (err) {
// cleaning up the the failed connection
server.close();
var self = this;
var read = function () {
process.nextTick(function(){
if (self.server) {
self.server.read(function (err, buffer) {
if (!err && buffer) {
self.emit('data', buffer);
read();
}else if(err != _ERROR_CLIENT_CLOSED_CONNECTION){
self.emit('failure', err);
}else{
// The client closed the connection, this is not a failure
// so we trigger the event but the RFCOMM socket still can
// receive new connections
self.emit('closed');
}
});
}
});
};
var server = new btSerial.BTSerialPortBindingServer(function (clientAddress) {
self.server = server;
read();
successCallback(clientAddress);
}, function (err) {
// cleaning up the the failed connection
if(this.server)
this.server.close();
if (typeof errorCallback === 'function') {
errorCallback(err);
}
}, options);
if (typeof errorCallback === 'function') {
errorCallback(err);
}
}, options);
};

@@ -229,4 +238,2 @@

}
this.emit('closed');
};

@@ -238,2 +245,1 @@

}());
{
"name": "bluetooth-serial-port",
"version": "2.1.1",
"version": "2.1.2",
"description": "Bluetooth serial port communication for Node.js",

@@ -30,3 +30,3 @@ "author": "Eelco Cramer <eelco@hailendal.org>",

"dependencies": {
"bindings": "1.1.x",
"bindings": "1.2.x",
"nan": "latest"

@@ -33,0 +33,0 @@ },

@@ -12,3 +12,7 @@ # Bluetooth serial port communication for Node.js

* Fixes a segmentation fault that can occur on OSX
* `listen()` method will not exit until there's an explicit call to `close()`.
* If a client disconnects, `listen()` can still handle new connections.
* Calling `listen()` more than once is not allowed.
* Better error handling in the server part.
* New server and client test in the experiments folder

@@ -93,3 +97,3 @@ ## Pre-requests on Linux

## Basic server usage
## Basic server usage (only on Linux)

@@ -104,3 +108,3 @@ ```javascript

console.log('Client: ' + clientAddress + ' connected!');
server.on('data' function(buffer) {
server.on('data', function(buffer) {
console.log('Received data from client: ' + buffer);

@@ -112,3 +116,3 @@

server.write(new Buffer('...'), function (err, bytesWritten) {
if (error) {
if (err) {
console.log('Error!');

@@ -122,3 +126,3 @@ } else {

console.error("Something wrong happened!:" + error);
}, {uuid: UUID, channel: PORT} );
}, {uuid: UUID, channel: CHANNEL} );
```

@@ -125,0 +129,0 @@

## RELEASE NOTES
### 2.1.2
* `listen()` method will not exit until there's an explicit call to `close()`.
* If a client disconnects, `listen()` can still handle new connections.
* Calling `listen()` more than once is not allowed.
* Better error handling in the server part.
* New server and client test in the experiments folder
### 2.1.1

@@ -4,0 +12,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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