2

I want to read more than 20 bytes of data from bluetooth to raspberry pi 3b+. I override DefaultDelegate and handleNotification(cHandle, data), and get data from handleNotification(cHandle, data). Then I convert type of data from byte to hex, and I can only get 20 bytes of data.

Here is my code:

dev = btle.Peripheral(address, 'random')
dev.setMTU(244)

My BLE peripheral device is "Nordic NRF52832". How can I get more than 20 bytes of data?

陳香君
  • 39
  • 2
  • 10

2 Answers2

1

Adding delay worked for me :

dev = btle.Peripheral(address, 'random')
import time
time.sleep(1)
dev.setMTU(244)

source: https://github.com/IanHarvey/bluepy/issues/325

0

I think I find the reason of it. Library bluepy supports BLE4.0 but don't support BLE4.2. BLE4.0 and BLE4.1 can get the payload for only 20 bytes.

陳香君
  • 39
  • 2
  • 10
  • MTU has nothing to do with Bluetooth version. In fact, Bluetooth 4.0 supports 64 KB MTU. – Emil Nov 28 '19 at 08:45
  • @Emil I think BLE is different from normal Bluetooth, is it? – 陳香君 Nov 29 '19 at 10:53
  • Yes it's a completely different radio protocol. – Emil Nov 29 '19 at 12:28
  • @Emil Do BLE4.0 supports more than 20 bytes of payload data? – 陳香君 Nov 30 '19 at 13:58
  • In Bluetooth 4.0, the BLE Link Layer supports up to 27 bytes payload per packet. In version 4.2 LE Data Length Extension was introduced which increases the maximum payload size of the Link Layer to 251 bytes (must be negotiated between the two devices). The link layer payload size is irrelevant and transparent to the application. To the application only the ATT MTU is relevant and all BLE versions support ATT MTU up to 65535 bytes. The devices however need to negotiate a max MTU if you want to use an MTU higher of 23 (which is default). So it's possible your peripheral sticks to default MTU. – Emil Nov 30 '19 at 15:00