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

Tracking macOS High Sierra Support #679

Closed
piotrdubiel opened this Issue Sep 19, 2017 · 18 comments

Comments

Projects
None yet
9 participants
@piotrdubiel

piotrdubiel commented Sep 19, 2017

Setup
noble: 1.8.1
node: 7.7.2
macOS High Sierra 10.13 GM (17A362a)

Description
Current, Yosemite bindings no longer work on High Sierra, supposedly because of changes in CoreBluetooth.
Here 'stateChange' events now comes as kCBMsgId4
I used method stated in noble/bleno#177 (comment), but haven't managed to compile https://github.com/sandeepmistry/osx-ble-peripheral on 10.13 SDK, because of linking error

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_CBXpcConnection"

which might mean it was removed.

@zwaldowski

This comment has been minimized.

Show comment
Hide comment
@zwaldowski

zwaldowski Sep 20, 2017

High Sierra has replaced blued with bluetoothd, and with it a replacement to the previous XPC messages.

zwaldowski commented Sep 20, 2017

High Sierra has replaced blued with bluetoothd, and with it a replacement to the previous XPC messages.

@mbruschi

This comment has been minimized.

Show comment
Hide comment
@mbruschi

mbruschi Sep 20, 2017

@zwaldowski do you have any idea what we have to do in order to make it work again? How can I help?

As far as I know the noble on Linux works with bluetoothd am I right?

Edit:
What I could figure out so far:

  1. We have to catch the osVersion here: https://github.com/sandeepmistry/noble/blob/master/lib/mac/bindings.js
  2. We have to create a highsierra.js file and replace com.apple.bluehd with com.apple.bluetoothd here https://github.com/sandeepmistry/noble/blob/master/lib/mac/yosemite.js#L18
  3. Then see if the protocol changed and if it did, we have to reverse engineer the message-id's: noble/bleno#177 (comment)

Does someone agree on this?

mbruschi commented Sep 20, 2017

@zwaldowski do you have any idea what we have to do in order to make it work again? How can I help?

As far as I know the noble on Linux works with bluetoothd am I right?

Edit:
What I could figure out so far:

  1. We have to catch the osVersion here: https://github.com/sandeepmistry/noble/blob/master/lib/mac/bindings.js
  2. We have to create a highsierra.js file and replace com.apple.bluehd with com.apple.bluetoothd here https://github.com/sandeepmistry/noble/blob/master/lib/mac/yosemite.js#L18
  3. Then see if the protocol changed and if it did, we have to reverse engineer the message-id's: noble/bleno#177 (comment)

Does someone agree on this?

@piotrdubiel piotrdubiel changed the title from No event 'stateChange' on macOS High Sierra to Noble bindings are not compatible with macOS High Sierra Sep 20, 2017

@Axadiw

This comment has been minimized.

Show comment
Hide comment
@Axadiw

Axadiw Sep 22, 2017

We're working on it here: https://github.com/PolideaInternal/noble/tree/macos_highsierra

Unfortunately https://github.com/sandeepmistry/osx-ble-peripheral isn't working anymore on HighSierra (we're not able to swizzle CBXpcConnection class there).

We've been sniffing XPC traffic using http://newosxbook.com/tools/XPoCe.html and decompiling bluetoothd using https://www.hopperapp.com and we've managed to retrieve some of the correct ID's that are being sent byt XPC to bluetoothd on HighSierra.

If someone could test it, and fix all not working calls, we'll be very appreciated.

