toy / blueutil

CLI for bluetooth on OSX: power, discoverable state, list, inquire devices, connect, info, …
https://github.com/toy/blueutil
Other
1.01k stars 53 forks source link

Also search paired devices to get device by name #88

Closed azuwis closed 5 months ago

azuwis commented 6 months ago

IOBluetoothDevice.recentDevices return empty list in macOS Monterey and later, also search paired devices to make

--info "BY NAME" --connect "BY NAME" --disconnect "BY NAME" ...

work again.

Fix #62

toy commented 6 months ago

Thank you for creating the PR

I think it would be better to search both lists, first paired, then recent devices (maybe easiest is to concat arrays to not do it separately). Please update documentaation describing the search by name (line starting with "ID can be either address"). I think it resolves #62, but not #58 - only addresses are used in all commands

azuwis commented 5 months ago

@toy Please review the new changes.

toy commented 5 months ago

Nice

I think it will be better to still show a separate error if there are no paired or recent devices, it will fail anyway, but error about empty list is more precise than one about not being able to find a device by name.

Also please run ./update_usage (to copy the change in help to readme) and add an entry to CHANGELOG.md

azuwis commented 5 months ago

@toy Done.

toy commented 5 months ago

I think it is still better to print error and exit if searchDevices is empty, not just show a warning if one of pairedDevices and recentDevices is nil. As is, if recent devices returns nil, but there are paired devices and there is a device by searched name, there will be a probably confusing warning message, but finding device will succeed. Sorry if I was not clear enough in previous message.

toy commented 5 months ago

Wanted to merge, but realised that you didn't add an entry to CHANGELOG.md, please write something following examples and please link there both this PR and the issue #62

toy commented 5 months ago

@azuwis Thank you