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

Discover service list of peripheral #11

Closed
JohnAZoidberg opened this issue Jan 11, 2020 · 11 comments · Fixed by #202
Closed

Discover service list of peripheral #11

JohnAZoidberg opened this issue Jan 11, 2020 · 11 comments · Fixed by #202
Labels
bluez (linux) Issues related to the dbus/bluez core

Comments

@JohnAZoidberg
Copy link

Just like discovering the characteristics of a peripheral, we need to be able to discover its services.

It looks like it's quite similar to characteristic discovery, so I'll try to implement it myself for BlueZ.

@qdot
Copy link
Contributor

qdot commented Jan 11, 2020

@JohnAZoidberg are you referring to enumerating services post GATT server connect to a peripheral, or when peripheral services are listed as part of advertisements?

@qdot qdot added the bluez (linux) Issues related to the dbus/bluez core label Jan 11, 2020
@JohnAZoidberg
Copy link
Author

The former, post connect service enumeration. Just like Peripheral::discover_characteristics currently does it for characteristics.

@qdot
Copy link
Contributor

qdot commented Jan 11, 2020

Thanks for clarifying. :D

@Moret84
Copy link

Moret84 commented Apr 17, 2020

Hi, just looking at this issue.

@JohnAZoidberg are you referring to enumerating services post GATT server connect to a peripheral, or when peripheral services are listed as part of advertisements?

About the latter,

I have a bluetooth device (a thermometer btw) that broadcast some data as advertisement.

@qdot Is there any plan to implement a way to get those data in PeripheralProperties ?

edit: I've found a PR that implement something like that, and another issue in which you expose your plans for the future of the crate. I will stay tuned.

@JohnAZoidberg
Copy link
Author

Your device probably also has this data as a characteristic. You can connect and let yourself be notified of changes in that characteristic.
You don't need to discover the services at all, just the characteristics.

@qdot
Copy link
Contributor

qdot commented Apr 17, 2020

At some point it would be nice to support service advertisements, but it's not on the roadmap yet (mostly because there's not a roadmap period, yet. I'm hoping to get back to planning improvements on btleplug sometime in the next few weeks)

@JohnAZoidberg
Copy link
Author

I took up the service discovery again and I thought that I'll combine it with the characteristic discover.
We can just read all of the attributes at once and then create our Rust service and characteristic structs from them. What do you think @qdot?

@Moret84
Copy link

Moret84 commented Apr 17, 2020

Your device probably also has this data as a characteristic. You can connect and let yourself be notified of changes in that characteristic.
You don't need to discover the services at all, just the characteristics.

Not exactly the same data, actually. There is indeed a characteristic where we can read temperature + hygrometry and subscribe to notification (data are string-encoded).

But the advertised payload periodically changes and contains alternatively humidity+ temperature, temperature, or battery level (as byte array). Furthermore, it is impossible to read battery through a characteristic.

Sometimes it can be useful to read advertisement data because it does not require to connect to the device.

@qdot
Copy link
Contributor

qdot commented Jul 31, 2021

Ok, so as of 0.8 I think we handle both of these things now. We'll do service detection on connect and fill out our peripheral properties struct with that info, and we can also pick it up from advertisements there when they happen. Going to close this, but feel free to reopen or yell at me if I've gotten this wrong.

@qdot qdot closed this as completed Jul 31, 2021
@qwandor
Copy link
Collaborator

qwandor commented Jul 31, 2021

I don't think we currently expose services, we just heap all the characteristics from all the services together in one big list.

@qwandor
Copy link
Collaborator

qwandor commented Oct 21, 2021

Services are accessible thanks to #202, released in 0.9.0.

@qwandor qwandor closed this as completed Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bluez (linux) Issues related to the dbus/bluez core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants