-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add service proc macro #131
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: Pete Kubiak <[email protected]>
Co-authored-by: Pete Kubiak <[email protected]>
Co-authored-by: Pete Kubiak <[email protected]>
Co-authored-by: James Sizeland <[email protected]>
…xample Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
Co-authored-by: Scott Gibb <[email protected]> Co-authored-by: James Sizeland <[email protected]>
@petekubiak Could you split out the uuid parser/generator macro as separate PR? This would immensely improve implementing services with 128-bit Uuids: let mut uart_service = table
// #[gatt_service(uuid = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E")]
.add_service(Service::new(Uuid::Uuid128([
0x9e, 0xca, 0xdc, 0x24,
0x0e, 0xe5, 0xa9, 0xe0,
0x93, 0xf3, 0xa3, 0xb5,
0x01, 0x00, 0x40, 0x6e,
])));
// #[characteristic(uuid = "6E400002-B5A3-F393-E0A9-E50E24DCCA9E", write)]
let _ = uart_service.add_characteristic(Uuid::Uuid128([
0x9e, 0xca, 0xdc, 0x24,
0x0e, 0xe5, 0xa9, 0xe0,
0x93, 0xf3, 0xa3, 0xb5,
0x02, 0x00, 0x40, 0x6e,
]),
&[
CharacteristicProp::Write,
],
&mut rx,
); |
You can write |
Following on from that my hope is that you wouldn't even need to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks the work on this! I've left a few inline comments.
I noticed a commend saying the pub server field would be non-public with additional changes. Do you wish to merge this now or make additional changes to it?
Thanks! I think we'd like to merge this one first and then do further development in a new PR (avoids this one getting too large :) ) |
I've decided to set the visibilities back to what they were and instead implement getter functions for the fields I need. At least that way they are immutable. |
106903c
to
05df3ac
Compare
The purpose of this PR is to simplify the process for defining services and characteristics in TrouBLE, as laid out in this issue: #130.
Services are defined as a struct decorated with the
#[gatt_service(uuid = ...)]
attribute and fields within the struct can be decorated with#[characteristic(<args>)]
attributes to define them as characteristics.In a similar way, the gatt server is defined as a struct with the
#[gatt_server]
attribute, where each of the fields is a service.The server is then instantiated with the
::new()
function which is generated by the attribute macro.This PR lays the foundation for expanding the functionality of the server, services and characteristics such that all access to characteristics (e.g. set, get, notify, indicate) can be done through methods on the characteristics, accessed through the server.