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

missing notification when subscribed --or-- not all data received from notificaitons #297

Open
snyderra opened this issue Oct 2, 2020 · 1 comment

Comments

@snyderra
Copy link

snyderra commented Oct 2, 2020

When subscribed, only the first notification of 20 bytes are received and the second notification is ignored. When not subscribed both notifications are received after a char_read_long. Trying to get all the data from notifications (this is how it works on mobile devices)

Subscribed (only first 20 bytes received):

DEBUG:pygatt.device:Looking up handle for characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e
DEBUG:pygatt.device:Found <Characteristic uuid=6e400003-b5a3-f393-e0a9-e50e24dcca9e handle=18>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
INFO:pygatt.device:Subscribed to uuid=6E400003-B5A3-F393-E0A9-E50E24DCCA9E
ready to write

writing: 540003a9
DEBUG:pygatt.device:Looking up handle for characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e
DEBUG:pygatt.device:Found <Characteristic uuid=6e400002-b5a3-f393-e0a9-e50e24dcca9e handle=16>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
INFO:pygatt.device:Received notification on handle=0x12, value=0xb'022302044fe2010000000001640102000000f286'
02 23 02 04 4f e2 01 00 00 00 00 01 64 01 02 00 00 00 f2 86
DEBUG:pygatt.backends.bgapi.device:Disconnecting from F2:86:DC:85:CE:E4
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.connection_disconnect: 29>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_attribute_value packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:attribute handle = 12
DEBUG:pygatt.backends.bgapi.bgapi:attribute type = 1
DEBUG:pygatt.backends.bgapi.bgapi:attribute value = 0xb'022302044fe2010000000001640102000000f286'
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.connection_status packet: Success
INFO:pygatt.backends.bgapi.bgapi:Connection status: handle=0x0, flags=9, address=0xb'e4ce85dc86f2', connection interval=30.000000ms, timeout=8000, latency=2 intervals, bonding=0xff
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.connection_disconnect packet: Success
INFO:pygatt.backends.bgapi.device:Disconnected from F2:86:DC:85:CE:E4
INFO:pygatt.backends.bgapi.bgapi:Stopping
INFO:pygatt.backends.bgapi.bgapi:Stopping receiver


Not Subscribed after a read long (expected output __bold__:

writing: 540003a9
DEBUG:pygatt.device:Looking up handle for characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e
DEBUG:pygatt.device:Found <Characteristic uuid=6e400002-b5a3-f393-e0a9-e50e24dcca9e handle=16>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
DEBUG:pygatt.device:Looking up handle for characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e
DEBUG:pygatt.device:Found <Characteristic uuid=6e400003-b5a3-f393-e0a9-e50e24dcca9e handle=18>
INFO:pygatt.backends.bgapi.device:Reading long characteristic at handle 18
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_read_long: 46>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_read_long packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_attribute_value: 21>, <EventPacketType.attclient_procedure_completed: 17>] within 1.000000s
__INFO:pygatt.device:Received notification on handle=0x12, value=0xb'022302044fe8010000000001640102000000f286dc85'__
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_attribute_value packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:attribute handle = 12
DEBUG:pygatt.backends.bgapi.bgapi:attribute type = 4
DEBUG:pygatt.backends.bgapi.bgapi:attribute value = 0xb'022302044fe8010000000001640102000000f286dc85'
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_attribute_value: 21>, <EventPacketType.attclient_procedure_completed: 17>] within 1.000000s
__INFO:pygatt.device:Received notification on handle=0x12, value=0xb'cee419dc209e0e481973190814110708c0'__
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_attribute_value packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:attribute handle = 12
DEBUG:pygatt.backends.bgapi.bgapi:attribute type = 4
DEBUG:pygatt.backends.bgapi.bgapi:attribute value = 0xb'cee419dc209e0e481973190814110708c0'
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_attribute_value: 21>, <EventPacketType.attclient_procedure_completed: 17>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
__02 23 02 04 4f e8 01 00 00 00 00 01 64 01 02 00 00 00 f2 86 dc 85 ce e4 19 dc 20 9e 0e 48 19 73 19 08 14 11 07 08 c0__
DEBUG:pygatt.backends.bgapi.device:Disconnecting from F2:86:DC:85:CE:E4
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.connection_disconnect: 29>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.connection_status packet: Success
INFO:pygatt.backends.bgapi.bgapi:Connection status: handle=0x0, flags=9, address=0xb'e4ce85dc86f2', connection interval=30.000000ms, timeout=8000, latency=2 intervals, bonding=0xff
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.connection_disconnect packet: Success
INFO:pygatt.backends.bgapi.device:Disconnected from F2:86:DC:85:CE:E4
INFO:pygatt.backends.bgapi.bgapi:Stopping
INFO:pygatt.backends.bgapi.bgapi:Stopping receiver
@imranmoezkhan
Copy link

imranmoezkhan commented Mar 1, 2021

Have you requested for the server to change the mtu size? BLE notification packet sizes are by default 20 bytes. Longer data sequences can be received after sending an exchange_mtu() request. After connecting to the device, add this command (to change to 64 bytes, or put any number that you want):
mtu=device.exchange_mtu(64)

The mtu variable will contain the new maximum transmission unit size that the server has successfully configured to.

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

2 participants