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

--connect for device is not holding through blueutil, but connection can hold through the Mac GUI #64

Open
jdonahue58 opened this issue Jan 10, 2022 · 18 comments

Comments

@jdonahue58
Copy link

using blueutil v2.9.0 on Mac Big Sur 11.6, connect is working very temporarily. Having the macOS GUI up, I can see the device connects using blueutil --connect through a script I wrote and manually, and then a few seconds later shows "not connected." I thought it might be the device, but when I connect through the GUI, the connection holds.

@jdonahue58
Copy link
Author

jdonahue58 commented Jan 10, 2022

Screen.Recording.2022-01-10.at.10.38.39.AM.mov

@jdonahue58
Copy link
Author

after more digging I believe this has something to do with the pairing. The --connect feature works with devices that do not require pin pairing. I see someone reported a similar issue #55

Also, is there a feature to turn off the automatic prompt for pin pairing? I would like to be able to use this feature in an automated fashion

@toy
Copy link
Owner

toy commented Jan 13, 2022

Thanks for opening the issue.

Could you please tell if you did intentionally upload the .zip of a .mov and not .mov itself? It will be easier to understand the issue if a player is presented instead of a link.

From the recording you are connecting a device that is already paired, so pin should not be an issue unless you are unpairing every time.

Also if you mean bypassing pin when pairing it could decrease security of pairing. As long as you understand the consequences in case during pairing only confirmation is requested, you can pipe yes like yes | blueutil --pair ….

@jdonahue58
Copy link
Author

Hi, yes the file was too big to upload the video by itself.

I only see this issue with devices that require pin pairing. It looks as though it pairs fine and shows up in blueutil --paired:

jdonahue$ blueutil --paired
address: c4-3a-35-dd-54-cc, not connected, not favourite, paired, name: "Mustang GTX", recent access date: 2022-01-14 16:25:47 +0000

When I try to connect after that is when I see the issue:

jdonahue$ blueutil --connect "Mustang GTX"
Failed to connect "Mustang GTX"

@toy
Copy link
Owner

toy commented Jan 14, 2022

On video the command succeeds, but connection drops right after, in your last comment the command failed.

Just to check if you tried cycling bluetooth power and restarting?

@jdonahue58
Copy link
Author

I just tried it and same result:

usdjdonahue:~ jdonahue$ blueutil --power off
usdjdonahue:~ jdonahue$ blueutil --power on
usdjdonahue:~ jdonahue$ blueutil --inquiry
address: c4-3a-35-dd-54-cc, not connected, not favourite, not paired, name: "Mustang GTX", recent access date: 2022-01-14 16:25:47 +0000
usdjdonahue:~ jdonahue$ yes yes | blueutil --pair "Mustang GTX"
Does "Mustang GTX" (c4-3a-35-dd-54-cc) display number 633681 (yes/no)? usdjdonahue:~ jdonahue$ blueutil --connect "Mustang GTX"
Failed to connect "Mustang GTX"

I believe connection drops because it tries to connect during the pairing command. Attached is a video that shows that. I've experienced both scenarios.

@jdonahue58
Copy link
Author

jdonahue58 commented Jan 14, 2022

Sorry, my mistake. I did not mean to close the issue.

I just tried it and same result:

usdjdonahue:~ jdonahue$ blueutil --power off
usdjdonahue:~ jdonahue$ blueutil --power on
usdjdonahue:~ jdonahue$ blueutil --inquiry
address: c4-3a-35-dd-54-cc, not connected, not favourite, not paired, name: "Mustang GTX", recent access date: 2022-01-14 16:25:47 +0000
usdjdonahue:~ jdonahue$ yes yes | blueutil --pair "Mustang GTX"
Does "Mustang GTX" (c4-3a-35-dd-54-cc) display number 633681 (yes/no)? usdjdonahue:~ jdonahue$ blueutil --connect "Mustang GTX"
Failed to connect "Mustang GTX"

