简体   繁体   English

Peripheral.setMTU(244) 但只能得到 20 个字节

[英]Peripheral.setMTU(244) but can get only 20 bytes

I want to read more than 20 bytes of data from bluetooth to raspberry pi 3b+.我想从蓝牙读取超过 20 个字节的数据到树莓派 3b+。 I override DefaultDelegate and handleNotification(cHandle, data) , and get data from handleNotification(cHandle, data) .我覆盖DefaultDelegatehandleNotification(cHandle, data) ,并从handleNotification(cHandle, data)获取数据。 Then I convert type of data from byte to hex, and I can only get 20 bytes of data.然后我将数据类型从字节转换为十六进制,我只能得到 20 个字节的数据。

Here is my code:这是我的代码:

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

My BLE peripheral device is "Nordic NRF52832".我的 BLE 外围设备是“Nordic NRF52832”。 How can I get more than 20 bytes of data?如何获得超过 20 个字节的数据?

I think I find the reason of it.我想我找到了原因。 Library bluepy supports BLE4.0 but don't support BLE4.2 .bluepy支持BLE4.0但不支持BLE4.2 BLE4.0 and BLE4.1 can get the payload for only 20 bytes. BLE4.0BLE4.1只能获得 20 字节的有效载荷。

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来源: https : //github.com/IanHarvey/bluepy/issues/325

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MemoryError: 无法分配形状为 (200, 20, 244, 244, 3) 和数据类型为 float64 的数组 - MemoryError: Unable to allocate array with shape (200, 20, 244, 244, 3) and data type float64 如何获得形状为(32,224,224)的np数组,其中[0]包含(244,224)1个和[1]仅2个? - how to get an np array of shape (32,224,224) where [0] contains (244,224) 1's and [1] only 2's? 只能将str(不是“ bytes”)连接到str - can only concatenate str (not “bytes”) to str 只能串联列表(不是“字节”)以列出 - can only concatenate list (not “bytes”) to list Python-可以总线,仅获取字节吗? - Python-Can Bus, grab only the bytes? 只能将 str (不是“字节”)连接到 str - can only concatenate str (not "bytes") to str python 3:只能将 str(不是“字节”)连接到 str - python 3: can only concatenate str (not “bytes”) to str TypeError:只能将 str(不是“字节”)连接到 str - TypeError: can only concatenate str (not “bytes”) to str 如何在 Python 中获得 10**20 + 10**-20 的确切结果? 它给了我 1e+20 - How can I get the exact result of 10**20 + 10**-20 in Python? It gives me 1e+20 我从传感器收到串行数据,我只想要最后 20 个字节的数据,并希望将其保存在文件中 - I recieved Serial data from sensor what i want only last 20 bytes of data and want to save it in a file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM