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

Get device Id in Notifications and Filter devices by Id #553

Closed
davidwiki8 opened this issue Jul 9, 2021 · 2 comments
Closed

Get device Id in Notifications and Filter devices by Id #553

davidwiki8 opened this issue Jul 9, 2021 · 2 comments

Comments

@davidwiki8
Copy link

Is it possible, or will it be, to get the Id of the device sending a notification? Right now, you can only get the UUID of the service and characteristic sending it, along with the data.

In addition, it would be really nice to be able to filter devices acording to their Id, and not only name and services.

@reillyeon
Copy link
Contributor

Inside a 'characteristicvaluechanged' event listener you can access the device ID through the BluetoothRemoteGATTCharacteristic object like this,

characteristic.addEventListener('characteristicvaluechanged', (e) => {
  console.log(`Device ID: ${e.target.service.device.id}`);
});

It doesn't make sense to filter devices based on their ID because the ID is only assigned to a device once the page has access to it. #417 tracks allowing filtering based on MAC address.

@davidwiki8
Copy link
Author

Thanks for the info!

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