<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[FR303x 连接之后，如果你想一包数据不分包发送最大值要怎么修改？]]></title><description><![CDATA[<p>答：当你MTU交互512字节之后，当你发一包512字节数据，底层可能不是一包就给你发出去，可能是分包发出去，这时候你测吞吐量的话就会影响。那么正确的做法就是使用ble_api_err_t gap_ll_pkt_size_exchange_req(struct gap_ll_pkt_size_exchange_req *req);这个函数去交互用于在链接层上交换最大数据包长度。<br />
<img src="/assets/uploads/files/1756883411745-a40ce660-3095-43c9-985b-392779fdb2ad-976c370a0a020774e1d056359bae6891-resized.png" alt="0_1756883411100_a40ce660-3095-43c9-985b-392779fdb2ad-976c370a0a020774e1d056359bae6891.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://www.freqchip.net:4567/topic/1441/fr303x-连接之后-如果你想一包数据不分包发送最大值要怎么修改</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 11:23:48 GMT</lastBuildDate><atom:link href="http://www.freqchip.net:4567/topic/1441.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 03 Sep 2025 07:11:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to FR303x 连接之后，如果你想一包数据不分包发送最大值要怎么修改？ on Invalid Date]]></title><description><![CDATA[<p>答：当你MTU交互512字节之后，当你发一包512字节数据，底层可能不是一包就给你发出去，可能是分包发出去，这时候你测吞吐量的话就会影响。那么正确的做法就是使用ble_api_err_t gap_ll_pkt_size_exchange_req(struct gap_ll_pkt_size_exchange_req *req);这个函数去交互用于在链接层上交换最大数据包长度。<br />
<img src="/assets/uploads/files/1756883411745-a40ce660-3095-43c9-985b-392779fdb2ad-976c370a0a020774e1d056359bae6891-resized.png" alt="0_1756883411100_a40ce660-3095-43c9-985b-392779fdb2ad-976c370a0a020774e1d056359bae6891.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://www.freqchip.net:4567/post/3252</link><guid isPermaLink="true">http://www.freqchip.net:4567/post/3252</guid><dc:creator><![CDATA[Mars]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to FR303x 连接之后，如果你想一包数据不分包发送最大值要怎么修改？ on Invalid Date]]></title><description><![CDATA[<p>你这个函数是 <strong>LL Data Length Extension (DLE)</strong> 的接口，作用是设置本端 <strong>Link Layer</strong> 最大发送数据包的长度和时间。</p>
<p>我们来拆解一下：</p>
<pre><code class="language-c">typedef struct gap_ll_pkt_size_exchange_req {
    uint8_t     conidx;     //!&lt; 连接索引
    uint16_t    tx_octets;  //!&lt; 最大发送字节数 (payload)
    uint16_t    tx_time;    //!&lt; 最大发送时长 (微秒)
} gap_ll_pkt_size_exchange_req_t;

ble_api_err_t gap_ll_pkt_size_exchange_req(struct gap_ll_pkt_size_exchange_req *req);
</code></pre>
<hr />
<h3><img
      src="http://www.freqchip.net:4567/plugins/nodebb-plugin-emoji/emoji/android/1f4cc.png?v=chgjecujl06"
      class="not-responsive emoji emoji-android emoji--pushpin"
      title=":pushpin:"
      alt="📌"
    /> 关键点</h3>
<ol>
<li>
<p><strong>tx_octets</strong>：想发的最大字节数，单位是字节，最大 251（BLE 规范限制 LL payload ≤ 251）。</p>
<ul>
<li>如果你想在 <strong>ATT 层</strong>发 512 字节，需要 <strong>分片传输</strong>（ATT MTU 扩展 + L2CAP 拆包）。</li>
<li>这里 <code>tx_octets</code> 不能直接设成 512，而是设成 <strong>最大允许的 251</strong>。</li>
</ul>
</li>
<li>
<p><strong>tx_time</strong>：允许的最大发送时间，单位是微秒。</p>
<ul>
<li>
<p>计算公式大致是：</p>
<pre><code>tx_time ≈ (tx_octets + 14) * 8  （PHY = 1M）
tx_time ≈ (tx_octets + 14) * 8 / 2  （PHY = 2M）
</code></pre>
<p>（+14 是 Link Layer header + MIC 等开销）</p>
</li>
<li>
<p>举例：</p>
<ul>
<li>1M PHY 下，251 字节：<code>(251+14)*8 ≈ 2120 us</code></li>
<li>2M PHY 下，251 字节：约 <code>1060 us</code></li>
</ul>
</li>
</ul>
</li>
</ol>
<hr />
<h3><img
      src="http://www.freqchip.net:4567/plugins/nodebb-plugin-emoji/emoji/android/1f4cc.png?v=chgjecujl06"
      class="not-responsive emoji emoji-android emoji--pushpin"
      title=":pushpin:"
      alt="📌"
    /> 你要传 <strong>512 字节</strong></h3>
<ul>
<li><strong>MTU/ATT 层</strong>：需要先做 <code>ATT_MTU_EXCHANGE</code>，把 MTU 提升到 ≥ 517（这样 ATT 一次最多可传 512）。</li>
<li><strong>LL 层 (DLE)</strong>：只能设 <code>tx_octets = 251</code>，剩下的 512 会自动拆成两包传输。</li>
</ul>
<hr />
<h3><img
      src="http://www.freqchip.net:4567/plugins/nodebb-plugin-emoji/emoji/android/1f4cc.png?v=chgjecujl06"
      class="not-responsive emoji emoji-android emoji--pushpin"
      title=":pushpin:"
      alt="📌"
    /> 示例代码</h3>
<pre><code class="language-c">gap_ll_pkt_size_exchange_req_t dle_req;
dle_req.conidx = 0;          // 假设是第 0 个连接
dle_req.tx_octets = 251;     // 最大 251，BLE 规范限制
dle_req.tx_time   = 2120;    // 1M PHY 下，251字节大概需要2120us

ble_api_err_t ret = gap_ll_pkt_size_exchange_req(&amp;dle_req);
if (ret != BLE_API_OK) {
    printf(&quot;DLE request failed: %d\n&quot;, ret);
}
</code></pre>
<hr />
<p><img
      src="http://www.freqchip.net:4567/plugins/nodebb-plugin-emoji/emoji/android/2705.png?v=chgjecujl06"
      class="not-responsive emoji emoji-android emoji--white_check_mark"
      title=":white_check_mark:"
      alt="✅"
    /> 总结：</p>
<ul>
<li><code>tx_octets</code> 填 <strong>251</strong>（不是 512）。</li>
<li><code>tx_time</code> 按 PHY 速率算，1M 时约 2120 us。</li>
<li>想发 512 字节，要配合 <strong>ATT MTU 扩展</strong>，LL 层只管单包最大字节数（≤ 251）。</li>
</ul>
]]></description><link>http://www.freqchip.net:4567/post/3259</link><guid isPermaLink="true">http://www.freqchip.net:4567/post/3259</guid><dc:creator><![CDATA[Mars]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to FR303x 连接之后，如果你想一包数据不分包发送最大值要怎么修改？ on Invalid Date]]></title><description><![CDATA[<p><strong>125K（LE Coded S=8）下还是走 DLE 的同一套规则</strong>：</p>
<ul>
<li><code>tx_octets</code> 的上限依然是 <strong>251</strong>（LL 层单包最大负载）。</li>
<li><code>tx_time</code> 是“单包最大发送时长（us）”，需要按所用 PHY 的比特率估算。</li>
</ul>
<p>一个好用的近似公式（够工程使用）：</p>
<pre><code>tx_time(µs) ≈ (tx_octets + 14) * 8 / R   ，R 为 Mbps（1M=1，2M=2，500K=0.5，125K=0.125）
</code></pre>
<blockquote>
<p>“+14”是 LL 层头部等开销的常用近似。<br />
以 tx_octets=251 估算得到常用值（四舍五入）：</p>
</blockquote>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>PHY</th>
<th>估算 tx_time</th>
</tr>
</thead>
<tbody>
<tr>
<td>1M</td>
<td>≈ 2120 µs</td>
</tr>
<tr>
<td>2M</td>
<td>≈ 1060 µs</td>
</tr>
<tr>
<td><strong>125K（S=8）</strong></td>
<td><strong>≈ 16960 µs</strong></td>
</tr>
<tr>
<td>500K（S=2）</td>
<td>≈ 4240 µs</td>
</tr>
</tbody>
</table>
<h3>你的需求：<strong>想一次发送 512 字节</strong></h3>
<ul>
<li>LL 层单包最多 <strong>251B</strong>，所以 <strong>必须分成两包</strong>（DLE 只是把单包上限提到 251B）。</li>
<li>若想在 <strong>ATT 层“一次性”写 512B</strong>，还需要 <strong>把 MTU 提到 ≥517</strong>（ATT 可载荷=MTU-3=512B），底层依然会拆成两包 LL PDU 发送。</li>
</ul>
<h3>125K（S=8）下的调用示例</h3>
<pre><code class="language-c">gap_ll_pkt_size_exchange_req_t req = {
    .conidx    = 0,        // 你的连接索引
    .tx_octets = 251,      // LL 单包最大负载上限
    .tx_time   = 16960,    // 125K 估算值（微秒）
};

ble_api_err_t err = gap_ll_pkt_size_exchange_req(&amp;req);
if (err != BLE_API_OK) {
    // 处理错误
}
</code></pre>
<blockquote>
<p>实战提示</p>
<ul>
<li>有的控制器会自己协商到双方都能接受的最大值；<code>tx_time</code> <strong>宁可略大不要偏小</strong>，125K 下给 <strong>17000~18000 µs</strong> 也常见。</li>
<li>记得在建立连接后：<strong>先做 ATT MTU 交换（≥517）→ 再做 DLE（251/16960）</strong>，最后再发 512B 的应用数据。</li>
<li>若用 <strong>500K（S=2）</strong>，把 <code>tx_time</code> 改成 ≈ <strong>4240 µs</strong> 即可，<code>tx_octets</code> 仍为 251。</li>
</ul>
</blockquote>
]]></description><link>http://www.freqchip.net:4567/post/3260</link><guid isPermaLink="true">http://www.freqchip.net:4567/post/3260</guid><dc:creator><![CDATA[Mars]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>