Giter Club home page Giter Club logo

Comments (6)

hbldh avatar hbldh commented on August 23, 2024

You have forgotten an await before client.write_gatt_char; that method is still a coroutine. It might be the reason for the FileLoadException, but I am not sure.

I just released verion 0.4.0 of bleak; install that from PyPI and run the service_explorer.py example on your peripheral and show me your output here. It should display all services and characteristics discovered on the peripheral, similar to Bluetooth LE Explorer.

In 0.4.0, the client.services now returns a BleakGATTServiceCollection which should be simpler to handle than the .NET objects returned in v0.3.0.

from bleak.

skjerns avatar skjerns commented on August 23, 2024

Thanks for the fast reply!

With this output, all services and their characteristics get printed as expected, just like in Bluetooth LE Explorer :) and it doesn't throw the UUID not found Exception anymore when paging the rw_charac.

However, when I request a write operation with response, I get no response:

await client.write_gatt_char(rw_charac, b'~HELLO', response=True)
# nothing happens. also running the script above again, no Value is put out

Output of the service_explorer:

click me

[Service] 00001800-0000-1000-8000-00805f9b34fb: Generic Access Profile
        [Characteristic] 00002a00-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'DeviceName' 
        [Characteristic] 00002a01-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'\x00\x00' 
[Service] 00001801-0000-1000-8000-00805f9b34fb: Generic Attribute Profile
        [Characteristic] 00002a05-0000-1000-8000-00805f9b34fb: (indicate) | Name: , Value: None 
                [Descriptor] 00002902-0000-1000-8000-00805f9b34fb: (Handle: 15) | Value: b'\x00\x00' 
[Service] 0000180a-0000-1000-8000-00805f9b34fb: Device Information
        [Characteristic] 00002a29-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'Microchip' 
        [Characteristic] 00002a24-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'RNXXXX' 
        [Characteristic] 00002a25-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'0000' 
        [Characteristic] 00002a27-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'5505 1XXX3' 
        [Characteristic] 00002a26-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'XXXXX' 
        [Characteristic] 00002a28-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'X.XX' 
        [Characteristic] 00002a23-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'\x00\x00\x00\x00\x00\x00\x00\x00' 
        [Characteristic] 00002a2a-0000-1000-8000-00805f9b34fb: (read) | Name: , Value: b'\x00\x00\x00\x00\x01\x00\x00\x00' 
[Service] 49535343-fe7d-4ae5-8fa9-9fafd205e455: Unknown
        [Characteristic] 49535343-1e4d-4bd9-ba61-23c647249616: (write-without-response,write,notify,indicate) | Name: , Value: None 
                [Descriptor] 00002902-0000-1000-8000-00805f9b34fb: (Handle: 83) | Value: b'\x00\x00' 
        [Characteristic] 49535343-8841-43f4-a8d4-ecbe34729bb3: (write-without-response,write) | Name: , Value: None 
        [Characteristic] 49535343-4c8a-39b3-2f49-511cff073b7e: (write,notify) | Name: , Value: None 
                [Descriptor] 00002902-0000-1000-8000-00805f9b34fb: (Handle: 88) | Value: b'\x00\x00' 

from bleak.

hbldh avatar hbldh commented on August 23, 2024

The response=True mean that the write method is used rather than the write-without-response. The response does not contain anything special though (https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.genericattributeprofile.gattwriteresult), so nothing is returned by the write_gatt_char method.

You can check the value of your characteristic by a read afterwards to verify that your data has been written:

value = await client.read_gatt_char(rw_charac)
print("Pre-Write Value: {0}".format(value))
await client.write_gatt_char(rw_charac, b'~HELLO', response=True)
value = await client.read_gatt_char(rw_charac)
print("Post-Write Value: {0}".format(value))

from bleak.

skjerns avatar skjerns commented on August 23, 2024

Somehow I can't read from this characteristic.

BleakError: Could not read characteristic value for 49535343-1e4d-4bd9-ba61-23c647249616: 2

which makes sense, as permissions for this attribute are
(write-without-response,write,notify,indicate)

from bleak.

hbldh avatar hbldh commented on August 23, 2024

Ah, i did not see that; of course it fails. The read was not important anyway, it was just meant to visualize what the write achieved.

The issue in general is to be regarded as closed then? There is nothing left to solve of the original request is there?

from bleak.

skjerns avatar skjerns commented on August 23, 2024

Yes, I'll open another issue for the non-response :) thank's!

from bleak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.