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

Added support for MacOS HighSierra #689

Closed
wants to merge 3 commits into from

Conversation

Axadiw
Copy link

@Axadiw Axadiw commented Sep 27, 2017

Changed XPC Id's that are being sent to CoreBluetooth on MacOS HighSierra

Tested everything besides:

  • discoverIncludedServices
  • broadcast
  • writeValue (on descriptor)
  • readHandle
  • writeHandle

Additionaly it looks like after registering on notifications, we're CoreBluetooth is sending the same ID as after requesting for characteristic value (single value, not continuous notifications). This may lead to some problems with notification registration on some characteristics.

Fixes #679 and #680

}.bind(this));
};

nobleBindings.on('kCBMsgId6', function(args) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was needed to change from kCBMsgId6 to kCBMsgId4 to catch stateChange event on my MBP running High Sierra.

 xpcEvent: {
  "kCBMsgId": 4,
  "kCBMsgArgs": {
    "kCBMsgArgState": 5
  }
}

Copy link
Author

@Axadiw Axadiw Sep 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I've missed that one

Thanks

@mlcloudsec
Copy link

mlcloudsec commented Oct 5, 2017

an ETL on this please?

@achingbrain
Copy link

Works for me, although running with DEBUG=* prints messages from yosemite-bindings instead of highsierra-bindings - this line needs changing.

@Axadiw
Copy link
Author

Axadiw commented Oct 10, 2017

Thanks @achingbrain - I've changed these debug messages accordingly to your suggestion

@andrewjaykeller
Copy link

Okay testing this branch!

@vikeri
Copy link

vikeri commented Oct 16, 2017

Can also verify that this works 👍

@andrewjaykeller
Copy link

Seems to be working good enough, as good enough, still loosing samples and we hope a switch to core Bluetooth could help!

@sid9102
Copy link

sid9102 commented Oct 16, 2017

Can confirm that this is working. However like @aj-ptw mentioned above it appears to be losing a lot of samples. My latency has gone from an average of 30 ms per update to 150 ms.

@andrewjaykeller
Copy link

andrewjaykeller commented Oct 17, 2017

I've got some hours to put towards using core bluetooth as the underlying lib with the goal to improve the notifications on select macOS computers.

I see @sandeepmistry started more-test looks like where i should pull and work from.

@andrewjaykeller
Copy link

Any idea when will this get merged?

@taktran
Copy link
Contributor

taktran commented Oct 24, 2017

This is working for me too, but it's a bit laggy. On simple scripts, it works ok with some minor lag, but with a UI, you can definitely feel it.

@nisargap
Copy link

nisargap commented Nov 1, 2017

This works for me on macOS High Sierra

@bennesp
Copy link

bennesp commented Nov 5, 2017

I run peripheral-explorer.js, and I obtained an error on line 376 of highsierra.js:

TypeError: Cannot read property 'uuid' of undefined

The line is the following:

var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid;

I debugged a bit, and serviceStartHandle is undefined, because the args passed to that callback don't contain a kCBMsgArgServiceStartHandle
Args:

{ kCBMsgArgDescriptors: 
   [ { kCBMsgArgUUID: <Buffer 29 02>, kCBMsgArgDescriptorHandle: 15 } ],
  kCBMsgArgCharacteristicHandle: 13,
  kCBMsgArgDeviceUUID: <Buffer 6e dd ... 27 e9> }

Am I doing something wrong?

@JackCurrie
Copy link

Works for me on 2017 MacBook pro running high sierra version 10.13.1. Thanks!

@leinelissen
Copy link

Works on iMac 2015, using 10.13. Also checks out with my MacBook Pro 2017 running 10.13. Could we please merge this?

@alexandrevilain
Copy link

Works for me on MacBook Pro (mid 2014) running macOS version 10.13.1.
Thanks for your work !

Copy link

@dfrankland dfrankland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever trying to discover descriptors, there's an error.

nobleBindings.on('kCBMsgId87', function(args) {
var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex');
var serviceStartHandle = args.kCBMsgArgServiceStartHandle;
var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consistently get a TypeError: Cannot read property 'uuid' of undefined error here.

Copy link

@josschne josschne Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Running examples/peripheral-explorer.js I see the TypeError: Cannot read property 'uuid' of undefined error. examples/advertisement-discovery.js runs without issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

87 is (correctly) assigned to servicesDiscover above, and duplicated here incorrectly. We need to figure out what includedServicesDiscover's xpc id actually is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its 76.. Try that

@gpgabriel
Copy link

gpgabriel commented Nov 24, 2017

I'm testing this PR on macOS 10.13, I'am able to discover my device (nRF52832) and from the logs I can see that the library sends the event 45 and 46 then receives 48 but it doesn't receive 49 to change the state of the device to connected. No other events are being logged.

When using gatttool on Debian I'm able to connect to the device without any errors.

I've been looking for a dictionary to get more details about all the possible events but I couldn't find any, could you please point me somewhere to get this data?

EDIT: Also, most of the devices around me appear with an unknown address. (noble on Debian returns the correct addresses).

EDIT2: The fact that the address is unknown for most of the devices seems to be related to the fact that CoreBluetoothCache from /Library/Preferences/com.apple.Bluetooth.plist has very few items (in my case just 5).

EDIT3: I just tested this with macOS 10.12.6 and the library stays blocked in the same connecting state. CoreBluetoothCache doesn't even exists in the com.apple.Bluetooth.plist object. The only place where I've seen the library to work is on Debian.

@gpgabriel
Copy link

gpgabriel commented Nov 27, 2017

I spent many hours trying to get the library to connect to a device on macOS 10.13 using node 8.2.1/7.10.2/4.1.2 but I couldn't find any way. The peripheral object gets blocked in connecting state (no other xpc events are being emitted after that). Also, the default bluetooth device from my computer is broken (it's not recognised) so I'm using a bluetooth dongle (Asus BT400).

EDIT: I think it's the BT400 which is causing issues, it works on macOS 10.12 with an integrated (Mac mini) bluetooth chip.

@hanhdt
Copy link

hanhdt commented Dec 1, 2017

I'm testing this PR on 10.13.1 High Sierra.
I run peripheral-explorer.js, and I obtained an error on: core-bluetooth/lib/peripheral-manager.js:41

Log is the following:

$.CBPeripheralManager.getInstanceMethod('xpcConnection:didReceiveMsg:args:').exchangeImplementations($.CBPeripheralManager.getInstanceMethod('xpcConnection:didReceiveMsg:argsSwizzled:'));

TypeError: Cannot read property 'exchangeImplementations' of null
    at Object.<anonymous> (/node_modules/core-bluetooth/lib/peripheral-manager.js:41:77)
    at Module._compile (module.js:635:30)

What am I doing wrong?

@Guzmandius
Copy link

Bit of a noob. But, how do I apply this specific branch. I installed the more-test branch, but i am getting yosemite-bindings. do I just modify the bindings.js and add the highsierra.js file. I appreciate the help and insight. I am trying to add the bluetooth module for the ceiling fan on 10.13.2 instead of Linux. Thanks!

@leinelissen
Copy link

@Guzmandius npm install git+https://github.com/PolideaInternal/noble.git#macos_highsierra

@elovin
Copy link

elovin commented Dec 8, 2017

when can we expect this to be merged into noble ?

@vikeri
Copy link

vikeri commented Jan 9, 2018

For anyone with the Descriptor issue, this PR fixed that for me: #727

@pchinjr
Copy link

pchinjr commented Jan 9, 2018

Thanks for doing this @Axadiw, it worked great for me with node-rolling-spider and resolved my issue. I'm on a 2016 Macbook Pro with High Sierra 10.13.2 and Node 8.9.4

@pchinjr
Copy link

pchinjr commented Jan 17, 2018

Hi everyone, I'm back, after further testing. I am running into an issue with notifications on one of the characteristics in Node-Rolling-Spider. voodootikigod/node-rolling-spider#103 So I'm currently bouncing back and forth between rolling-spider and noble, to understand what is going on with the way High Sierra is interacting with Rolling-Spider. Thanks everyone!

@jacobrosenthal
Copy link
Member

Superceded by #727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.