Open jnmandal opened 6 months ago
Will keep updates here if thats OK with you.
Please do! I don't use a Mac regularly, although I do have one at home I could test with.
From the logs, it looks like the discovery went okay. Does the Click respond as you'd expect after this (the light should switch from pulsing blue to steady blue for some short amount of time, and go back to flashing when it disconnects).
There may be something of interest in the Bleak documentation about MacOS: https://bleak.readthedocs.io/en/latest/backends/macos.html I've never developed with Bleak on the Mac platform, so it's possible something different/special needs to be done in that case.
hi @jnmandal any progress on the project? I would love to use this too on my mac mini.
would also love to use it, but can't get past this:
[11:43:36] INFO Set up logging @ "2024-10-24T11:43:36.195216+02:00" app.py:40
INFO Setting up BLE client **WITHOUT** encryption app.py:49
INFO Using MAC of "None" app.py:51
INFO Scanning for Click... (10 second timeout) app.py:89
INFO Found Click device with MAC "AD1AFCCE-78AE-808B-629F-24B9CF1EDCAA" app.py:93
INFO Waiting for device to be visible; please press a button on the Click if it is not already in "connecting" mode app.py:245
(pulsing blue light)
[11:43:38] INFO Click device found; Starting connection handshake app.py:261
ERROR Failed to write characteristic 27: Error Domain=CBATTErrorDomain Code=3 "Writing is not permitted." app.py:298
UserInfo={NSLocalizedDescription=Writing is not permitted.}
Traceback (most recent call last):
File "/Users/kevin/Coding/zwift_click_handling/app.py", line 296, in <module>
asyncio.run(click.write_handshake())
File
"/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners
.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File
"/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners
.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_ev
ents.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/kevin/Coding/zwift_click_handling/app.py", line 267, in write_handshake
await client.write_gatt_char(
File
"/Users/kevin/Library/Caches/pypoetry/virtualenvs/zwift-click-handler-UnesyFEq-py3.12/lib/python3.12/sit
e-packages/bleak/__init__.py", line 786, in write_gatt_char
await self._backend.write_gatt_char(characteristic, data, response)
File
"/Users/kevin/Library/Caches/pypoetry/virtualenvs/zwift-click-handler-UnesyFEq-py3.12/lib/python3.12/sit
e-packages/bleak/backends/corebluetooth/client.py", line 326, in write_gatt_char
await self._delegate.write_characteristic(
File
"/Users/kevin/Library/Caches/pypoetry/virtualenvs/zwift-click-handler-UnesyFEq-py3.12/lib/python3.12/sit
e-packages/bleak/backends/corebluetooth/PeripheralDelegate.py", line 196, in write_characteristic
await future
bleak.exc.BleakError: Failed to write characteristic 27: Error Domain=CBATTErrorDomain Code=3 "Writing is not
permitted." UserInfo={NSLocalizedDescription=Writing is not permitted.} ```
any progress on the MAC version? I've tried but failed at the compatible phyton version..
ok... I only to include 3.13, but now failing the next step
As a temporary workaround, you can use the python script below, which relies on the QZ app to monitor click presses and then sends virtual gearing keypresses to indieVelo/TPv: https://github.com/mnetzwur/tpv-zclick
Please note that this is a hacky solution. I hope someone uses the click handling code from the QZ app, which is open source, to write a native click handler for macOS/iOS/iPadOS soon!
Hi thanks for your work on this. ITs great. I am interested in getting this going on my Mac so I am going to do my best to make it work. Will keep updates here if thats OK with you.
Attempting to use script running on macOS sonoma 14.2 (23C64)
steps:
xcode-select --install
)1.
script will crash with error:
ERROR Bluetooth device is turned off
. Look for a permissions window asking for bluetooth permission for terminal. Accept.This is as far as I got. It says it connected to the device but is not receiving the button presses. Logs:
I will debug and update as necessary, perhaps w/ a fork and PR.