Giter Site home page Giter Site logo

eelcocramer / node-bluetooth-serial-port Goto Github PK

View Code? Open in Web Editor NEW
495.0 24.0 138.0 647 KB

Serial I/O over bluetooth for NodeJS

License: Other

Python 0.62% JavaScript 11.89% C++ 43.18% C 21.58% Objective-C++ 17.58% Objective-C 5.09% Dockerfile 0.08%
bluetooth-devices serial bluetooth nodejs javascript communication client server linux windows

node-bluetooth-serial-port's People

Contributors

againpsychox avatar alexssdc avatar atilag avatar barabas6river avatar barchard avatar bebraw avatar bmadzinski avatar dependabot[bot] avatar edsadr avatar eelcocramer avatar elundby45 avatar ericsmekens avatar ezfe avatar gavanderhoorn avatar imyller avatar joostverdoorn avatar kncs avatar langholz avatar meisterlampe avatar oukanina avatar programmarchy avatar sandangel avatar tillbaks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-bluetooth-serial-port's Issues

What is the behavior on power loss ?

Hello,

I am wondering what should be the behavior of the bluetooth-serial-port library when a device it is already paired with suffers a power loss.
From my experiments, the library returns an error on writing ("Write was unsuccessful") but is there a way to be more proactive, i.e. listening on a particular event emitted by the library ?
It seems that neither "closed" nor "failure" are emitted in this particular case...

How to make the bluetooth service visible

I'm trying to build a bluetooth serial bridge between two Macs using this library, but I can't seem to figure out how to make them talk to each other. I've tried just manually picking a channel (which I presume the OS is stopping) and trying to have each one scan the other for serial ports which lists the same services whether the other side is running or not. I'm wondering if that's just not built into this library right now or if I'v got something wrong in my setup.

My code for each side is here if you're interested

Not able to rebuild for node-webkit 0.9.2

I'm trying to rebuild bluetooth-serial-port for using in node-webkit on a Mac, but failed.
Following is the error message:

Andys-MacBook-Pro:bluetooth-serial-port andy$ nw-gyp rebuild --target=0.9.2
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/nw-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/andy/Documents/workspace/UserDefinedBezelGestures/desktop/app/node_modules/bluetooth-serial-port/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/nw-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/andy/.nw-gyp/0.9.2/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/andy/.nw-gyp/0.9.2',
gyp info spawn args   '-Dmodule_root_dir=/Users/andy/Documents/workspace/UserDefinedBezelGestures/desktop/app/node_modules/bluetooth-serial-port',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o
../src/osx/DeviceINQ.mm:79:55: error: cannot initialize a parameter of type
      'FunctionCallback' (aka 'void (*)(const FunctionCallbackInfo<v8::Value>
      &)') with an lvalue of type 'v8::Handle<v8::Value>
      (const v8::Arguments &)': type mismatch at 1st parameter ('const
      FunctionCallbackInfo<v8::Value> &' vs 'const v8::Arguments &')
    Local<FunctionTemplate> t = FunctionTemplate::New(New);
                                                      ^~~
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:3379:24: note: passing argument
      to parameter 'callback' here
      FunctionCallback callback = 0,
                       ^
../src/osx/DeviceINQ.mm:84:45: error: cannot initialize a parameter of type
      'v8::FunctionCallback' (aka 'void (*)(const
      FunctionCallbackInfo<v8::Value> &)') with an lvalue of type
      'v8::Handle<v8::Value> (const v8::Arguments &)': type mismatch at 1st
      parameter ('const FunctionCallbackInfo<v8::Value> &' vs
      'const v8::Arguments &')
    NODE_SET_PROTOTYPE_METHOD(t, "inquire", Inquire);
                                            ^~~~~~~
