蓝牙LE最大传输大小 [英] Bluetooth LE maximum transmission size

查看:120
本文介绍了蓝牙LE最大传输大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在与Bluetooth LE合作,并希望向gatt服务发送128个字符串.

We are currently working with Bluetooth LE and want to send a 128 character string to a gatt service.

现在,蓝牙规范说BLE的最大数据包大小为22个字节,我的字符串将永远无法容纳在数据包中.

Now the Bluetooth Specs say that the maximum packet size of BLE is 22 bytes, my string will never fit in the packet.

我们正在考虑将其分块并在迭代中发送.

We are thinking about chunking it up and send it in iterations.

这是惯常的做事方式吗?

Is this the usual way of doing things?

推荐答案

是的,您需要将数据分块为18个字节,然后将一系列Prepare Write Request发送到服务器.每个请求都有3个参数:

Yes, you need to chunk the data into 18 bytes pieces, then send a series of Prepare Write Requests to the Server. Each of this request has 3 parameters:

  • 属性句柄(2个字节)
  • 属性偏移量(2个字节)
  • 数据部分(最多18个字节)

因此,您将首先发送偏移量为0的数据包,然后发送偏移量为18的数据包,然后发送36等. 当您这样做时,服务器会将所有请求排队.

So you would first send a packet with offset 0, then a packet with offset 18, then 36 etc. When you do that, the Server queues all your requests.

最后,您发送一个Execute Write Request,服务器将所有字节写入一次.

In the end, you send an Execute Write Request and the Server writes all the bytes in one shot.

这篇关于蓝牙LE最大传输大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