1# 1 介绍 2 3NimBLE 软件包是 RT-Thread 基于 [Apache NimBLE](https://github.com/apache/mynewt-nimble) 开源蓝牙 5.0 协议栈的移植实现,该协议栈提供完整的 Host 层和 Controller 层支持,目前支持 Nordic nRF51 和 nRF52 系列芯片。 4 5## 1.1 主要特性 6 7- 扩展广播(LE Advertising Extensions) 8- 2Mbit/s比特率的物理层 9- 长距离编码(Coded PHY for LE Long Range) 10- 高速不可连接广播(High Duty Cycle Non-Connectable Advertising) 11- 新的跳频算法(Channel Selection Algorithm #2) 12- 隐私1.2(LE Privacy 1.2) 13- 安全管理(SM),支持传统配对(LE Legacy Pairing),安全连接(LE Secure Connections),特定秘钥分发(Transport Specific Key Distribution) 14- 链路层PDU数据长度扩展(LE Data Length Extension) 15- 多角色并发(主机(central)/从机(peripheral), server/client) 16- 同时广播和扫描 17- 低速定向广播(Low Duty Cycle Directed Advertising) 18- 连接参数请求(Connection parameters request procedure) 19- LE Ping 20- 完整的GATT客户端,服务端,以及子功能 21- 抽象HCI接口层 22 23## 1.2 Profile和Service支持 24 25- 警报通知服务(ANS) 26- 即时报警服务(IAS) 27- 链路丢失服务(LLS) 28- 电池服务(BAS) 29- 设备信息服务(DIS) 30- 心率服务(HRS) 31- 自行车速度及步调(CSC) 32- 射频功率(TPS) 33 34## 1.3 Mesh 特性 35 36- 广播和GATT承载(Advertising and GATT bearers) 37- PB-GATT 和 PB-ADV provisioning 38- 模型层(Foundation Models (server role)) 39- 支持中继(Relay support) 40- 支持GATT代理(GATT Proxy) 41 42更多关于 NimBLE Stack 的介绍请参考 ``http://mynewt.apache.org/latest/network/docs/index.html``。 43 44## 1.4 目录结构 45 46``` 47NimBLE 48 ├───apps /* Bluetooth 示例应用程序 */ 49 │ ├───blecent 50 │ ├───blecsc 51 │ ├───blehci 52 │ ├───blehr 53 │ ├───blemesh 54 │ ├───blemesh_light 55 │ ├───blemesh_shell 56 │ ├───bleprph 57 │ ├───bleuart 58 │ ├───btshell 59 │ ├───ext_advertiser 60 │ └───ibeacon 61 ├───docs /* 官方文档及 API 说明 */ 62 ├───ext 63 │ └───tinycrypt /* Tinycrypt 加密库 */ 64 ├───nimble 65 │ ├───controller /* Controller 实现 */ 66 │ │ ├───include 67 │ │ └───src 68 │ ├───drivers /* Nordic 系列 Phy 驱动 */ 69 │ │ ├───nrf51 70 │ │ └───nrf52 71 │ ├───host /* Host Stack(主机控制器)实现 */ 72 │ │ ├───include 73 │ │ ├───mesh /* Mesh 组网功能 */ 74 │ │ ├───pts /* PTS 测试相关 */ 75 │ │ ├───services /* 通用的 Profile */ 76 │ │ │ ├───ans 77 │ │ │ ├───bas 78 │ │ │ ├───bleuart 79 │ │ │ ├───dis 80 │ │ │ ├───gap 81 │ │ │ ├───gatt 82 │ │ │ ├───ias 83 │ │ │ ├───lls 84 │ │ │ └───tps 85 │ │ ├───src 86 │ │ ├───store 87 │ │ ├───tools 88 │ │ └───util 89 │ ├───include 90 │ │ └───nimble 91 │ ├───src 92 │ └───transport /* HCI 传输抽象层 */ 93 │ ├───emspi 94 │ ├───ram 95 │ ├───socket 96 │ └───uart 97 └───porting /* OS 抽象层及系统配置 */ 98 ├───nimble 99 │ ├───include 100 │ └───src 101 └───npl 102 └───rtthread /* RT-Thread OS 接口实现 */ 103 ├───include 104 │ ├───config /* NimBLE 协议栈配置选项 */ 105 │ ├───console 106 │ └───nimble 107 └───src 108``` 109 110## 1.5 许可证 111 112NimBLE 软件包遵循 Apache-2.0 许可,详见 LICENSE 文件。 113 114## 1.6 依赖 115 116- RT_Thread 3.0+ 117 118## 2 获取软件包 119 120使用 NimBLE 软件包需要在 RT-Thread 的包管理中选中它,具体路径如下: 121 122``` 123RT-Thread online packages 124 IoT - internet of things ---> 125--- NimBLE:An open-source Bluetooth 5.0 stack porting on RT-Thread 126 Bluetooth Role support ---> 127 Host Stack Configuration ---> 128 Controller Configuration ---> 129 Bluetooth Mesh support ---> 130 HCI Transport support ---- 131 Device Driver support ---- 132 Log level (INFO) ---> 133 Bluetooth Samples (Not enable sample) ---> 134(1) Maximum number of concurrent connections 135[*] Device Whitelist Support 136(0) The number of multi-advertising instances 137[ ] Extended Advertising Feature Support 138 Version (latest) ---> 139 140``` 141 142**Bluetooth Role support** : 配置 BLE角色支持(Central/Peripheral/Broadcaster/Observer) ; 143**Host Stack Configuration** : 配置 Host 相关功能; 144**Controller Configuration** : 配置 Controller 相关功能; 145**Bluetooth Mesh support** : Mesh 特性支持及配置; 146**HCI Transport support** : 配置HCI层传输方式 147**Device Driver support ** : 底层 SOC Phy 支持 148**Log level (INFO)** : 配置协议栈日志等级; 149**Bluetooth Samples** : 配置示例应用; 150**Version** : 软件包版本选择; 151 152配置完成后让 RT-Thread 的包管理器自动更新,或者使用 pkgs --update 命令更新包到 BSP 中。 153 154## 3 使用 NimBLE 软件包 155 156配合独立的 nrf52832-nimble bsp 使用,参考 https://github.com/EvalZero/nrf52832-nimble 。 157 158## 4 注意事项 159- NimBLE 当前处于开发阶段,暂时只支持 Nodic nRF52832 MCU,参见 [nrf52832-bsp](https://github.com/EvalZero/nrf52832-nimble) 160 161## 5、联系方式 & 感谢 162 163- 维护:RT-Thread 开发团队 164- 主页:https://github.com/RT-Thread-packages/nimble 165