Generally I think that this XPC method should be abanddoned in noble and some legit implementation basing on CoreBluetooth should be used there (I think that https://github.com/sandeepmistry/noble/tree/more-test is a good start for it)

Axadiw commented Sep 22, 2017

We're working on it here: https://github.com/PolideaInternal/noble/tree/macos_highsierra

Unfortunately https://github.com/sandeepmistry/osx-ble-peripheral isn't working anymore on HighSierra (we're not able to swizzle CBXpcConnection class there).

We've been sniffing XPC traffic using http://newosxbook.com/tools/XPoCe.html and decompiling bluetoothd using https://www.hopperapp.com and we've managed to retrieve some of the correct ID's that are being sent byt XPC to bluetoothd on HighSierra.

If someone could test it, and fix all not working calls, we'll be very appreciated.

Generally I think that this XPC method should be abanddoned in noble and some legit implementation basing on CoreBluetooth should be used there (I think that https://github.com/sandeepmistry/noble/tree/more-test is a good start for it)

@jacobrosenthal jacobrosenthal changed the title from Noble bindings are not compatible with macOS High Sierra to Tracking macOS High Sierra Support Dec 23, 2017

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Dec 26, 2017

Member

I have a hopefully complete high sierra PR in
#727

Needs testing though.

You can have npm install from my git branch with
npm install git://github.com/jacobrosenthal/noble.git#highsierra or edit your package.json and add the branch to your dependencies

  "dependencies": {
    "noble": "git://github.com/jacobrosenthal/noble.git#highsierra"
  }
Member

jacobrosenthal commented Dec 26, 2017

I have a hopefully complete high sierra PR in
#727

Needs testing though.

You can have npm install from my git branch with
npm install git://github.com/jacobrosenthal/noble.git#highsierra or edit your package.json and add the branch to your dependencies

  "dependencies": {
    "noble": "git://github.com/jacobrosenthal/noble.git#highsierra"
  }
@Ezor

This comment has been minimized.

Show comment
Hide comment
@Ezor

Ezor Dec 29, 2017

@jacobrosenthal Just tested it on a little project and it works like a charm

Ezor commented Dec 29, 2017

@jacobrosenthal Just tested it on a little project and it works like a charm

@klategan

This comment has been minimized.

Show comment
Hide comment
@klategan

klategan Dec 29, 2017

@jacobrosenthal Working perfectly. Thanks!

klategan commented Dec 29, 2017

@jacobrosenthal Working perfectly. Thanks!

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster Jan 4, 2018

Ive tried it with muse-lsl (https://github.com/urish/muse-lsl) and it connects to the device but wont get any data from the characteristics. Has anything changed in its interface?

stefanclayster commented Jan 4, 2018

Ive tried it with muse-lsl (https://github.com/urish/muse-lsl) and it connects to the device but wont get any data from the characteristics. Has anything changed in its interface?

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Jan 4, 2018

Member

@stefanclayster can you enable debug logging for the bindings layer and report back
DEBUG=highsierra-bindings node yourscripthere.js

Member

jacobrosenthal commented Jan 4, 2018

@stefanclayster can you enable debug logging for the bindings layer and report back
DEBUG=highsierra-bindings node yourscripthere.js

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Jan 8, 2018

Member

ping @stefanclayster you're the only one to report in with problems. Were you able to solve those? If not can you enable debugging by running like DEBUG=highsierra-bindings node yourscripthere.js

Member

jacobrosenthal commented Jan 8, 2018

ping @stefanclayster you're the only one to report in with problems. Were you able to solve those? If not can you enable debugging by running like DEBUG=highsierra-bindings node yourscripthere.js

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster Jan 8, 2018

Sorry I haven't responded yet, I am on a skiing holiday.I did run with the debug flag and i got too much data outputted to know where the bug is/what is relevant. I will have to investigate further.

stefanclayster commented Jan 8, 2018

Sorry I haven't responded yet, I am on a skiing holiday.I did run with the debug flag and i got too much data outputted to know where the bug is/what is relevant. I will have to investigate further.

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Jan 8, 2018

Member
Member

jacobrosenthal commented Jan 8, 2018

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster commented Jan 15, 2018

debuglog.txt
Here is the log.

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster Jan 15, 2018

I reckon that log was too short. Longer version below with data from characteristics.

debuglog2.txt

stefanclayster commented Jan 15, 2018

I reckon that log was too short. Longer version below with data from characteristics.

debuglog2.txt

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Jan 15, 2018

Member

@stefanclayster Seems like all xpcids are being caught and you're getting a ton of reads (83). Make sure you pull fresh? Its had some changes, but otherwise I think youll need to poke around and debug in this function to see why that function or the emit inside it isnt being called for you https://github.com/sandeepmistry/noble/pull/727/files#diff-81c793ee25a4a5820d33c0d4c9beeea0R519

To explain the log:
48s peripheral founds
45 stop scanning
57 response to stop scanning we dont do anything with
46 49 connect/connected
62 72 discover services / did discoverservices
75 discover characteristics
60 params update we dont do anything with
77 response discover characteristics
81 notify / 86 response notify on a bunch of chars
79 write value a couple times
83 response read value over and over again

Member

jacobrosenthal commented Jan 15, 2018

@stefanclayster Seems like all xpcids are being caught and you're getting a ton of reads (83). Make sure you pull fresh? Its had some changes, but otherwise I think youll need to poke around and debug in this function to see why that function or the emit inside it isnt being called for you https://github.com/sandeepmistry/noble/pull/727/files#diff-81c793ee25a4a5820d33c0d4c9beeea0R519

To explain the log:
48s peripheral founds
45 stop scanning
57 response to stop scanning we dont do anything with
46 49 connect/connected
62 72 discover services / did discoverservices
75 discover characteristics
60 params update we dont do anything with
77 response discover characteristics
81 notify / 86 response notify on a bunch of chars
79 write value a couple times
83 response read value over and over again

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster Jan 15, 2018

Cool! Ill dig into it! Thank you.

stefanclayster commented Jan 15, 2018

Cool! Ill dig into it! Thank you.

@stefanclayster

This comment has been minimized.

Show comment
Hide comment
@stefanclayster

stefanclayster Jan 17, 2018

Is the emitter on 'characteristicvaluechanged' removed? I cannot find it in the repo at all (github search) while it exists in noble repo.

stefanclayster commented Jan 17, 2018

Is the emitter on 'characteristicvaluechanged' removed? I cannot find it in the repo at all (github search) while it exists in noble repo.

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Jan 17, 2018

Member

That appears to be a web bluetooth specific event thats consumed by the web bluetooth bindings layer. Shouldn't have anything to do with macosx support.

High Sierra consumes the kCBMsgId83 event for reads and subscribe notifications triggering 'read' emits to characteristic.js which are consumed in noble.js and trigger 'data' emits for user facing code.

Member

jacobrosenthal commented Jan 17, 2018

That appears to be a web bluetooth specific event thats consumed by the web bluetooth bindings layer. Shouldn't have anything to do with macosx support.

High Sierra consumes the kCBMsgId83 event for reads and subscribe notifications triggering 'read' emits to characteristic.js which are consumed in noble.js and trigger 'data' emits for user facing code.

@weisjohn

This comment has been minimized.

Show comment
Hide comment
@weisjohn

weisjohn Jan 26, 2018

Switching to @jacobrosenthal's fork allowed me to get events right away. Thanks.

weisjohn commented Jan 26, 2018

Switching to @jacobrosenthal's fork allowed me to get events right away. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment