pygattlib icon indicating copy to clipboard operation
pygattlib copied to clipboard

Cannot recieve more than 257 bytes using read_by uuid

Open primus192 opened this issue 3 years ago • 0 comments

Hi. I have got a problem with reading characteristic using read_by_uuid function.

This is full characteristic value:

239425535_237740064896546_4954214041111378117_n

Here is my code:

from gattlib import DiscoveryService import sys from gattlib import GATTRequester

service = DiscoveryService() devices = service.discover(2)

for address, name in list(devices.items()): print("name: {}, address: {}".format(name, address))

print("Done.")

requester = GATTRequester("4C:11:AE:76:2A:16") data = requester.read_by_uuid("1ff045a9-a049-4e41-92c7-e5d784a29e86")

print(data)

That way, when i print data, i got only first 20 bytes of the uuid.

print(data) [b'{"version":"0.1.52"']

I searched the Internet for the possible solution, and i came up with the idea of changing MTU size using command exchange_mtu(). When i add exchange_mtu(257) to the code before read_by_uuid() i got output like this:

print(data) [b'{"version":"0.1.52","mode":1,"brightness":0,"position":0,"treshold":100,"lt":0,"warm":false,"wifi":"false","isGsm":"false","gsm":"true","ssid":"EG_WiFi","password":"eGminy123","Apn":"playmetric","User":"","PAssword":"","gsmPin":"","wifiConnected":"false']

Better but it still is not full message. I tried to increase exchanche_mtu(number) to like 300. (it must be between 23-512).

When i increase it past 257 i got an error like this:

requester.exchange_mtu(258) 258 data = requester.read_by_uuid("1ff045a9-a049-4e41-92c7-e5d784a29e86") Traceback (most recent call last): File "", line 1, in gattlib.GATTException: Characteristic value/descriptor operation failed: The operation was aborted

Can you help me face this issue?

primus192 avatar Aug 26 '21 09:08 primus192