Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 12 compatibility #5

Merged
merged 6 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
- NODE_VERSION="6"
- NODE_VERSION="8"
- NODE_VERSION="10"
- NODE_VERSION="12"

before_install:
- sudo apt-get install build-essential libudev-dev -y
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ environment:
- node_version: '6'
- node_version: '8'
- node_version: '10'
- node_version: '12'

install:
- ps: Install-Product node $env:node_version $env:platform
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abandonware/bluetooth-hci-socket",
"version": "0.5.3-1",
"version": "0.5.3-2",
"description": "Bluetooth HCI socket binding for Node.js",
"main": "index.js",
"repository": {
Expand All @@ -27,25 +27,27 @@
],
"dependencies": {
"debug": "^4.1.0",
"nan": "^2.10.0",
"node-pre-gyp": "^0.12.0"
"nan": "^2.14.0",
"node-pre-gyp": "^0.13.0"
},
"optionalDependencies": {
"usb": "^1.1.0"
"usb": "^1.6.0"
},
"devDependencies": {
"jshint": "^2.8.0"
},
"scripts": {
"preinstall": "npm install node-pre-gyp",
"install": "node-pre-gyp install --fallback-to-build",
"test": "jshint lib/*.js"
"test": "jshint lib/*.js && node ."
},
"binary": {
"module_name": "binding",
"module_path": "./lib/binding/",
"host": "https://github.com/sandeepmistry/node-bluetooth-hci-socket/releases/download/",
"package_name": "{module_name}-{version}-{node_abi}-{platform}-{arch}.tar.gz",
"remote_path": "{version}"
},
"jshintConfig": {
"esversion": 6
}
}
29 changes: 10 additions & 19 deletions src/BluetoothHciSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ NAN_MODULE_INIT(BluetoothHciSocket::Init) {
Nan::SetPrototypeMethod(tmpl, "stop", Stop);
Nan::SetPrototypeMethod(tmpl, "write", Write);

target->Set(Nan::New("BluetoothHciSocket").ToLocalChecked(), tmpl->GetFunction());
Nan::Set(target, Nan::New("BluetoothHciSocket").ToLocalChecked(), Nan::GetFunction(tmpl).ToLocalChecked());
}

BluetoothHciSocket::BluetoothHciSocket() :
Expand Down Expand Up @@ -264,16 +264,7 @@ void BluetoothHciSocket::write_(char* data, int length) {
}

void BluetoothHciSocket::emitErrnoError() {
Nan::HandleScope scope;

Local<Object> globalObj = Nan::GetCurrentContext()->Global();
Local<Function> errorConstructor = Local<Function>::Cast(globalObj->Get(Nan::New("Error").ToLocalChecked()));

Local<Value> constructorArgs[1] = {
Nan::New(strerror(errno)).ToLocalChecked()
};

Local<Value> error = Nan::NewInstance(errorConstructor, 1, constructorArgs).ToLocalChecked();
v8::Local<v8::Value> error = Nan::ErrnoException(errno, NULL, strerror(errno));

Local<Value> argv[2] = {
Nan::New("error").ToLocalChecked(),
Expand Down Expand Up @@ -393,7 +384,7 @@ NAN_METHOD(BluetoothHciSocket::BindRaw) {
if (info.Length() > 0) {
Local<Value> arg0 = info[0];
if (arg0->IsInt32() || arg0->IsUint32()) {
devId = arg0->IntegerValue();
devId = Nan::To<int32_t>(arg0).FromJust();

pDevId = &devId;
}
Expand All @@ -415,7 +406,7 @@ NAN_METHOD(BluetoothHciSocket::BindUser) {
if (info.Length() > 0) {
Local<Value> arg0 = info[0];
if (arg0->IsInt32() || arg0->IsUint32()) {
devId = arg0->IntegerValue();
devId = Nan::To<int32_t>(arg0).FromJust();

pDevId = &devId;
}
Expand Down Expand Up @@ -468,12 +459,12 @@ NAN_METHOD(BluetoothHciSocket::GetDeviceList) {
bool devUp = dr->dev_opt & (1 << HCI_UP);
if (dr != NULL) {
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
obj->Set(Nan::New("devId").ToLocalChecked(), Nan::New<Number>(devId));
obj->Set(Nan::New("devUp").ToLocalChecked(), Nan::New<Boolean>(devUp));
obj->Set(Nan::New("idVendor").ToLocalChecked(), Nan::Null());
obj->Set(Nan::New("idProduct").ToLocalChecked(), Nan::Null());
obj->Set(Nan::New("busNumber").ToLocalChecked(), Nan::Null());
obj->Set(Nan::New("deviceAddress").ToLocalChecked(), Nan::Null());
Nan::Set(obj, Nan::New("devId").ToLocalChecked(), Nan::New<Number>(devId));
Nan::Set(obj, Nan::New("devUp").ToLocalChecked(), Nan::New<Boolean>(devUp));
Nan::Set(obj, Nan::New("idVendor").ToLocalChecked(), Nan::Null());
Nan::Set(obj, Nan::New("idProduct").ToLocalChecked(), Nan::Null());
Nan::Set(obj, Nan::New("busNumber").ToLocalChecked(), Nan::Null());
Nan::Set(obj, Nan::New("deviceAddress").ToLocalChecked(), Nan::Null());
Nan::Set(deviceList, di++, obj);
}
}
Expand Down