/Users/andy/.nw-gyp/0.9.2/src/node.h:187:60: note: passing argument to parameter
      'callback' here
                                      v8::FunctionCallback callback) {
                                                           ^
../src/osx/DeviceINQ.mm:85:59: error: cannot initialize a parameter of type
      'v8::FunctionCallback' (aka 'void (*)(const
      FunctionCallbackInfo<v8::Value> &)') with an lvalue of type
      'v8::Handle<v8::Value> (const v8::Arguments &)': type mismatch at 1st
      parameter ('const FunctionCallbackInfo<v8::Value> &' vs
      'const v8::Arguments &')
    NODE_SET_PROTOTYPE_METHOD(t, "findSerialPortChannel", SdpSearch);
                                                          ^~~~~~~~~
/Users/andy/.nw-gyp/0.9.2/src/node.h:187:60: note: passing argument to parameter
      'callback' here
                                      v8::FunctionCallback callback) {
                                                           ^
../src/osx/DeviceINQ.mm:86:55: error: cannot initialize a parameter of type
      'v8::FunctionCallback' (aka 'void (*)(const
      FunctionCallbackInfo<v8::Value> &)') with an lvalue of type
      'v8::Handle<v8::Value> (const v8::Arguments &)': type mismatch at 1st
      parameter ('const FunctionCallbackInfo<v8::Value> &' vs
      'const v8::Arguments &')
    NODE_SET_PROTOTYPE_METHOD(t, "listPairedDevices", ListPairedDevices);
                                                      ^~~~~~~~~~~~~~~~~
/Users/andy/.nw-gyp/0.9.2/src/node.h:187:60: note: passing argument to parameter
      'callback' here
                                      v8::FunctionCallback callback) {
                                                           ^
../src/osx/DeviceINQ.mm:238:81: error: conditional expression is ambiguous;
      'Local<v8::String>' can be converted to 'Handle<v8::Primitive>' and vice
      versa
  ...serviceObj->Set(String::NewSymbol("name"), [service getServiceName] ?
                                                                         ^
In file included from ../src/osx/DeviceINQ.mm:12:
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:481:5: error: assigning to
      'v8::Object *volatile' from incompatible type 'v8::Primitive *'
    TYPE_CHECK(O, Primitive);
    ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:182:37: note: expanded from macro
      'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:477:5: note: in instantiation of
      function template specialization
      'v8::NonCopyablePersistentTraits<v8::Function>::Uncompilable<v8::Object>'
      requested here
    Uncompilable<Object>();
    ^
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:5683:6: note: in instantiation of
      function template specialization
      'v8::NonCopyablePersistentTraits<v8::Function>::Copy<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >' requested here
  M::Copy(that, this);
     ^
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:550:5: note: in instantiation of
      function template specialization 'v8::Persistent<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >::Copy<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >' requested here
    Copy(that);
    ^
/Users/andy/.nw-gyp/0.9.2/deps/v8/include/v8.h:5650:3: note: in instantiation of
      member function 'v8::Persistent<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >::Persistent' requested
      here
  return New(Isolate::GetCurrent(), that.val_);
  ^
../src/osx/DeviceINQ.mm:184:39: note: in instantiation of function template
      specialization 'v8::Persistent<v8::Function,
      v8::NonCopyablePersistentTraits<v8::Function> >::New<v8::Function>'
      requested here
    baton->cb = Persistent<Function>::New(cb);
                                      ^
6 errors generated.
make: *** [Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/nw-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.3.0
gyp ERR! command "node" "/usr/local/bin/nw-gyp" "rebuild" "--target=0.9.2"
gyp ERR! cwd /Users/andy/Documents/workspace/UserDefinedBezelGestures/desktop/app/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.24
gyp ERR! nw-gyp -v v0.12.2
gyp ERR! not ok 

Unable to keep example running or discover devices

Hey there.

I am pretty new to messing with Bluetooth peripherals, but my initial experience with the provided example is that it exits immediately after running. I have prevented it from exiting by adding setInterval(function(){},10000);, but it still does not seem to be able to discover any devices. I've also tried setInterval(btSerial.inquire.bind(btSerial),10000); thinking it might need to inquire repeatedly, but this also hasn't helped.

Being that I am new to the concepts at hand, I assume there is something basic or general that I am missing or doing wrong. I am attempting this on a new MacBook Air with Mavericks that does have Bluetooth functioning properly. Using noble, I am able to discover and connect to the device in question which is a LightBlue Bean BLE Arduino device. While using provided software that allows you to connect to the Bean and put it in a Virtual Serial Port mode, I am able to use serialport to communicate with the device.

Is there something I'm missing or is this device possibly just not supported? Perhaps because of the BLE nature of it? I have also made sure that it is not already paired or connected with any other application. Any help or suggestions would be greatly appreciated.

Thanks,
Kevin

Node v0.11.13 gyp build issues on OSX 10.9.2

In trying to solve for some intermittent crashes I upgraded Node to 0.11.13. In doing this I removed node-bluetooth-serial-port and hit some issues on reinstall with gyp failures. Realize this is not a stable release of node, but thought I would raise this to let you guys see the issues.

In file included from ../src/osx/DeviceINQ.mm:18:
../src/DeviceINQ.h:33:35: error: unknown type name 'uv_work_t'
static void EIO_SdpSearch(uv_work_t req);
^
../src/DeviceINQ.h:34:40: error: unknown type name 'uv_work_t'
static void EIO_AfterSdpSearch(uv_work_t *req);
^
../src/DeviceINQ.h:39:13: error: unknown type name 'uv_work_t'
uv_work_t request;
^
../src/DeviceINQ.h:48:48: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handlev8::Value New(const v8::Arguments& args);
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/osx/DeviceINQ.mm:18:
../src/DeviceINQ.h:49:52: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handlev8::Value Inquire(const v8::Arguments& args);
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/osx/DeviceINQ.mm:18:
../src/DeviceINQ.h:50:54: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handlev8::Value SdpSearch(const v8::Arguments& args);
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/osx/DeviceINQ.mm:18:
../src/DeviceINQ.h:51:62: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handlev8::Value ListPairedDevices(const v8::Arguments& args);
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/osx/DeviceINQ.mm:45:31: error: unknown type name 'uv_work_t'
void DeviceINQ::EIO_SdpSearch(uv_work_t *req) {
^
../src/osx/DeviceINQ.mm:57:36: error: unknown type name 'uv_work_t'
void DeviceINQ::EIO_AfterSdpSearch(uv_work_t *req) {
^
../src/osx/DeviceINQ.mm:63:15: error: too few arguments to function call, expected 2, have 1; did you mean '::DeviceINQ::New'?
argv[0] = Integer::New(baton->channelID);
^~~~~~~~~~~~
::DeviceINQ::New
../src/DeviceINQ.h:48:38: note: '::DeviceINQ::New' declared here
static v8::Handlev8::Value New(const v8::Arguments& args);
^
../src/osx/DeviceINQ.mm:64:14: error: member reference type 'v8::Persistentv8::Function' is not a pointer; maybe you meant to use '.'?
baton->cb->Call(Context::GetCurrent()->Global(), 1, argv);
~~~~~~~~~^~
.
../src/osx/DeviceINQ.mm:64:16: error: no member named 'Call' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraitsv8::Function >'
baton->cb->Call(Context::GetCurrent()->Global(), 1, argv);
~~~~~~~~~ ^
../src/osx/DeviceINQ.mm:64:30: error: no member named 'GetCurrent' in 'v8::Context'
baton->cb->Call(Context::GetCurrent()->Global(), 1, argv);
~~~~~~~~~^
../src/osx/DeviceINQ.mm:70:5: error: cannot initialize object parameter of type 'node::ObjectWrap' with an expression of type 'DeviceINQ'
baton->inquire->Unref();
^~~~~~~~~~~~~~
../src/osx/DeviceINQ.mm:71:15: error: no member named 'Dispose' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraitsv8::Function >'
baton->cb.Dispose();
~~~~~~~~~ ^
../src/osx/DeviceINQ.mm:77:17: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:845:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/osx/DeviceINQ.mm:79:55: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type 'v8::Handlev8::Value (const v8::internal::Arguments &)'
Local t = FunctionTemplate::New(New);
^~~
/Users/trevormurphy/.node-gyp/0.11.13/deps/v8/include/v8.h:3520:16: note: passing argument to parameter 'isolate' here
Isolate
isolate,
^
../src/osx/DeviceINQ.mm:82:29: error: no member named 'NewSymbol' in 'v8::String'
t->SetClassName(String::NewSymbol("DeviceINQ"));
~~~~~~~~^
../src/osx/DeviceINQ.mm:84:45: error: cannot initialize a parameter of type 'v8::FunctionCallback' (aka 'void (*)(const FunctionCallbackInfov8::Value &)') with an lvalue of type
'v8::Handlev8::Value (const v8::internal::Arguments &)': type mismatch at 1st parameter ('const FunctionCallbackInfov8::Value &' vs 'const v8::internal::Arguments &')
NODE_SET_PROTOTYPE_METHOD(t, "inquire", Inquire);
^~~~~~~
/Users/trevormurphy/.node-gyp/0.11.13/src/node.h:212:60: note: passing argument to parameter 'callback' here
v8::FunctionCallback callback) {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Multiple concurrent connections

Can multiple connections be made with the library to multiple devices? That is, any reason I can't have a collection of BluetoothSerialPort objects?

Can't connect with an HC-06 Bluetooth module

Hi everyone,

I'm trying to connect to an HC-06 module connected to my Arduino Yùn using this library. I am writing a program on my computer which will communicate with the Arduino through the Bluetooth HC-06.

The find() method of the library does its job very well: it finds the device named "HC-06" with its mac address, and it also finds the channel with the findSerialPortChannel() method.

Where things go wrong is when I use the connect(address, channel, callback) method, I always have "can't connect" as a response.

I don't know where I am doing something wrong...

Here, the code I use to connect:

var BTSP = require('bluetooth-serial-port');
var serial = new BTSP.BluetoothSerialPort(); 

serial.on('found', function(address, name) {
    logger.debug('found ', address, ' & name : ', name);
    // you might want to check the found address with the address of your
    // bluetooth enabled Arduino device here.
    if (name === 'HC-06') {
        serial.findSerialPortChannel(address, function(channel) {
            serial.connect(address, channel, function() {
                console.log('connected');
                process.stdin.resume();
                process.stdin.setEncoding('utf8');
                console.log('Press "1" or "0" and "ENTER" to turn on or off the light.')

                process.stdin.on('data', function (data) {
                    serial.write(data);
                });

                serial.on('data', function(data) {
                    console.log('Received: ' + data);
                });
            }, function () {
                    console.log('cannot connect');
            });
        });
    }
});

serial.inquire(); 

and the output I have:

$ node bin/arduino.js 
2015-03-18T19:28:17 <debug> arduino.js:21 (BluetoothSerialPort.<anonymous>) found  54:27:1E:AC:0E:A0  & name :  Bluetooth USB Host Controller
2015-03-18T19:28:18 <debug> arduino.js:21 (BluetoothSerialPort.<anonymous>) found  20:13:11:01:26:71  & name :  HC-06
cannot connect

Leaking Socket / Pipe on Linux?

Hi. Thank you for providing this really useful library to node js. I am running on Raspberry PI (Raspbian). It looks like there may be sockets / pipes leaking. I am creating a service that periodically attempts to connect to a bluetooth device. After running for a while, it starts to fail on connect (with an uncaught exception):

Error: Cannot create pipe for reading.
    at BluetoothSerialPort.connect (/home/pi/node_modules/bluetooth-serial-port/lib/bluetooth-serial-port.js:81:26)
    at tryConnect (/home/pi/repositories/nodeGateway/test/leak.js:20:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

If you run the code below and check the file descriptors (FDs) owned by the process, you will see that each new connection attempt appears to be creating 3 FDs: 1 socket and 2 pipes (using ls -l /proc//fd). Three new FDs are created for each connection attempt and the previous attempt's FDs do not seem to be getting released. Continue running it until 1024 FDs are consumed to get the error. I am by no means a linux expert so I might not be interpreting these results correctly. Perhaps there is something I am doing incorrectly?

var BtSerial = require('bluetooth-serial-port');

var args = process.argv.slice(2);
var bdAddr = args[0];
var channel = args[1];

process.on('uncaughtException', function (error) {
    console.log(error.stack);
    process.exit(1);
});

var btSerial = new BtSerial.BluetoothSerialPort();

function tryConnect() {

    console.log('Connecting...');

    btSerial.connect(bdAddr, channel,
        function () {
            console.log('Connected');
            btSerial.close();
            setTimeout(tryConnect, 1000);
        },
        function () {
            console.log('Connect failed');
            btSerial.close();
            setTimeout(tryConnect, 1000);
        });

}

tryConnect();

NOTE: It does not seem to matter if a new BluetoothSerialPort is created for each connection attempt, or if a single BluetoothSerialPort is used for all connection attempts (as shown above).

Thank you again for providing this useful project.

Unable to install on OSX yosemite

Hello,

I'm trying to install bluetooth-serial-port on OSX yosemite, it currently fails.

This seems related to a (not so) recent Apple API modification:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63651

Here is an excerpt of the npm output (quite long):

10:40 $ LANG=C npm install bluetooth-serial-port
/

[email protected] install /Users/del/dev/telecom_sante/bed-control-panel/backend/node_modules/bluetooth-serial-port
node-gyp configure build

CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6:0,
from ../src/osx/DeviceINQ.mm:36:
/usr/include/objc/NSObject.h:22:4: error: 'instancetype' does not name a type

  • (instancetype)self;
    ^
    /usr/include/objc/NSObject.h:36:4: error: 'instancetype' does not name a type
  • (instancetype)retain OBJC_ARC_UNAVAILABLE;
    ^
    /usr/include/objc/NSObject.h:38:4: error: 'instancetype' does not name a type
  • (instancetype)autorelease OBJC_ARC_UNAVAILABLE;
    ^

.... LOTS OF ERRORS AND WARNINGS ....

In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:55:0,
from /System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:12,
from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80,
from /System/Library/Frameworks/IOBluetooth.framework/Headers/IOBluetoothUserLib.h:10,
from /System/Library/Frameworks/IOBluetooth.framework/Headers/objc/IOBluetoothDevice.h:9,
from ../src/osx/DeviceINQ.mm:37:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:414:89: error: expected unqualified-id before '=' token
kFSEventStreamEventFlagItemCreated __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_6_0) = 0x00000100,
^
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:481:1: error: expected declaration before '}' token
};
^
make: *** [Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/del/.nave/installed/0.10.38/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/Users/del/.nave/installed/0.10.38/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/del/dev/telecom_sante/bed-control-panel/backend/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.38
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.1.0
npm ERR! command "/Users/del/.nave/installed/ts/bin/node" "/Users/del/.nave/installed/ts/bin/npm" "install" "bluetooth-serial-port"
npm ERR! cwd /Users/del/dev/telecom_sante/bed-control-panel/backend
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

Bluetooth listener

Hello,
I'm working with a RPi and I would like it to listen for connecting devices so they can send data to it. I haven't worked with Bluetooth before so I'm kind of lost.

My desired workflow is the following:

  1. Server starts and listen for bluetooth connections (makes itself discoverable).
  2. Bluetooth enabled device enters server bluetooth range and sees it.
  3. Device connects to server.
  4. Device sends data to server.

I would really appreciate if you could help me with this.

Why is BluetoothWorker a singleton?

I think some of the performance issues (and perhaps stability ones) resolve around the BluetoothWorker singleton and all the locking it's trying to do. Any reason why it isn't a simpler instance-per-address or instance-per-nodejs-instance model? The pipe stuff looks to be contained inside the worker so that seems fine...

Data getting combined incorrectly?

I'm using your wonderful library on OS X. I have a device which likes to send data in 256-byte or less chunks. I added an NSLog to the rfcommChannelData selector in the native side and I see these events:

2014-11-26 23:56:59.954 node[40679:338053] Received 258 from device
2014-11-26 23:57:00.013 node[40679:338053] Received 258 from device
2014-11-26 23:57:00.014 node[40679:338053] Received 156 from device

But in my data handler in node I see:
[2014-11-27 04:57:00.014 UTC] - verbose: [40679:lib/stuff.js] Received 258 bytes
[2014-11-27 04:57:00.014 UTC] - verbose: [40679:lib/stuff.js] Received 414 bytes

And the last 156 bytes of packet #2 appear to be garbage. Ideas? Could be me somehow, but not entirely sure how.

Install Failling on Linux (Ubuntu/Debian) gyp

Hey guys, it sounds like this could be a similar issue to what the other platforms are having. Using Ubuntu 14.04, I've installed the libbluetooth-dev package mentioned as a prereq, but the install is failing. Python and gcc are both available on the system and in the PATH.

~$ npm install bluetooth-serial-port

npm http GET https://registry.npmjs.org/bluetooth-serial-port
npm http 304 https://registry.npmjs.org/bluetooth-serial-port
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

> [email protected] install /var/www/net-log/node_modules/bluetooth-serial-port
> node-gyp configure build

Usage: gyp_main.py [options ...] [build_file ...]

gyp_main.py: error: no such option: --no-parallel
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onCpExit (/home/seth/opt/node-v0.11.13-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1046:12)
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "node" "/home/seth/opt/node-v0.11.13-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /var/www/net-log/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.11.13
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.13.0-24-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "bluetooth-serial-port"
npm ERR! cwd /var/www/net-log
npm ERR! node -v v0.11.13
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/www/net-log/npm-debug.log
npm ERR! not ok code 0

I'm not familiar with gyp but I tried to get a version number for it, but it didn't have one. I did gyp --help and it seems like it has a --parallel option, but no --no-parallel. Is it non-parallel by default?

Is there anything I can try?

Thanks, -Seth

Exception on device disconnect?

I was happily running with multiple devices and then turned off one of them. I got an exception:

Error: connection has been closed
    at eval (/dev/node/node-bluetooth-serial-port/lib/bluetooth-serial-port.js:70:41)
    at process._tickCallback (node.js:351:13)
    at process._tickFromSpinner (node.js:326:15)

OSX findSerialPortChannel errors

Hi there,
OSX support seems to be working well except for one issue. The first time I can findSerialPortChannel, it correctly returned 1. However since connecting to the device once, all subsequent attempts have not only fired the errorCallback, but no parameter was included in that callback (i.e the parameter was undefined ).

I've been able to bypass this issue by manually setting the channel, rather than using findSerialPortChannel.

I'm running osX mavericks, node v0.10.29, and the latest node-bluetooth-serial-port.

btw, really really useful library, I'm so glad it already existed, would have hated to try and write it myself, in the limited time I have.

continuous scanning

In the app I am working on we have devices coming in and out of range. We'd like to scan continuously and allow duplicates (ie. a device returning to range). Is that possible with this module?

Thx. Paul

Does this support OSX mavericks?

Specifically with the mac's built in bluetooth, trying to connect to another macbook and having trouble finding the device. Do I need to get an external bluetooth device, or am I just going about this completely wrong? I'm trying to run the Basic Usage example from the terminal and It just hangs. I've got three other bluetooth devices in the area that it could connect to.

I'm not able to...

Hi,
i'm trying to use node-bluetooth-serial-port, but i'm not able to work it. My idea is to connect two devices (2 laptops with BT 4.0 usb adapter on linux) but just trying to use your example code, i'm not able. Could anyone help me?
Thanks in advance

Trying to reconnect when serial port is down causes Crash

Simple enough to reproduce on OSX, just do have your rfcomm server DOWN.
The try to connect, handle the exception and try again. Normally this fails after second or third retry, sometimes on first.

Exceptions cause app the crash and disappear. Every now and then I get lucky and get a stack trace.

2014-11-26 00:14:22.300 node-webkit Helper[1461:507] -[NSEvent unregisterForServiceRemovalNotification]: unrecognized selector sent to instance 0x7bf83fe0
2014-11-26 00:14:22.300 node-webkit Helper[1461:507] An uncaught exception was raised
2014-11-26 00:14:22.301 node-webkit Helper[1461:507] -[NSEvent unregisterForServiceRemovalNotification]: unrecognized selector sent to instance 0x7bf83fe0
2014-11-26 00:14:22.381 node-webkit Helper[1461:507](0 CoreFoundation 0x991ad471 __raiseError + 193
1 libobjc.A.dylib 0x9b2f6091 objc_exception_throw + 162
2 CoreFoundation 0x991b1cb3 -[NSObject%28NSObject%29 doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x990fd522 forwarding + 1010
4 CoreFoundation 0x990fd10e _CF_forwarding_prep_0 + 14
5 IOBluetooth 0x95e97386 -[IOBluetoothObject setIOService:] + 92
6 IOBluetooth 0x95ebeed5 -[IOBluetoothObject ioServiceTerminated:] + 47
7 IOBluetooth 0x95ea9947 -[IOBluetoothRFCOMMChannel ioServiceTerminated:] + 58
8 IOBluetooth 0x95ebee8c IOBluetoothObjectServiceTerminated + 106
9 IOKit 0x949749b6 IODispatchCalloutFromCFMessage + 237
10 IOKit 0x94974aad _IODispatchCalloutWithDispatch + 42
11 libdispatch.dylib 0x9a8245f2 dispatch_mig_server + 381
12 IOKit 0x94974b99 __IONotificationPortSetDispatchQueue_block_invoke + 47
13 libdispatch.dylib 0x9a81b386 _dispatch_client_callout + 50
14 libdispatch.dylib 0x9a822ddf _dispatch_source_latch_and_call + 150
15 libdispatch.dylib 0x9a81dcf8 _dispatch_source_invoke + 422
16 libdispatch.dylib 0x9a823a24 _dispatch_main_queue_callback_4CF + 207
17 CoreFoundation 0x99106fae CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 14
18 CoreFoundation 0x990be3c9 __CFRunLoopRun + 1897
19 CoreFoundation 0x990bd9ea CFRunLoopRunSpecific + 394
20 CoreFoundation 0x990bd84b CFRunLoopRunInMode + 123
21 HIToolbox 0x99d85b5d RunCurrentEventLoopInMode + 259
22 HIToolbox 0x99d858e2 ReceiveNextEventCommon + 526
23 HIToolbox 0x99d856bd _BlockUntilNextEventMatchingListInModeWithFilter + 92
24 AppKit 0x90def349 _DPSNextEvent + 1602
25 AppKit 0x90dee870 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 119
26 node-webkit Framework 0x00abc20e _ZN2v86Locker14StopPreemptionEv + 8486030
27 node-webkit Framework 0x00abb7fc _ZN2v86Locker14StopPreemptionEv + 8483452
28 node-webkit Framework 0x00af9172 _ZN2v86Locker14StopPreemptionEv + 8735730
29 node-webkit Framework 0x00b1375e _ZN2v86Locker14StopPreemptionEv + 8843742
30 node-webkit Framework 0x00af8b4a _ZN2v86Locker14StopPreemptionEv + 8734154
31 node-webkit Framework 0x01c3fcb3 ares_send + 1445395
32 node-webkit Framework 0x009a2419 _ZN2v86Locker14StopPreemptionEv + 7331481
33 node-webkit Framework 0x009a3233 _ZN2v86Locker14StopPreemptionEv + 7335091
34 node-webkit Framework 0x009a2180 _ZN2v86Locker14StopPreemptionEv + 7330816
35 node-webkit Framework 0x0002c409 ContentMain + 41
36 node-webkit Helper 0x00028f75 node-webkit Helper + 3957)
2014-11-26 00:14:22.383 node-webkit Helper[1461:507] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSEvent unregisterForServiceRemovalNotification]: unrecognized selector sent to instance 0x7bf83fe0'
*** Call stack at first throw:
(
0 CoreFoundation 0x991ad471 raiseError + 193
1 libobjc.A.dylib 0x9b2f6091 objc_exception_throw + 162
2 CoreFoundation 0x991b1cb3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x990fd522 __forwarding
+ 1010
4 CoreFoundation 0x990fd10e _CF_forwarding_prep_0 + 14
5 IOBluetooth 0x95e97386 -[IOBluetoothObject setIOService:] + 92
6 IOBluetooth 0x95ebeed5 -[IOBluetoothObject ioServiceTerminated:] + 47
7 IOBluetooth 0x95ea9947 -[IOBluetoothRFCOMMChannel ioServiceTerminated:] + 58
8 IOBluetooth 0x95ebee8c IOBluetoothObjectServiceTerminated + 106
9 IOKit 0x949749b6 IODispatchCalloutFromCFMessage + 237
10 IOKit 0x94974aad _IODispatchCalloutWithDispatch + 42
11 libdispatch.dylib 0x9a8245f2 dispatch_mig_server + 381
12 IOKit 0x94974b99 __IONotificationPortSetDispatchQueue_block_invoke + 47
13 libdispatch.dylib 0x9a81b386 _dispatch_client_callout + 50
14 libdispatch.dylib 0x9a822ddf _dispatch_source_latch_and_call + 150
15 libdispatch.dylib 0x9a81dcf8 _dispatch_source_invoke + 422
16 libdispatch.dylib 0x9a823a24 _dispatch_main_queue_callback_4CF + 207
17 CoreFoundation 0x99106fae CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 14
18 CoreFoundation 0x990be3c9 __CFRunLoopRun + 1897
19 CoreFoundation 0x990bd9ea CFRunLoopRunSpecific + 394
20 CoreFoundation 0x990bd84b CFRunLoopRunInMode + 123
21 HIToolbox 0x99d85b5d RunCurrentEventLoopInMode + 259
22 HIToolbox 0x99d858e2 ReceiveNextEventCommon + 526
23 HIToolbox 0x99d856bd _BlockUntilNextEventMatchingListInModeWithFilter + 92
24 AppKit 0x90def349 _DPSNextEvent + 1602
25 AppKit 0x90dee870 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 119
26 node-webkit Framework 0x00abc20e _ZN2v86Locker14StopPreemptionEv + 8486030
27 node-webkit Framework 0x00abb7fc _ZN2v86Locker14StopPreemptionEv + 8483452
28 node-webkit Framework 0x00af9172 _ZN2v86Locker14StopPreemptionEv + 8735730
29 node-webkit Framework 0x00b1375e _ZN2v86Locker14StopPreemptionEv + 8843742
30 node-webkit Framework 0x00af8b4a _ZN2v86Locker14StopPreemptionEv + 8734154
31 node-webkit Framework 0x01c3fcb3 ares_send + 1445395
32 node-webkit Framework 0x009a2419 _ZN2v86Locker14StopPreemptionEv + 7331481
33 node-webkit Framework 0x009a3233 _ZN2v86Locker14StopPreemptionEv + 7335091
34 node-webkit Framework 0x009a2180 _ZN2v86Locker14StopPreemptionEv + 7330816
35 node-webkit Framework 0x0002c409 ContentMain + 41
36 node-webkit Helper 0x00028f75 node-webkit Helper + 3957

Writing lag on OSX

Hey there.

I've been using your software recently to relay commands from a ps3 controller to an Arduino-based robot. It works really well, except that it takes 250ms to write data to the Arduino's bluetooth. For a robot which needs quick moment-to-moment controls, this is quite unwieldy.

When the write command is called for the first time, it can take as few as 10ms to summon its callback. Within two or three calls, however, it slows to exactly 250ms. I've checked that the ps3-parser I wrote is serving data fast enough and that the Arduino is reading data fast enough; both systems perform in the <20ms range. I've put together a minimal test case which you can see here: https://gist.github.com/mindoftea/ac6ca90687e0f1c10d0f.

Do you know why this might be happening? I wondered if it might be an OSX-specific issue, but I don't have another machine to test it on.

Thanks!

Segfault in `read` during GC

I think I've identified a segfault occurring in the EIO_AfterRead in BTSerialPortBinding.cc/.mm, during a garbage collection event. I was noticing crashes after reading data consistently from my Bluetooth device after about 30 minutes or so. After inspecting the crash log, I was able to narrow it down to the following lines:

void BTSerialPortBinding::EIO_AfterRead(uv_work_t *req) {
    read_baton_t *baton = static_cast<read_baton_t *>(req->data);

    TryCatch try_catch;

    Handle<Value> argv[2];

    if (baton->size < 0) {
        argv[0] = Exception::Error(String::New("Error reading from connection"));
        argv[1] = Undefined();
    } else {
        Buffer *buffer = Buffer::New(baton->size);
        memcpy_s(Buffer::Data(buffer), baton->size, baton->result, baton->size);
        Local<Object> globalObj = Context::GetCurrent()->Global();
        Local<Function> bufferConstructor = Local<Function>::Cast(globalObj->Get(String::New("Buffer")));
        Handle<Value> constructorArgs[3] = { buffer->handle_, Integer::New(baton->size), Integer::New(0) };
        Local<Object> resultBuffer = bufferConstructor->NewInstance(3, constructorArgs); // <---- Segfault occurring here: access violation (0xC0000005)

        argv[0] = Undefined();
        argv[1] = resultBuffer;
    }

    baton->cb->Call(Context::GetCurrent()->Global(), 2, argv);
    ...

What I believe is happening, is that the GC fires some time after Buffer::New, and before the line of the crash. Specifically, the handle_ property in buffer->handle_ is being invalidated by the GC, and then when trying to use that handle as the constructor argument, the segfault occurs.

I've been able to resolve this issue by following a workaround found online:

void BTSerialPortBinding::EIO_AfterRead(uv_work_t *req) {
    read_baton_t *baton = static_cast<read_baton_t *>(req->data);

    TryCatch try_catch;

    Handle<Value> argv[2];

    if (baton->size < 0) {
        argv[0] = Exception::Error(String::New("Error reading from connection"));
        argv[1] = Undefined();
    } else {
        Local<Object> globalObj = Context::GetCurrent()->Global();
        Local<Function> bufferConstructor = Local<Function>::Cast(globalObj->Get(String::New("Buffer")));
        Handle<Value> constructorArgs[1] = { Integer::New(baton->size) };
        Local<Object> resultBuffer = bufferConstructor->NewInstance(1, constructorArgs);
        memcpy(node::Buffer::Data(resultBuffer), baton->result, baton->size);
        argv[0] = Undefined();
        argv[1] = resultBuffer;
    }

    baton->cb->Call(Context::GetCurrent()->Global(), 2, argv);
    ...

Based on my preliminary testing, this seems to work. However, a tradeoff is being made here, I believe: which is the patched version is using a "slow buffer" where the previous version was using a "fast buffer".

A related issue has been posted on node core repo here: nodejs/node-v0.x-archive#5864

The workaround posted by Jonathan Wiepert here: http://www.samcday.com.au/blog/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/

Pull request forthcoming, but curious to hear any thoughts or better solutions to this problem.

Failed install on Mac

I get the following error when running install

npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/bluetooth-serial-port
npm http 304 https://registry.npmjs.org/bluetooth-serial-port
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

> [email protected] install /Users/facultymatt/Sites/labs/bluetooth/node_modules/bluetooth-serial-port
> node-gyp configure build

make: Entering directory `/Users/facultymatt/Sites/labs/bluetooth/node_modules/bluetooth-serial-port/build'
  CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:161,
                 from /System/Library/Frameworks/IOBluetooth.framework/Headers/objc/IOBluetoothRFCOMMChannel.h:6,
                 from ../src/osx/BluetoothWorker.h:16,
                 from ../src/osx/DeviceINQ.mm:36:
/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:16: error: expected `}' before '__attribute__'
/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:16: error: expected unqualified-id before '=' token
/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:17: error: expected declaration before '}' token
make: *** [Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o] Error 1
make: Leaving directory `/Users/facultymatt/Sites/labs/bluetooth/node_modules/bluetooth-serial-port/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/facultymatt/Sites/labs/bluetooth/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "bluetooth-serial-port"
npm ERR! cwd /Users/facultymatt/Sites/labs/bluetooth
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/facultymatt/Sites/labs/bluetooth/npm-debug.log
npm ERR! not ok code 0

Interestingly I get the same error when trying to install https://github.com/sandeepmistry/noble.

Connecting to multiple devices at once

Hi,

I'm having trouble connecting to multiple devices at once. Is that supported? I'm using a new instance of bluetooth-serial-port each time, and still no luck.

In any case, thanks for creating this, it's great to have rfcomm directly from Node.

Best,
Greg

not building on ubuntu 14.04

bluetooth libraries are installed

Now using node v0.10.29
bmiller@bmiller-Latitude-E7440:~$ sudo apt-get install libbluetooth-dev
[sudo] password for bmiller:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libbluetooth-dev is already the newest version.

bmiller@bmiller-Latitude-E7440:~/git/test$ npm install bluetooth-serial-port

[email protected] install /home/bmiller/git/test/node_modules/bluetooth-serial-port
node-gyp configure build

make: Entering directory /home/bmiller/git/test/node_modules/bluetooth-serial-port/build' CXX(target) Release/obj.target/BluetoothSerialPort/src/linux/BluetoothSerialPort.o make: g++: Command not found make: *** [Release/obj.target/BluetoothSerialPort/src/linux/BluetoothSerialPort.o] Error 127 make: Leaving directory/home/bmiller/git/test/node_modules/bluetooth-serial-port/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/bmiller/.nvm/v0.10.29/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 3.13.0-34-generic
gyp ERR! command "node" "/home/bmiller/.nvm/v0.10.29/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /home/bmiller/git/test/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.13.0-34-generic
npm ERR! command "/home/bmiller/.nvm/v0.10.29/bin/node" "/home/bmiller/.nvm/v0.10.29/bin/npm" "install" "bluetooth-serial-port"
npm ERR! cwd /home/bmiller/git/test
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/bmiller/git/test/npm-debug.log
npm ERR! not ok code 0

Could not locate the bindings file

hi,

i'm trying to use the lib on my computer;
i use ubuntu precise
i installed libbluetooth-dev;
then the npm install went correctly but when i run the test script i got this:

.../uploader/node_modules/bluetooth-serial-port/node_modules/bindings/bindings.js:91
throw err
^
Error: Could not locate the bindings file. Tried:
→ (...)/uploader/node_modules/bluetooth-serial-port/build/BluetoothSerialPort.node
→ (...)/uploader/node_modules/bluetooth-serial-port/build/Debug/BluetoothSerialPort.node
(....) -> more locations here
at bindings (/media/data/Dropbox/dev/2012-ruches/openbeelab/uploader/node_modules/bluetooth-serial-port/node_modules/bindings/bindings.js:88:9)
at /media/data/Dropbox/dev/2012-ruches/openbeelab/uploader/node_modules/bluetooth-serial-port/lib/bluetooth-serial-port.js:16:39
at Object. (/media/data/Dropbox/dev/2012-ruches/openbeelab/uploader/node_modules/bluetooth-serial-port/lib/bluetooth-serial-port.js:112:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/media/data/Dropbox/dev/2012-ruches/openbeelab/uploader/uploader_module/test.js:1:83)

ps: i used (...) to shorten file urls and stack trace.

what should i do to make it work?
thanks for any reply!
cheers
remy

Windows 8.1 Pro with Visual Studio Express 2013

Problem installing on a windows8 machine, python and VS installed.

npm install fails during node-gyp build phase when linking.
LINK: fatal error LNK1104 cannot open file 'LIBCMT.lib'

Using VS Express 2013, on a brand new Windows 8.1 pro machine with windows SDK installed ( to resolve earlier issue with missing headers )

Also, once this is resolved, any help on which binaries need to be included into a distribution package would be appreciated also.

Help appreciated :)

Is there SDP support?

Hi all,

Sorry that I'm new to bluetooth.

Is node-blue-serial-port for RFCOMM?

Is there SDP support?

Communication

Hello,
I have some problems about setting bluetooth communication between two VM Linux, in 2 different pc, using bluetooth-serial-port. In particular I need to connect these 2 machine and send data.
Referring to the issue #14, I have the same trouble.
For this reason I activated a Serial Port service, using sdptool, then using this channel I tried to connect 2 devices but not always work.

Suppose that I'm able to connect two system, How can I send data from one to the second? I know, I can use "write" method on the sender, but what about the receiver? How I can run a piece of code in the receiver to listen for input data?

thanks in advance
Ignazio

Failed Install (Windows)

Hey there, I am getting errors when I try and run npm install bluetooth-serial-port.

I have Python 2.7 and I installed Visual Studio 2013 but I wasn't sure exactly how the prerequisite works for that.

The cmd line error report says a lot of stuff, including this.

Failed at the [email protected] install script.
Tell the author that this fails on your system:
node-gyp configure build

This is the start of the npm debug log.

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files (x86)\nodejs\node.exe',
1 verbose cli 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'bluetooth-serial-port' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink C:\Program Files (x86)\nodejs\node.exe
5 verbose cache add [ 'bluetooth-serial-port', null ]
6 verbose cache add name=undefined spec="bluetooth-serial-port" args=["bluetooth-serial-port",null]

etc...

BluetoothSerialPort on RaspberryPi

Hello, I trying to use this library but have not been successful in my raspberry pi.
I was able to install all right but when I run the app nodejs fails, the error seems to be when running BluetoothSerialPort.inquire

 Error: opening socket
    at BluetoothSerialPort.inquire (.../node_modules/bluetooth-serial-port/lib/bluetooth-serial-port.js:44:18)
    at Object.<anonymous> (.../server.js:24:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

Someone else has tried to use this library on a raspberry pi?

Regards! (sorry for the English)

serialbluetooth.on('data', buffer) cuts the incoming string

Hi there!
First I want to thank you for your great work! :) It works like a charm.

Except I'm having some trouble with the on data event.

my code is as follow:

serial.connect(address, channel, function() {
    console.log('Connected. Receiving data...');
    serial.on('data', function(buffer) {
        console.log("New incoming string");
        var buf = buffer.toString('utf-8');
        console.log("String = " + buf);
});

It should look like this:

New incoming string
String = { "accel":{"x":76,"y":-2,"z":217},"gyro":{"yaw":109,"pitch":19,"roll":0}}

And this is what I get:

New incoming string
String = {
New incoming string
String = "accel":{"x":76,"y":-2,"z":217},"gyro":{"yaw":109,"pitch":19,"roll":0
New incoming string
String = }}

Do you have any idea of what I'm doing wrong?

Crash in node-webkit on osx

Not sure what to look for here, but the library seems to cause a crash (often when closing):

Process: node-webkit Helper [40922]
Path: /Users/USER/*/node-webkit.app/Contents/Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper
Identifier: com.intel.nw.helper
Version: 30.0.1599.66 (1599.66)
Code Type: X86 (Native)
Parent Process: node-webkit [40894]
Responsible: iTerm [496]
User ID: 110069666

Date/Time: 2014-12-18 17:27:08.460 -0500
OS Version: Mac OS X 10.10 (14A389)
Report Version: 11
Anonymous UUID: 8DE39E2A-DC5B-CE1F-5A71-87D08FC54021

Sleep/Wake UUID: F44C0C0C-7591-4C25-A943-AD2904649534

Time Awake Since Boot: 250000 seconds
Time Since Wake: 200000 seconds

Crashed Thread: 0 CrRendererMain Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000011

VM Regions Near 0x11:
-->
__TEXT 0000000000070000-0000000000071000 [ 4K] r-x/rwx SM=COW /Users/USER/*/node-webkit.app/Contents/Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper

Thread 0 Crashed:: CrRendererMain Dispatch queue: com.apple.main-thread
0 ??? 0x2621823f 0 + 639730239
1 ??? 0x2620e8aa 0 + 639690922
2 node-webkit Framework 0x000f1885 0x73000 + 518277
3 node-webkit Framework 0x000f1a64 0x73000 + 518756
4 node-webkit Framework 0x0008b158 v8::Function::NewInstance(int, v8::Handlev8::Value_) const + 424
5 BluetoothSerialPort.node 0x08166483 BTSerialPortBinding::EIO_AfterRead(uv_work_s_) + 197 (BTSerialPortBinding.mm:183)

npm install gyp build error

Hey guys, I try to run npm install bluetooth-serial-port in windows 7(64bit) command line.
Then throw this error message:

PS E:\study\ble-light> npm install bluetooth-serial-port npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data

[email protected] install E:\study\ble-light\node_modules\bluetooth-serial-port
node-gyp configure build
E:\study\ble-light\node_modules\bluetooth-serial-port>node "D:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" configure build
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
BluetoothSerialPort.cc
DeviceINQ.cc
BTSerialPortBinding.cc
BluetoothHelpers.cc
C:\Users\win7.node-gyp\0.10.32\deps\v8\include\v8.h(218): warning C4506: no definition for inline function 'v8::Persistent v8::Persistent::New(v8::Handle)' [E:\study\ble-light\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
with
[
T=v8::Object
]
C:\Users\win7.node-gyp\0.10.32\deps\v8\include\v8.h(218): warning C4506: no definition for inline function 'v8::Persistent v8::Persistent::New(v8::Handle)' [E:\study\ble-light\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
with
[
T=v8::Object
]
C:\Users\win7.node-gyp\0.10.32\deps\v8\include\v8.h(179): warning C4506: no definition for inline function 'v8::Persistent v8::Persistent::New(v8::Handle)' [E:\study\ble-light\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
with
[
T=v8::Object
]
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [E:\study\ble-light\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "build"
gyp ERR! cwd E:\study\ble-light\node_modules\bluetooth-serial-port
gyp ERR! node -v v0.10.32
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok


npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "D:\Program Files\nodejs\node.exe" "D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "bluetooth-seri
npm ERR! cwd E:\study\ble-light
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

Can somebody give me a hand?

npm install gyp build error: call to 'New' is ambiguous

When trying to run npm install bluetooth-serial-port I get the following error on osx:

CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/DeviceINQ.o
CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/BluetoothWorker.o
CC(target) Release/obj.target/BluetoothSerialPort/src/osx/pipe.o
CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/BluetoothDeviceResources.o
CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/BluetoothSerialPort.o
CXX(target) Release/obj.target/BluetoothSerialPort/src/osx/BTSerialPortBinding.o
In file included from ../src/osx/BTSerialPortBinding.mm:14:
In file included from ../node_modules/nan/nan.h:63:
../node_modules/nan/nan_new.h:184:10: error: call to 'New' is ambiguous
return NanIntern::Factory::New(arg0);
^~~~~~~~~~~~~~~~~~~~~~~~~~
../src/osx/BTSerialPortBinding.mm:124:19: note: in instantiation of function template specialization 'NanNew<v8::Integer, unsigned long>' requested here
argv[1] = NanNewv8::Integer(data->result);
^
../node_modules/nan/nan_new.h:86:26: note: candidate function
static inline return_t New(int32_t value);
^
../node_modules/nan/nan_new.h:87:26: note: candidate function
static inline return_t New(uint32_t value);
^
1 error generated.
make: *** [Release/obj.target/BluetoothSerialPort/src/osx/BTSerialPortBinding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/davidwhitely/Sites/comcast-xr16/bluetooth-serial/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bluetooth-serial-port package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "bluetooth-serial-port"
npm ERR! cwd /Users/davidwhitely/Sites/comcast-xr16/bluetooth-serial
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

issue with acquiring channel / rfcomm through windows

I am wanting to connect to a bluetooth device, but am having trouble getting passed the mac address, and can't seem to continue on getting passed findSerialPortChannel().

I am using windows 7, and have tried with using node 8.*, but am now up to 10.23. In the documentation, I have read that there is a prerequisite for python 2.6/2.7, but I am not sure just how that should matter.

The funny thing is how ever, if I run the experiment script or the one mentioned in the readme, and if I just so happen to run my python script that I had written, and execute it, it says that it has found the matching channel ... how ever, I have to do this at separate times and in separate windows.

C:\Apache2\htdocs...\public_html\abate\nodejs\node_modules\bluetooth-serial-port\experiments>node scan-test.js
Found: (10:00:E8:6B:F9:F8) with name Serial Port Device
scan did finish
Found RFCOMM channel for serial port on Serial Port Device: 1

C:\Apache2\htdocs...\public_html\abate\python>python server.py
Attempting to connect to 10:00:E8:6B:F9:F8 Port: 1... done.
Closing socket... done.

Is there a separate issue with windows and bluetooth? Do I need a separate python script?

could not install on windows box

windows 8.1 x64

G:\Projects\NOTE.JS\examples\bluetooth>npm install bluetooth-serial-port
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your operating system or architecture: bluet
[email protected]
npm ERR! notsup Valid OS:    darwin,linux
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "bluetooth-serial-port"
npm ERR! cwd G:\Projects\NOTE.JS\examples\bluetooth
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code EBADPLATFORM
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     G:\Projects\NOTE.JS\examples\bluetooth\npm-debug.log
npm ERR! not ok code 0

G:\Projects\NOTE.JS\examples\bluetooth>

windows 7 x86


Z:\NOTE.JS\examples\bluetooth>npm install bluetooth-serial-port

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your operating system or architecture: bluet
[email protected]
npm ERR! notsup Valid OS:    darwin,linux
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: ia32

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "bluetooth-serial-port"
npm ERR! cwd Z:\E-Drive\Projects\NOTE.JS\examples\bluetooth
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code EBADPLATFORM
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     Z:\NOTE.JS\examples\bluetooth\npm-debug.log
npm ERR! not ok code 0

Z:\NOTE.JS\examples\bluetooth>

Disconnected event

Eelco,

Do you think it could be possible to add a 'disconnected' event to know if a device turn off for example ?

Thanks a lot,
JT

Authenticating Pin Code

I just tried it real quick on my Mac and this works beautifully. But it is opening a popup window to enter the pin code. Is there a way to ask directly through the commandline or give it a static pin-code through node?
That would be really useful to have.

npm install fails on Trisquel/Ubuntu

rodrigo@tequila4free:~/devel$ npm install bluetooth-serial-port
npm http GET https://registry.npmjs.org/bluetooth-serial-port
npm http 304 https://registry.npmjs.org/bluetooth-serial-port
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/nan

> [email protected] install /home/rodrigo/devel/node_modules/bluetooth-serial-port
> node-gyp configure build

make: Entrando no diretório `/home/rodrigo/devel/node_modules/bluetooth-serial-port/build'
  CXX(target) Release/obj.target/BluetoothSerialPort/src/linux/BluetoothSerialPort.o
  CXX(target) Release/obj.target/BluetoothSerialPort/src/linux/DeviceINQ.o
../src/linux/DeviceINQ.cc:35:37: fatal error: bluetooth/bluetooth.h: Arquivo ou diretório não encontrado
     #include <bluetooth/bluetooth.h>
                                     ^
compilation terminated.
make: ** [Release/obj.target/BluetoothSerialPort/src/linux/DeviceINQ.o] Erro 1
make: Saindo do diretório `/home/rodrigo/devel/node_modules/bluetooth-serial-port/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-46-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /home/rodrigo/devel/node_modules/bluetooth-serial-port
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! not ok code 0

Even after installing nodejs-legacy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.