I believe connection drops because it tries to connect during the pairing command. Attached is a link for a video that shows that. I've experienced both scenarios. 1. Where it attempts to connect during the pairing, does not hold, and then it "connects" using the command but then it drops connection immediately after. 2. I use the command and I get the message "Failed to connect."

https://youtu.be/a85QKyjyLKM

@toy
Copy link
Owner

toy commented Jan 14, 2022

Odd is that on the video in the GUI the device after pairing appears connected, disconnects, connects again and disconnects, then connects after blueutil --connect (and disconnects again).
Please try also blueutil --connect "Mustang GTX" --wait-disconnect "Mustang GTX".

If paired using blueutil, will it connect properly through menu item? And vice versa?

@jdonahue58
Copy link
Author

jdonahue58 commented Jan 14, 2022

Seems like I can pair through blueutil, connect through the Mac GUI fine and connection holds. There is no option in the GUI to just pair, so I connect through the GUI, then disconnect and it is still in the list of paired items in blueutil. Then try to connect through blueutil and get "failed to connect."

usdjdonahue:~ jdonahue$ blueutil --inquiry
address: c4-3a-35-dd-54-cc, not connected, not favourite, not paired, name: "Mustang GTX", recent access date: 2022-01-14 23:28:32 +0000
**Connect through GUI**
usdjdonahue:~ jdonahue$ blueutil --disconnect "Mustang GTX"
usdjdonahue:~ jdonahue$ blueutil --paired 
address: c4-3a-35-dd-54-cc, not connected, not favourite, paired, name: "Mustang GTX", recent access date: 2022-01-14 23:31:26 +0000
usdjdonahue:~ jdonahue$ blueutil --connect "Mustang GTX"
Failed to connect "Mustang GTX"

I still am seeing failure using --wait-disconnect as well

@toy
Copy link
Owner

toy commented Jan 17, 2022

Can you try to reproduce conditions when --connect wouldn't fail, but device disconnects right away? I wanted to see what blueutil --connect "Mustang GTX" --wait-disconnect "Mustang GTX" would do in that case, not when connect fails.

@jdonahue58
Copy link
Author

jdonahue58 commented Jan 18, 2022

Here's a video of my process. For some reason the first run of --connect "Mustang GTX" --wait-disconnect "Mustang GTX" didn't work but I was able to run it again and it worked. I also wanted to show the connection through the GUI working. Let me know if you'd like to see anything else. I can show the tool working with a device that doesn't require pin pairing.

https://youtu.be/JYOixsKjlX4

@jdonahue58
Copy link
Author

Hi Ivan,

Any updates here? I'm thinking of updating my Mac to Monterey but I see there are issues there too. What do you think?

@toy
Copy link
Owner

toy commented Feb 17, 2022

Hi Jillian,
Unfortunately no updates.
Good thing is that the problem may correct itself with the system upgrade. Please write on the outcome if you go with the upgrade.

@fallible-algebra
Copy link

fallible-algebra commented Jan 26, 2024

Hi, I just wanted to contribute to this issue as I had been struggling with it this morning with both --connect and --wait-connect (both terminated immediately while in a script).

Strangely, this issue was resolved for me by running:

bash -c "blueutil --connect ID"

instead of blueutil --connect ID. I'm bringing this up not as a pertinent detail but instead as a potential fix for anyone else who is coming across this issue.

@toy
Copy link
Owner

toy commented Jan 27, 2024

@fallible-algebra That is peculiar, this creates one more process between terminal emulator and blueutil, but there is already the login shell, so no idea why would it fix the issue.
Is bash also your login shell?
I assume it should also work, but can you try also zsh or some scripting language (ruby -e 'system "blueutil --is-connected ID"')?

@fallible-algebra
Copy link

fallible-algebra commented Jan 28, 2024

Zsh is my login shell, with a fairly basic oh-my-zsh install. I'll get around to that shortly.

@fallible-algebra
Copy link

Can confirm that specifically ruby -e "system 'blueutil --connect ID'" also successfully connects, and that the command you posted does correctly report the connection status.

@fallible-algebra
Copy link

This also works with the script set to zsh, and with the command set to zsh.

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

3 participants