pygattlib icon indicating copy to clipboard operation
pygattlib copied to clipboard

Can't send more than 20 bytes

Open svez01 opened this issue 2 years ago • 1 comments

I have increased the MTU size. This allows me to receive more than 20 bytes of data. However, I still can't send more than 20 bytes.

Output from python console:

>>> from gattlib import GATTRequester

>>> requester = GATTRequester("A1:D8:FE:0C:42:B0", True)

>>> requester.exchange_mtu(185)
185

>>> requester.write_by_handle(0x09, bytes.fromhex('0100'))
[b'\x13']

>>> requester.write_by_handle(0x06, bytes.fromhex("FEFE03010200"))
[b'\x13']
on notification, handle: 0x8 -> 00:fe:fe:21:01:00:01:00:00:fe:14:ec:02:00:00:00:00:fd:00:ff:64:0e:02:ec:28:d8:02:00:00:fd:00:ed:01:00:00:0a:68:

>>> requester.write_by_handle(0x06, bytes.fromhex("FEFE1C0200010000FE14EC0200000000FD00EC28D8020000FD000000000803"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
gattlib.GATTException: Characteristic value/descriptor operation failed: Attribute can't be written

The previous steps are successful using the interactive gatttool:

sudo gatttool -i hci0 -b A1:D8:FE:0C:42:B0 -I

[A1:D8:FE:0C:42:B0][LE]> connect
Attempting to connect to A1:D8:FE:0C:42:B0
Connection successful

[A1:D8:FE:0C:42:B0][LE]> mtu 185
MTU was exchanged successfully: 185

[A1:D8:FE:0C:42:B0][LE]> char-write-req 09 0100
Characteristic value was written successfully

[A1:D8:FE:0C:42:B0][LE]> char-write-req 06 FEFE03010200
Characteristic value was written successfully
Notification handle = 0x0008 value: fe fe 21 01 00 01 00 00 fe 14 ec 02 00 00 00 00 fd 00 00 64 0e 02 ec 28 d8 02 00 00 fd 00 ed 00 00 00 09 68 

[A1:D8:FE:0C:42:B0][LE]> char-write-req 06 FEFE1C0200010000FE14EC0200000000FD00EC28D8020000FD000000000803
Characteristic value was written successfully
Notification handle = 0x0008 value: fe fe 21 02 00 01 00 00 fe 14 ec 02 00 00 00 00 fd 00 00 64 0e 02 ec 28 d8 02 00 00 fd 00 ed 00 00 00 09 69 

svez01 avatar Jun 22 '22 14:06 svez01

For me the limit was 23 bytes (the default MTU) and it turns out i also need to call set_mtu in addition to exchange_mtu

nielsole avatar Nov 06 '22 06:11 nielsole