当前位置:网站首页>ble HCI 流控机制
ble HCI 流控机制
2022-07-04 15:24:00 【千年缘】
HCI 有两种流控机制
- packet-based - 基于数据包的个数来控制收发
- data-block-based - 基于数据长度来控制收发
BR/EDR 默认使用 packet-based,可用 HCI_Write_Flow_Control_Mode command 设置,而 BLE 只支持 packet-based
一、Host to Controller data flow control
初始时,Host 通过 HCI_LE_Read_Buffer_Size 命令获取 Controller 中每个 ACL buffer 的大小,以及 ACL buffer 的个数,该个数即允许 Host 向 Controller 连续发送 ACL 包的个数当 Host 向 Controller 发送一个 ACL 包后,允许发包个数减 1,当允许发包个数为 0 时,则不能再向 Controller 发送
当 Controller 处理完一个 ACL 包后,如已将数据发给对端设备,Controller 释放 ACL buffer 空间,并向 Host 发送 HCI_Number_Of_Completed_Packets event,此时允许发包个数加 1,Host 又可以继续向 Controller 发送了
如果 Controller 同时处理完多个 ACL 包,Controller 释放多个 ACL buffer 空间,HCI_Number_Of_Completed_Packets event 中会有多个连接释放的 ACL buffer 个数,此时允许发包个数增值为所有连接释放的 ACL buffer 个数总和
二、Controller to Host data flow control
Controller 向 Host 方向的流控默认是关闭的,可以通过 HCI_Set_Controller_To_Host_Flow_Control cmd 打开或关闭
机制与 Host to Controller 相似,初始时,Host 通过 HCI_Host_Buffer_Size cmd 告知 Controller 自己每个 ACL buffer 的大小,以及 ACL buffer 的个数,该个数即允许 Controller 向 Host 连续发送 ACL 包的个数
当 Controller 向 Host 发送一个 ACL 包后,允许发包个数减 1,当允许发包个数为 0 时,则不能再向 Host 发送
当 Host 处理完一个 ACL 包后,如已将数据发给上层协议处理,Host 释放 ACL buffer 空间,并向 Controller 发送 HCI_Host_Number_Of_Completed_Packets command,此时允许发包个数加 1,Controller 又可以继续向 Host 发送了
如果 Host 同时处理完多个 ACL 包,Host 释放多个 ACL buffer 空间,HCI_Host_Number_Of_Completed_Packets command 中会有多个连接释放的 ACL buffer 个数,此时允许发包个数增值为所有连接释放的 ACL buffer 个数总和
HCI_Host_Number_Of_Completed_Packets cmd 是一个特殊的 cmd,它不受流控控制,Host 可以在任何时刻向 Controller 发送,且也没有相应的 event 生成
三、command flow control
当 Host 向 Controller 发送 command 后,Controller 会向 Host 返回 HCI_Command_Complete event 或 HCI_Command_Status event,这两个 event 中都有参数 num_of_allowed_command_packet, 这个参数即是 Host 可以向 Controller 连续发送 command 的个数
在初始时或者后续任何时刻,Controller 都可以向 Host 发送 Command Opcode=0x0000 的 HCI_Command_Status event 或 HCI_Command_Status event,用以告知 Host 此时允许连续发送 command 的个数
边栏推荐
- 电子元器件B2B商城系统开发:赋能企业构建进销存标准化流程实例
- 《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下
- China's roof ladder market trend report, technological innovation and market forecast
- 跳跃表实例
- Hair and fuzz interceptor Industry Research Report - market status analysis and development prospect forecast
- APOC自定义函数和过程
- 力扣今日题-1200. 最小绝对差
- 矿产行业商业供应链协同系统解决方案:构建数智化供应链平台,保障矿产资源安全供应
- Market trend report, technical innovation and market forecast of China's hair repair therapeutic apparatus
- Unity interview questions (continuously updated)
猜你喜欢
The winning rate against people is 84%, and deepmind AI has reached the level of human experts in army chess for the first time
Object.keys()的用法
GO开发:如何利用Go单例模式保障流媒体高并发的安全性?
被PMP考试“折磨”出来的考试心得,值得你一览
"Cannot initialize Photoshop because the temporary storage disk is full" graphic solution
容器环境minor gc异常频繁分析
Embedded software architecture design - function call
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
Readis configuration and optimization of NoSQL (final chapter)
Position encoding practice in transformer
随机推荐
嵌入式软件架构设计-函数调用
Detailed process of DC-2 range construction and penetration practice (DC range Series)
智慧物流園區供應鏈管理系統解决方案:數智化供應鏈賦能物流運輸行業供應鏈新模式
How to implement a delay queue?
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
SQL implements split
Principle and general steps of SQL injection
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
[glide] cache implementation - memory and disk cache
ONgDB图数据库与Spark的集成
表单传递时,如何隐式将值传过去
Inside and outside: flow chart drawing elementary: six common mistakes
How can programmers improve the speed of code writing?
Firebird experience summary
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Pytorch deep learning quick start tutorial
Go language loop statement (under Lesson 10)
线程池的使用和原理
How to decrypt worksheet protection password in Excel file
被PMP考试“折磨”出来的考试心得,值得你一览