bluez / bluer

BlueR — Official BlueZ Bindings for Rust
https://crates.io/crates/bluer
Other
321 stars 45 forks source link

Add a command line tool for device advertising #140 #143

Closed potto216 closed 5 months ago

potto216 commented 6 months ago

Add a command line tool for device advertising. Closes #140

potto216 commented 5 months ago

@surban are there any changes I should make?

surban commented 5 months ago

I made some changes to massively simplify your code.

In general you need to look more into existing code to see how things are solved efficiently. For example we use the clap parser, but you tried to introduce the deprecated structopt parser.

Your code looked like it was copied together from snippets generated by ChatGPT oder GitHub copilot. These tools can be useful to get started, but are often wrong, inefficient and do not produce code that is acceptable for production.

potto216 commented 5 months ago

@surban before future commits I'll review the code base for more organized, efficient solutions. I tested the code and made some minor modifications. In particular I changed the Manufacture Id numeric format from decimal to hexadecimal to match the Bluetooth "Assigned Numbers" document Section "7.1 Company Identifiers by Value" where the Manufacture Ids are in hexadecimal format.

I believe this is ready for the merge, unless you see other issues.

surban commented 5 months ago

When --duration is specified, shouldn't we exit after the specified time, since the advertisement is removed anyway?

potto216 commented 5 months ago

Sure, I'll also look if the HCI_LE_Advertising_Set_Terminated event is indicated on the dbus which should be generated when the duration specified in the Duration[i] parameter expires. If not, I'll make the exit based on the duration time plus some padding

surban commented 5 months ago

I don't see anything in the D-Bus API that would provide a notification when the advertisement is unregistered. I think it is fine to just exit after the specified duration has passed.

surban commented 5 months ago

Thanks!