1 2 3## 使用说明文档 4 5 本文档主要介绍了蓝牙专项测试程序的所在仓,如何使用DevEco程序导入该项目,如何预览、编译和烧录该程序以及该程序的功能使用说明。 6 7### 安装使用说明(win环境) 8 9#### 下载代码 10 111. 文件代码所在仓的地址 12 13[communication_bluetooth: 蓝牙服务组件为设备提供接入与使用Bluetooth的相关接口,包括BLE设备gatt相关的操作,以及BLE广播、扫描等功能。 (gitee.com)](https://gitee.com/openharmony/communication_bluetooth) 14 152. 下载方式 16 17 18 19- 使用git下载 20 21 - 安装git。 22 23 - 选择一个空文件夹,右键打开git Bash。(文件夹路径中不要出现中文) 24 25  26 27 - 使用命令 `git clone {http}` 28 29  30 31- 直接下载zip 32 33#### 工具 34 351. DevEco Studio 3.0 Beta4 36 37- HUAWEI DevEco Studio For OpenHarmony是基于IntelliJ IDEA Community开源版本打造,面向OpenHarmony全场景多设备的一站式集成开发环境(IDE),DevEco Studio 3.0支持在HarmonyOS 3.0 Beta版上开发应用及服务,并已适配ArkUI声明式编程范式、ArkCompiler方舟编译,同时提供低代码开发、双向预览、全新构建工具、模拟器、调试调优、信息中心等功能,为开发者提供工程模板创建、开发、编译、调试、发布等E2E的OpenHarmony应用/服务开发。 38 392. 下载链接: [HUAWEI DevEco Studio和SDK下载和升级 | HarmonyOS开发者](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta) 40 413. 安装步骤: [下载与安装软件-快速开始-HUAWEI DevEco Studio For OpenHarmony使用指南-工具-HarmonyOS应用开发 | HarmonyOS](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-download-software-0000001218760592) 42 43注:建议在选项界面都勾选DevEco Studio,Add “bin” folder to the PATH,Add "Open Folder as Project" 44 454. 配置开发环境:[配置开发环境-快速开始-HUAWEI DevEco Studio For OpenHarmony使用指南-工具-HarmonyOS应用开发 | HarmonyOS](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443) 46 47#### 如何导入程序 48 491. 打开DevEco 50 512. 在DevEco Studio的欢迎页,选择**Open Project**开始创建一个新工程。 52 53 54 552.选择程序所在的路径 56 57 58 593. 打开程序的homepage 60 61 \communication_bluetooth\test\example\BluetoothTest\entry\src\main\ets\MainAbility\pages\homePage.ets 62 63 64 65- **entry**为应用的主模块,类似与Android Studio的app模块,一个APP中,对于同一设备类型必须有且只有一个entry类型的HAP,可独立安装运行。 66 67- 使用**previewer**查看程序的预览图 68 69 点击View > Tool Windows > Project > Previewer 如下图所示: 70 71 - 方法一: 72 73  74 75 - 方法二: 76 77  78 79 - 成功预览后会生成.preview结构: 80 81  82 83- 使用**build**编译程序 84 85 - 点击Build > Rebuild 进行编译; Build > Build Hap(s) /App(s) >Build Hap(s) 生成hap文件 86 87  88 89 - hap文件的生成路径:entry\build\outputs\default 90 91  92 93- 打开homepage点击预览,会显示蓝牙专项测试程序的主界面,如下图所示 94 95 96 97注:在预览中,点击具体的功能模块,能实现页面跳转。具体的方法实现,需要在开发板上完成。 98 99- 将搭载OpenHarmony标准系统的开发板与电脑连接。 100 101- 点击File > Project Structure > Project > Signing Configs界面勾选“Automatically generate signature”,等待自动签名完成即可,点击“OK”。如下图所示: 102- 为了保证OpenHarmony应用的完整性和来源可靠,在应用构建时需要对应用进行签名。经过签名的应用才能在真机设备上安装、运行、和调试。如果没有配置签名,会报错:hvigor WARN: Will skip sign ‘hap’,Invalid signingConfig is configured for 'default' product. 103 104<img src="InstructionDoc/project structure.png" alt="project structure" style="zoom:75%;" /> 105 106程序烧录 107 108 109 110--- 111 112### 安装使用说明(Open-Harmony) 113 114在开源鸿蒙系统下 115 116- 蓝牙专项应用程序路径为:foundation/communication/bluetooth/test/example/BluetoothTest 117 118- 编译命令 119 120 ~~~ 121 # 全量编译 122 ./build.sh --product-name {product_name} 123 124 # 单独编译HAP 125 ./build.sh --product-name {product_name} --build-target BluetoothTest 126 127- 生成文件 128 129 - 使用 find out -name "BluetoothTest.hap*" 查找生成文件,或者直接查看config.json所写的生成路径。 130 - 将生成文件拷到本地电脑上,连接板子,使用命令 `hdc_std.exe install BluetoothTest`进行安装。 131 - 使用命令 `hdc_std uninstall {安装包名}` 进行卸载。 132 - 安装包名在 `entry\src\main\config.json` 如:`"bundleName": "com.ohos.bttest"` 133 134- 补充 135 136 在鸿蒙系统下编译,仍存在高版本对低版本的编译不兼容性问题。即在mater版本下编译的hap无法在beta2版本运行;反之则可以。 137 138**要使用Opp文件传输功能,需要添加暴漏接口到本地DevEco的ohos.bluetooth.d.ts,才可以使用opp的接口** 139 140- 修改ohos.bluetooth.d.ts中的 function ` getProfile` 141 142 ~~~ 143 /** 144 * Obtains the instance of profile. 145 * 146 * @param profileId The profile id.. 147 * @return Returns instance of profile. 148 * @since 8 149 */ 150 function getProfile(profileId: ProfileId): A2dpSourceProfile | A2dpSinkProfile | AvrcpProfile | HandsFreeAudioGatewayProfile | HandsFreeUnitProfile | HidHostProfile | PanProfile | PbapClientProfile |OppProfile | PbapServerProfile ; 151 152- 增加interface `OppProfile` 153 154 ~~~ 155 /** 156 * Manager OppProfile profile. 157 */ 158 interface OppProfile extends BaseProfile { 159 on(type: "transferStateChange", callback: Callback<BluetoothOppTransferInformation>): void; 160 off(type: "transferStateChange"): void; 161 on(type: "receiveIncomingFile", callback: Callback<BluetoothOppTransferInformation>): void; 162 off(type: "receiveIncomingFile"): void; 163 sendFile(device: string, filePaths: Array<string>, mimeTypes: Array<string>): boolean; 164 setIncomingFileConfirmation(accept: boolean): boolean; 165 getCurrentTransferInformation(): BluetoothOppTransferInformation; 166 cancelTransfer(): boolean; 167 } 168 ~~~ 169 170--- 171 172### 程序说明 173 174测试模块根据测试类型不同可以分为接口测试,自动化测试,场景测试,Profile测试,性能测试; 175 176根据测试的接口仓不同可以分为bluetooth仓的测试与bluetoothManager仓的测试。 177 178- 接口测试(ohos.bluetooth.d.ts) 179 180 >1. 经典蓝牙模块接口测试 181 > 182 > Br功能界面使用说明文档.md 183 > 184 >2. BLE蓝牙模块接口测试 185 > 186 > BLE功能界面使用说明文档.md 187 > 188 >3. Gatt模块接口测试 189 > 190 > Gatt功能界面使用说明文档.md 191 > 192 >4. SPP模块接口测试 193 > 194 > SPP功能界面使用说明文档.md 195 > 196 197 198 199 200 201- 接口测试(ohos.bluetoothManager.d.ts) 202 203 >1. 经典蓝牙Manager模块接口测试 204 > 205 > BrManager功能界面使用说明文档.md 206 > 207 >2. BLE蓝牙Manager模块接口测试 208 > 209 > BLEManager功能界面使用说明文档.md 210 > 211 >3. GattManager模块接口测试 212 > 213 > GattManager功能界面使用说明文档.md 214 > 215 >4. SPPManager模块接口测试 216 > 217 > SPPManager功能界面使用说明文档.md 218 219 220 221- 自动测试(ohos.bluetooth.d.ts) 222 223 >1. 经典蓝牙模块自动测试 224 > 225 >2. BLE蓝牙模块自动测试 226 > 227 >3. Gatt蓝牙模块自动测试 228 > 229 >4. SPP蓝牙模块自动测试 230 > 231 >5. Profile蓝牙模块自动测试 232 > 233 > 蓝牙自动测试使用说明文档.md 234 235 236 237 238 239- 自动测试(ohos.bluetoothManager.d.ts) 240 241 >1. 经典蓝牙Manager自动测试 242 > 243 >2. BLE蓝牙Manager自动测试 244 > 245 >3. Gatt蓝牙Manager自动测试 246 > 247 >4. SPP蓝牙Manager自动测试 248 > 249 >5. Profile蓝牙Manager自动测试 250 > 251 > 蓝牙Manager自动测试使用说明文档.md 252 253 254 255- 场景测试(ohos.bluetooth.d.ts) 256 257 >1. 经典蓝牙发现场景测试 258 >2. BLE蓝牙发现场景测试 259 >3. GattClient场景测试 260 >4. GattServer场景测试 261 >5. SppClient场景测试 262 >6. SppServer场景测试 263 >7. Opp发送端场景测试 264 >8. Opp接收端场景测试 265 >9. 蓝牙场景测试使用说明文档.md 266 267 268 269 270 271- 场景测试(ohos.bluetoothManager.d.ts) 272 273 >1. 经典蓝牙Manager发现场景测试 274 > 275 >2. BLE蓝牙Manager发现场景测试 276 > 277 >3. GattClientManager场景测试 278 > 279 >4. GattServerManager场景测试 280 > 281 >5. SppClientManager场景测试 282 > 283 >6. SppServerManager场景测试 284 > 285 > 蓝牙Manager场景测试使用说明文档.md 286 287 288 289- Profile测试(ohos.bluetooth.d.ts) 290 291 >1. A2dpSourceProfile测试 292 > 293 >2. HandsFreeAudioGatewayProfile测试 294 > 295 >3. HidHostProfile测试 296 > 297 >4. PanNetwork测试 298 > 299 > Profile功能界面使用说明文档.md 300 301 302 303 304 305- Profile测试(ohos.bluetoothManager.d.ts) 306 307 >1. A2dpSourceProfileManager测试 308 > 309 >2. HandsFreeAudioGatewayProfileManager测试 310 > 311 >3. HidHostProfileManager测试 312 > 313 >4. PanNetworkManager测试 314 > 315 > ProfileManager功能界面使用说明文档.md 316 317 318 319- 性能测试(ohos.bluetooth.d.ts) 320 321 >1. BrBenchmark测试 322 > 323 >2. BleBenchmark测试 324 > 325 >3. GattClientVelocityBenchmark / GattServerVelocityBenchmark测试 326 > 327 >4. SppClientVelocityBenchmark / SppServerVelocityBenchmark测试 328 > 329 >5. SppClientBandWidthBenchmark / SppServerBandWidthBenchmark测试 330 > 331 > 蓝牙性能测试功能界面使用说明文档.md 332 333 334 335 336 337- 性能测试(ohos.bluetoothManager.d.ts) 338 339 >1. BrManagerBenchmark测试 340 > 341 >2. BleManagerBenchmark测试 342 > 343 >3. GattClientManagerVelocityBenchmark / GattServerManagerVelocityBenchmark测试 344 > 345 >4. SppClientManagerVelocityBenchmark / SppServerManagerVelocityBenchmark测试 346 > 347 >5. SppClientManagerBandWidthBenchmark / SppServerManagerBandWidthBenchmark测试 348 > 349 > 蓝牙Manager性能测试功能界面使用说明文档.md 350 351 352 353 354 355