sindresorhus / Actions

⚙️ Supercharge your shortcuts
https://sindresorhus.com/actions
MIT License
2.49k stars 103 forks source link

encounter an error when using "Get Bluetooth device with identifier" #216

Open Huangbinghui opened 6 months ago

Huangbinghui commented 6 months ago

Description

when i using action "Get Bluetooth device with identifier", it throw an error "operation is not supported".

macOS/iOS version

IOS 17.2.1,iPhone 12 mini

Shortcut URL

No response

sindresorhus commented 6 months ago

Can you try out the latest TestFlight build and let me know whether it fixes the issue? https://testflight.apple.com/join/fJGUrsZx

Huangbinghui commented 6 months ago

Can you try out the latest TestFlight build and let me know whether it fixes the issue? https://testflight.apple.com/join/fJGUrsZx

sure,it seems fixed. but this action returns disconnect states when my airpods is connnected to my phone.

sindresorhus commented 6 months ago

Did you try both AirPods? Each (left and right) has their own identifier.

ShxdowStar commented 6 months ago

Did you try both AirPods? Each (left and right) has their own identifier.

I currently have both connected and this is what it returns:

Identifier: CE95259D-3E18-C236-CD98-0110935B3DE3 
Connected: false
Signal: 100%
RSSI: 0 
Unique Services: 0
Services: 0

Edit: The testflight version did fix the Operation Not Supported issue though.

Edit #2: I was testing with only having one or the other Airpod connected and it seems to return the same UUID, whether it is the left, right or both. Perhaps this is something related? Edit #3 Did some more testing, and I got details on a Bluetooth device near by, and the connected value returns true despite me not being connected to it. Maybe the conditions for the Boolean are reversed in the code? Going to take a look now.

Edit #4: I'm not very familiar with Swift but maybe the issue lies in line 71 to line 73?

if
            !wasConnected,
            peripheral.state == .connected

If I'm understanding this correctly, !wasConnected means "not" wasConnected, and then the code returns the value as connected which is the opposite of what is expected.

zecanard commented 6 months ago

I’ve just tested this in 3.1.0.62 (suggestion: maybe show the version number inside the app?). Here are my findings:

Lastly, Get Bluetooth Device by UUID seems a lot less reliable than Get All Bluetooth Devices. The latter (Get All) reliably gives me all (or most Bluetooth devices), even in a crowded gym with tons of Bluetooth headphones and smart TVs.

Get by UUID usually fails to get me the smart TV I’m asking for at the gym (I meant to use it to detect being inside the gym). In my apartment with relatively few Bluetooth devices within range, Get by UUID only retrieves Bluetooth devices with a strong signal/RSSI. This is even if I push the scan duration to 10 seconds. Try Get All, and those weak devices show up immediately. Is this normal/an iOS limitation?

ShxdowStar commented 6 months ago

Get by UUID usually fails to get me the smart TV I’m asking for at the gym (I meant to use it to detect being inside the gym).

Random thought, but wouldn't a location based automation/shortcut fare better than checking to see if you can detect the smart TV inside the gym? (Unless you are intentionally trying to avoid location based automations) Side note: I am currently at work and I am able to detect the smart tvs, some of which are up to 500ft away. Have you tried the testflight version?

Can you try out the latest TestFlight build and let me know whether it fixes the issue? https://testflight.apple.com/join/fJGUrsZx

zecanard commented 6 months ago

I am on the TestFlight version (62), and I have a specific need for detecting being inside the gym.

ShxdowStar commented 6 months ago

I figured as much, I'm not sure as to why you're unable to detect those TV's.... Perhaps it is a limitation of the hardware inside of the TV rather than the software of the app. The TVs at my job are fairly new (purchased within the last 6 months) and may be able to transmit the signal farther due to new hardware.

zecanard commented 6 months ago

I am able to detect the smart TVs just fine, otherwise I couldn’t even attempt to Get by UUID. Retrieving a specific device is the problem.

Those are two distinct Actions.

ShxdowStar commented 6 months ago

I see, sorry I misunderstood what you wrote. Not sure why it isn't retrieving a specific device with Get by UUID. I don't seem to be having that issue, even with one of the farther away TV's that I've never connected to, I have a 7% signal and get all of the information... (I set the timeout to 60s but it took maybe 15-20s maybe try a higher timeout and see?)

Edit: RSSI is -96 too

zecanard commented 6 months ago

I’ve done some more testing. Devices with weaker RSSI usually connect within 2–3 seconds, and sometimes return no result even after 25 seconds.

At the same time, one device I tried immediately throws an error (rather than returning no result). I guess Get by UUID actively tries to connect to the device, which may choose to reject the connection.

The documentation does state that you need to have connected to the device at least once before. I had read that part when the feature was first released, but since it actually worked for the random devices I had tested (my neighbors’ smart bulbs and foot massagers), it slipped my mind.

As for my Powerbeats Pro, Get All Devices returns the same UUID regardless of which earbud I put on. I wait a few minutes until the earbud that’s in the case disappears from my Batteries widget before scanning.

Jack-GH2000 commented 6 months ago

I have similar issues. My Tesla Model 3 audio doesn't show up at all, only the key but the key shows as disconnected even though it is connected.

TesLocker commented 3 months ago

I also see the same issue with “get Bluetooth device” (singular). I have both AirPods on and am listening to music in both ears, but the shortcut returns that “connected” is false, signal is 100%, and RSSI is 0.

Samuelodan commented 3 weeks ago

I have the same issue with connected: false. I'm trying to run some actions when an app is opened with one of those actions running only when my AirPods are connected.

A fix will be appreciated.

Edit: for now tho, I can successfully check to see if the identifier matches what I expect as a way to know that it's connected. I initially tried to match the name but that didn't work for me.