Reputation: 590
I am using bleak to connect to a GATT server and gather packets transmitted from a peripheral. The server is set up using notifications, so I am registering a callback with the function start_notify
to capture those bytes produced by the characteristic and log them. The characteristic that is handled by this particular callback sends 200 bytes at regular intervals. I am able to
However, it seems that I am only collecting a fraction on the bytes that are available. The call to start notifications looks like
await self.client.start_notify(self.data, self.data_notification_cb, )
and the actual call back looks like
def data_notification_cb(self, sender: str, data: str):
hdata = binascii.hexlify(data)
print("Current data value is %s" % hdata)
self.write_voice.write(hdata)
The data produced by the server looks like
b8 5b 2e 64 ab 77 5e d3 05 08 27 39 8e 9d 3d 2a
e1 0d bf 3c bf 19 5f 44 05 86 e7 35 98 22 a7 9f
cc e1 aa 4d 5b b4 5e 5b b2 91 e8 98 8e 0f 38 92
78 b9 90 0f 2b 62 e7 5f 56 e8 83 83 65 e8 56 32
81 48 85 11 cc cd c3 a6 e8 6b 49 d9 77 b4 b4 34
b7 87 f2 eb 9c 05 7e 65 52 36 98 20 b2 9b 64 d8
fc d2 92 e1 cd fd f5 e5 81 9a 97 5b a9 f0 98 6c
6b ca 08 0c 77 19 34 4d 93 25 8e 5a 31 a9 9f a7
53 fd 7a 1e b7 97 44 e5 d4 25 02 42 04 b6 e0 7b
06 b7 ea 96 77 7b 0f 8c 63 ca 7e bd 3e 52 a1 a0
82 50 29 dc 6b 0e 3a 1d 68 92 21 88 0c b7 54 b8
8c f3 16 ed 4b 78 3c a3 2d 78 ba 09 b3 25 d1 c9
ec af 0c d9 7a 0d a9 b1
while the data that is returned by the call back is truncated like so
b'b85b2e64ab775ed3050827398e9d3d2ae10dbf3c'
so that at most it gives back 19 bytes. Has anyone seen this before? Am I misconfiguring this callback so that it only gets a subset of the available bytes?
Upvotes: 1
Views: 586
Reputation: 2673
It seems like the BLE adapter of the device you are running your script on (probably a Notebook) is only capable of BLE 4.0. According to this answer BLE 4.0 only supports up to 20 bytes per notification.
You could use a different device thats capable of a higher BLE version to check if everything else works. I recommend the nRF Connect App for your mobile device.
If everything works on your mobile device the use of a USB BLE adapter could help you achieve your goals.
Upvotes: 1