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

Read Blob not supported #37

Open
jrluppold opened this issue Nov 28, 2017 · 3 comments
Open

Read Blob not supported #37

jrluppold opened this issue Nov 28, 2017 · 3 comments

Comments

@jrluppold
Copy link

"Read (handle)" is currently implemented and only supports a max payload of 22 bytes.
According to Bluegiga documentation "Read Blob (handle, offset)" has a max payload of 64 kBytes.

Unless I'm missing something there is no way to Read Blob with this python module.

@mjbrown
Copy link
Owner

mjbrown commented Nov 29, 2017

Bluetooth low energy has a maximum characteristic size of something like 512 bytes.

Bluegiga has Bluetooth Classic modules as well. Perhaps you are reading documentation for one of those.

@jrluppold
Copy link
Author

I'm referring to page 27 of the linked pdf.
https://www.silabs.com/documents/login/reference-manuals/Bluetooth_Smart_Software-BLE-1.4-API-RM.pdf

I ran into an issue reading the characteristic of a device, where the data returned was greater than 22 bytes. The data returned was cut off after 22 bytes. According to that pdf there is a read blob that handles payloads larger than 22 bytes.

That being said the documentation goes on to explain that "Read Long" should be used to read characteristic longer than 22 bytes and so far I've not got that to work for me either.

@pckbls
Copy link

pckbls commented Jul 18, 2019

If someone else stumbles across this issue, using the "Read Long" method is indeed the correct way to read out larger characteristics. The client will then perform successive reads and transmit the data in smaller chunks. Unfortunately bgapi does not properly concatenate the received data and instead always stores the last received chunk.

The following (hacky) code snippet may act as a workaround though:

def read_long_by_handle_properly(connection, handle):
    result = b''

    def custom_callback(value):
        nonlocal result
        print('Received long read chunk: {0}'.format(value))
        result += value

    connection.attrclient_value_cb[handle] = custom_callback
    connection.read_long_by_handle(handle)
    del connection.attrclient_value_cb[handle]

    return result

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