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

Problem with function client.write_gatt_char() #71

Closed
Szymon-Gesicki opened this issue Jun 6, 2019 · 2 comments
Closed

Problem with function client.write_gatt_char() #71

Szymon-Gesicki opened this issue Jun 6, 2019 · 2 comments

Comments

@Szymon-Gesicki
Copy link

Szymon-Gesicki commented Jun 6, 2019

  • bleak version: 0.4.2
  • Python version: 3.7
  • Operating System: win 10

I am trying to communicate to device by bluetooth. I have the UUID, also I'm doing everything that you showed in issue #59 but no matter what I'm typing to 'data' in function client.write_gatt_char it shows me this type of error:
"Could not write value 'data' to characteristic"
I've tried bytes or bytearray, but everything ends with the same error.
I decided to comment this function. Unfortunately, the function callback has never been called.
My code:

def callback(sender, data):
    print(f"{sender}: {data}")

async def run(address, loop, debug=False):
    log = logging.getLogger(__name__)
    if debug:
        import sys
        loop.set_debug(True)
        log.setLevel(logging.DEBUG)
        h = logging.StreamHandler(sys.stdout)
        h.setLevel(logging.DEBUG)
        log.addHandler(h)

    async with BleakClient(address, loop=loop) as client:
        x = await client.is_connected()
        log.info("Connected: {0}".format(x))
        write_value = bytearray([0xa0])
        rw_charac = uuid.UUID('49365E80-CF3A-11E1-9AB4-0002A5D5C51B')
        await client.get_services()
        await client.start_notify(rw_charac, callback)
        #await client.write_gatt_char(rw_charac, write_value, response=True)
        await asyncio.sleep(0.5, loop=loop)
        await client.stop_notify(rw_charac)

if __name__ == "__main__":
    address = "9D:1C:2D:D3:E6:85"
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(address, loop, True))
@Surgavery
Copy link

Hi Szymon-Gesicki,

I have similar problem when using version 0.4.2. I suggest you try to downgrade the bleak version to 0.4.0.

@Huygon
Copy link

Huygon commented Oct 23, 2023

How do you solve your problem @Szymon-Gesicki ? thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants