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

Connect to nrf52 #8

Open
chipimix opened this issue Jun 4, 2020 · 5 comments
Open

Connect to nrf52 #8

chipimix opened this issue Jun 4, 2020 · 5 comments

Comments

@chipimix
Copy link

chipimix commented Jun 4, 2020

Hi!
I'm trying to use this module to connect to a nrf52 with NUS service.
However when I run this code:
`var winnus = require("winnus");

var device = winnus.getDevices()[0];
console.log(device)
winnus.connect(device, function(data) {
console.log("Got data "+JSON.stringify(data));
});`
It fails on connect:
image
Am I doing something wrong? does this module work exclusively for puck.js devices?
Thanks!

@gfwilliams
Copy link
Member

Hi - I'm afraid I don't know exactly what the issue is. How are you creating the NUS service on the device? Using the Nordic ble_nus library?

There is nothing specific in there that requires a Puck.js or other Espruino device, so it should work just fine

@chipimix
Copy link
Author

chipimix commented Jun 4, 2020

Thanks for the answer!
Yes we're using ble_nus library, is there something in particular I should be doing?

@gfwilliams
Copy link
Member

No - I'm extremely surprised then. It should 'just work' :(

@chipimix
Copy link
Author

chipimix commented Jun 5, 2020

I think I know what the issue is but I'm not entirely sure how to solve it.
From what I understand, when we subscribe a characteristic with the notify attribute, we're basically writing something like [0x01,0x00] to the Client Characteristic Configuration Descriptor.
In the case of my nRF52 board and the specifications of NUS, the CCCD UUID is 0x2902; however I think winnus will try to write it to 0x2901.
I think this is what's happening and considering the BluetoothGATTSetDescriptorValue error, it would make sense. Any thoughts on how I can make this parameterizable or hardcode it? Thanks!

@gfwilliams
Copy link
Member

Ahh, interesting - thanks for spotting that!

Well, I assume it's this check? https://github.com/espruino/winnus/blob/master/cpp/winnus.cpp#L494

There must be a better way to handle it...

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

No branches or pull requests

2 participants