jat255 / zwift_click_handling

MIT License
23 stars 0 forks source link

MacOS Support #1

Open jnmandal opened 5 months ago

jnmandal commented 5 months ago

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:

1.

brew install poetry
poetry install --no-root
poetry run python app.py -v
  1. script will crash with error: ERROR Bluetooth device is turned off. Look for a permissions window asking for bluetooth permission for terminal. Accept.

  2. This is as far as I got. It says it connected to the device but is not receiving the button presses. Logs:

    zwift_click_handling [main] |> poetry run python app.py -v
    [11:53:22] INFO     Set up logging @ "2024-05-23T11:53:22.632943-05: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
           DEBUG    centralManagerDidUpdateState_                                                                                                                                        CentralManagerDelegate.py:223
           DEBUG    Bluetooth powered on                                                                                                                                                 CentralManagerDelegate.py:235
           DEBUG    'isScanning' changed                                                                                                                                                 CentralManagerDelegate.py:212
    [11:53:23] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataTimestamp', 'kCBAdvDataServiceData',            CentralManagerDelegate.py:267
                    'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and Central: <CBCentralManager:                              
                    0x6000023b0dc0>                                                                                                                                                                                   
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 2196AFB9-02C9-BD1E-F7A3-CC50B924B7D2: WL_SC3 @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',        CentralManagerDelegate.py:267
                    'kCBAdvDataServiceUUIDs', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                         
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 2196AFB9-02C9-BD1E-F7A3-CC50B924B7D2: WL_SC3 @ RSSI: -92 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',            CentralManagerDelegate.py:267
                    'kCBAdvDataIsConnectable', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and Central: <CBCentralManager:                              
                    0x6000023b0dc0>                                                                                                                                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -81 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -84 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -81 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -61 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -61 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
    [11:53:24] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -67 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -67 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -90 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
    [11:53:26] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -86 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
    [11:53:27] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -79 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
    [11:53:28] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -84 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -84 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
    [11:53:29] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -59 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
           DEBUG    Discovered device AE0C69FA-B2C5-F841-4A60-85B0CFE09C9A: Govee_H5151_1E8F @ RSSI: -60 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName',     CentralManagerDelegate.py:267
                    'kCBAdvDataManufacturerData', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                     
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
    [11:53:30] DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device BE8E3ACE-A055-6829-7BCB-8C79222AFE75: None @ RSSI: -86 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',          CentralManagerDelegate.py:267
                    'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                                                   
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0dc0>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 0DF90D17-3B41-B621-CEDA-026BCB7B498E: Zwift Click @ RSSI: -93 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',   CentralManagerDelegate.py:267
                    'kCBAdvDataServiceUUIDs', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0dc0>                                         
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 0DF90D17-3B41-B621-CEDA-026BCB7B498E: Zwift Click @ RSSI: -93 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataIsConnectable', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and Central: <CBCentralManager:                              
                    0x6000023b0dc0>                                                                                                                                                                                   
           DEBUG    'isScanning' changed                                                                                                                                                 CentralManagerDelegate.py:212
           INFO     Found Click device with MAC "0DF90D17-3B41-B621-CEDA-026BCB7B498E"                                                                                                                       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 (pulsing blue light)                                                     app.py:245
           DEBUG    centralManagerDidUpdateState_                                                                                                                                        CentralManagerDelegate.py:223
           DEBUG    Bluetooth powered on                                                                                                                                                 CentralManagerDelegate.py:235
           DEBUG    'isScanning' changed                                                                                                                                                 CentralManagerDelegate.py:212
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -84 (kCBAdvData <nsdict_keys(['kCBAdvDataTimestamp', 'kCBAdvDataServiceData',            CentralManagerDelegate.py:267
                    'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and Central: <CBCentralManager:                              
                    0x6000023b0d20>                                                                                                                                                                                   
           DEBUG    Discovered device 98A9DF68-4EE5-2259-D192-30274124F25A: Hatch Naksh @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataTimestamp',       CentralManagerDelegate.py:267
                    'kCBAdvDataServiceData', 'kCBAdvDataRxPrimaryPHY', 'kCBAdvDataIsConnectable', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataLocalName', 'kCBAdvDataServiceUUIDs'])>) and                                 
                    Central: <CBCentralManager: 0x6000023b0d20>                                                                                                                                                       
           DEBUG    centralManager_didDiscoverPeripheral_advertisementData_RSSI_                                                                                                         CentralManagerDelegate.py:283
           DEBUG    Discovered device 0DF90D17-3B41-B621-CEDA-026BCB7B498E: Zwift Click @ RSSI: -92 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataManufacturerData',   CentralManagerDelegate.py:267
                    'kCBAdvDataServiceUUIDs', 'kCBAdvDataRxSecondaryPHY', 'kCBAdvDataTimestamp', 'kCBAdvDataRxPrimaryPHY'])>) and Central: <CBCentralManager: 0x6000023b0d20>                                         
           DEBUG    'isScanning' changed                                                                                                                                                 CentralManagerDelegate.py:212
           DEBUG    CentralManagerDelegate  at <CentralManagerDelegate: 0x10fe61540>                                                                                                                     client.py:134
           DEBUG    Connecting to BLE device @ 0DF90D17-3B41-B621-CEDA-026BCB7B498E                                                                                                                      client.py:135
    [11:53:31] DEBUG    centralManager_didConnectPeripheral_                                                                                                                                 CentralManagerDelegate.py:303
           DEBUG    Retrieving services...                                                                                                                                                               client.py:218
    [11:53:32] DEBUG    peripheral_didDiscoverServices_                                                                                                                                          PeripheralDelegate.py:279
           DEBUG    Services discovered                                                                                                                                                      PeripheralDelegate.py:273
           DEBUG    Retrieving characteristics for service 180A                                                                                                                                          client.py:223
           DEBUG    peripheral_didDiscoverCharacteristicsForService_error_                                                                                                                   PeripheralDelegate.py:315
           DEBUG    Characteristics discovered                                                                                                                                               PeripheralDelegate.py:309
           DEBUG    Retrieving descriptors for characteristic 2A29                                                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 15                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 2A25                                                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 17                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 2A27                                                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 19                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 2A26                                                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 21                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving characteristics for service 00000001-19CA-4651-86E5-FA29DCDD09D1                                                                                                          client.py:223
           DEBUG    peripheral_didDiscoverCharacteristicsForService_error_                                                                                                                   PeripheralDelegate.py:315
           DEBUG    Characteristics discovered                                                                                                                                               PeripheralDelegate.py:309
           DEBUG    Retrieving descriptors for characteristic 00000002-19CA-4651-86E5-FA29DCDD09D1                                                                                                       client.py:232
    [11:53:33] DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 24                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 00000003-19CA-4651-86E5-FA29DCDD09D1                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 27                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 00000004-19CA-4651-86E5-FA29DCDD09D1                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 29                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 00000005-19CA-4651-86E5-FA29DCDD09D1                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 32                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving descriptors for characteristic 00000006-19CA-4651-86E5-FA29DCDD09D1                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 35                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Retrieving characteristics for service 180F                                                                                                                                          client.py:223
           DEBUG    peripheral_didDiscoverCharacteristicsForService_error_                                                                                                                   PeripheralDelegate.py:315
           DEBUG    Characteristics discovered                                                                                                                                               PeripheralDelegate.py:309
           DEBUG    Retrieving descriptors for characteristic 2A19                                                                                                                                       client.py:232
           DEBUG    peripheral_didDiscoverDescriptorsForCharacteristic_error_                                                                                                                PeripheralDelegate.py:354
           DEBUG    Descriptor discovered 39                                                                                                                                                 PeripheralDelegate.py:345
           DEBUG    Services resolved for BleakClientCoreBluetooth (0DF90D17-3B41-B621-CEDA-026BCB7B498E)                                                                                                client.py:253
           DEBUG    Subscribing to ZWIFT_ASYNC_CHARACTERISTIC_UUID                                                                                                                                          app.py:251
           DEBUG    peripheral_didUpdateNotificationStateForCharacteristic_error_                                                                                                            PeripheralDelegate.py:538
           DEBUG    Character Notify Update                                                                                                                                                  PeripheralDelegate.py:529
           DEBUG    Subscribing to ZWIFT_SYNC_TX_CHARACTERISTIC_UUID                                                                                                                                        app.py:253
           DEBUG    peripheral_didUpdateNotificationStateForCharacteristic_error_                                                                                                            PeripheralDelegate.py:538
           DEBUG    Character Notify Update                                                                                                                                                  PeripheralDelegate.py:529
           DEBUG    Subscribing to ZWIFT_UNKNOWN_6_CHARACTERISTIC_UUID                                                                                                                                      app.py:255
           DEBUG    peripheral_didUpdateNotificationStateForCharacteristic_error_                                                                                                            PeripheralDelegate.py:538
           DEBUG    Character Notify Update                                                                                                                                                  PeripheralDelegate.py:529
           DEBUG    Subscribing to BATTERY_LEVEL_CHARACTERISTIC_UUID                                                                                                                                        app.py:257
    [11:53:34] DEBUG    peripheral_didUpdateNotificationStateForCharacteristic_error_                                                                                                            PeripheralDelegate.py:538
           DEBUG    Character Notify Update                                                                                                                                                  PeripheralDelegate.py:529
           INFO     Click device found; Starting connection handshake                                                                                                                                       app.py:261
           DEBUG    Sending: b'RideOn'                                                                                                                                                                      app.py:266
           DEBUG    peripheral_didWriteValueForCharacteristic_error_                                                                                                                         PeripheralDelegate.py:467
           DEBUG    Write Characteristic Value                                                                                                                                               PeripheralDelegate.py:458
           DEBUG    Write Characteristic 00000003-19ca-4651-86e5-fa29dcdd09d1 : b'RideOn'                                                                                                                client.py:335
           INFO     Finished handshake; waiting for input (press `Ctrl-C` to exit)     

I will debug and update as necessary, perhaps w/ a fork and PR.

jat255 commented 5 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.

goodhuntergood commented 1 month ago

hi @jnmandal any progress on the project? I would love to use this too on my mac mini.

kpotschi commented 1 week ago

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.}              ```
renekar commented 1 week ago

any progress on the MAC version? I've tried but failed at the compatible phyton version..

Bildschirmfoto 2024-10-25 um 11 55 06

ok... I only to include 3.13, but now failing the next step

Bildschirmfoto 2024-10-25 um 12 20 00