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

Issues subscribing and receiving data #17

Open
chipimix opened this issue May 23, 2020 · 8 comments
Open

Issues subscribing and receiving data #17

chipimix opened this issue May 23, 2020 · 8 comments

Comments

@chipimix
Copy link

Hi!
It seems to me that BLE support on windows is somewhat limited and UWP-centric. This module allows development of electron apps. Thanks for all of your work!! :)
Having said that, I'm having issues subscribing a service characteristic with the "notify" attribute: it doesn't seem to trigger the data event. Perhaps I'm doing something wrong:

uartCharacteristic.subscribe(function(error) {
     console.log('battery level notification on');
});
uartCharacteristic.on('data', function(data, isNotification){
	console.log(data);
});

Also, i read that

Writing/Reading to descriptor handles is not supported
Broadcast is not supported

Does this mean subscribing to a service characteristic with the "notify" attribute is not supported yet?
Thanks again!

@chipimix
Copy link
Author

I think I forgot a bolean parameter in the subscribe method; but now I encounter this error:
image

@geovie
Copy link
Contributor

geovie commented May 28, 2020

@chipimix There is no need for a boolean parameter. You can check the example for a how to subscribe to a characteristic

@chipimix
Copy link
Author

I thought it could be outdatted since the noble example features the boolean parameter.
batteryLevelCharacteristic.subscribe(true, function(error) { console.log('battery level notification on'); });
Thanks for pointing the direction though. Still can't get on('data') events triggered by subscribe though, only with read() :(

@geovie
Copy link
Contributor

geovie commented May 28, 2020

Do you get any error in the subscribe callback?

@chipimix
Copy link
Author

chipimix commented May 28, 2020

unfortunately no!

uartCharacteristic.subscribe(function(error) { console.log('notification on'); }); uartCharacteristic.on('data', function(data, isNotification){ console.log(data); });

results in:
image

If I inspect the characteristic this is what I see:
image

uartCharacteristic.read() does trigger the on('data') event though ...

@geovie
Copy link
Contributor

geovie commented May 28, 2020

Can you log the error: uartCharacteristic.subscribe(function(error) { console.log('subscribe:', error); });

@chipimix
Copy link
Author

sure! but the issue is don't get any error in the subscribe callback

uartCharacteristic.subscribe(function(error) {
	console.log(error)
	console.log('notification on');
});

results in:
image

@chipimix
Copy link
Author

chipimix commented Jun 5, 2020

I think I found the issue!
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 Nordic UART Service Tx Characteristic, the CCCD UUID is 0x2902; however I think noble will try to write it to 0x2901.
Is there some place where I can make this parameterizable or hardcode it? Thanks for all the help!

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