kevincar / bless

Cross-platform Bluetooth Low Energy Server Python Library
MIT License
86 stars 28 forks source link

QUESTION: read_request() and write_request(); data not received by Collector (client) #72

Closed WouterJD closed 2 years ago

WouterJD commented 2 years ago

Description

I am writing a Fitness Machine Server and to be able to debug the server, also a Collector (client).

The server is based upon bless\examples\gattserver.py The collector is based upon bleak\examples\discover.py, service_explorer.py

What is already working

The service is already detected by a standard training software, such as Trainer Road. The first read_request() and write_request() callbacks are called, but the response does not arrive at client-side.

What is NOT yet working

read_request() and write_request() are correctly called and can be processed.

QUESTION: Refer to code below (unchanged from gattserver.py); How should read_request() and write_request() respond, so that the collector actually receives the data. Should "server.update_value(sUUID, cUUID)" be called?

def read_request(
        characteristic: BlessGATTCharacteristic,
        **kwargs
        ) -> bytearray:
    logger.debug(f"Reading {characteristic.value}")
    return characteristic.value

def write_request(
        characteristic: BlessGATTCharacteristic,
        value: Any,
        **kwargs
        ):
    characteristic.value = value
    logger.debug(f"Char value set to {characteristic.value}")
    if characteristic.value == b'\x0f':
        logger.debug("Nice")
        trigger.set()
WouterJD commented 2 years ago

GATT Server is now working.