xiaoyaoyou1212 / BLE

✨Android BLE基础操作框架,基于回调,操作简单。包含扫描、多连接、广播包解析、服务读写及通知等功能。
http://www.huwei.tech/
Apache License 2.0
1.38k stars 364 forks source link

为什么发送数据要限制20个字节 #58

Open chengxinping opened 6 years ago

chengxinping commented 6 years ago

RT 为什么发送数据要限制20个字节

SawXu commented 6 years ago

因为默认MTU情况下,BLE一个包最多只能发20个字节。 有个requestMTU接口可以尝试修改。 https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestMtu(int)

flyzhangyx commented 3 years ago

Min MTU in LE-U (L2CAP) is 23 octects, 当你使用ATT Write CMD的时候,Payload就有一个字节的Opcode+两个字节的Handle,留给你的Parameter就只剩MTU-3=20字节了