Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Service and Characteristic Handles #29

@kevincar

Description

@kevincar

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.

Metadata

Metadata

Assignees

Labels

backend: CoreBluetoothProblem specific to CoreBluetoothbackend: WinRTProblem specific to WinRTbugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions