bgapi
bgapi copied to clipboard
Read Blob not supported
"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.
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.
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.
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