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

Service and Characteristic Handles #29

Closed
kevincar opened this issue Mar 30, 2021 · 2 comments
Closed

Service and Characteristic Handles #29

kevincar opened this issue Mar 30, 2021 · 2 comments
Assignees
Labels
backend: CoreBluetooth Problem specific to CoreBluetooth backend: WinRT Problem specific to WinRT bug Something isn't working

Comments

@kevincar
Copy link
Owner

The problem

self = <bleak.backends.corebluetooth.service.BleakGATTServiceCoreBluetooth object at 0x7fade9a57460>
obj = <CBMutableService: 0x7fade91507c0 Primary = YES, UUID = A438A1A6-47C0-4FD1-88BE-4531A1BAB891, Included Services = (null), Characteristics = (null)>

    def __init__(self, obj: CBService):
        super().__init__(obj)
        self.__characteristics = []
        # N.B. the `startHandle` method of the CBService is an undocumented Core Bluetooth feature,
        # which Bleak takes advantage of in order to have a service handle to use.
>       self.__handle = int(self.obj.startHandle())
E       TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

/usr/local/anaconda3/envs/bless_test/lib/python3.8/site-packages/bleak/backends/corebluetooth/service.py:20: TypeError

This behavior is a result of this recent bleak pull request. It seems that when a new CBService is initialized before setting the server in motion that the service does not yet own a handle

Reproduction

TEST_HARDWARE=True python -m pytest -s -k server

Desktop

  • OS: macOS

Proposed Solution

Create a BlessGATTServiceCoreBluetooth rather than bleak. This will allow us to get the service created, and potentially handle "handles" later.

@kevincar kevincar added bug Something isn't working backend: CoreBluetooth Problem specific to CoreBluetooth labels Mar 30, 2021
@kevincar kevincar self-assigned this Mar 30, 2021
@kevincar
Copy link
Owner Author

This is also occurring on Windows

  File "C:\tools\miniconda3\envs\bless\lib\site-packages\bleak\backends\dotnet\characteristic.py", line 70, in handle
    return int(self.obj.AttributeHandle)
AttributeError: 'GattLocalCharacteristic' object has no attribute 'AttributeHandle'

@kevincar kevincar changed the title macOS Add new service error Service and Characteristic Handles Mar 31, 2021
@kevincar kevincar added the backend: WinRT Problem specific to WinRT label Mar 31, 2021
@kevincar
Copy link
Owner Author

Closing with #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: CoreBluetooth Problem specific to CoreBluetooth backend: WinRT Problem specific to WinRT bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant