• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3734

entry/12-May-2024-1,2781,108

screenshots/devices/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-20241.7 KiB4121

README_zh.mdD12-May-20242.1 KiB4121

build-profile.json5D12-May-20241 KiB4241

hvigorfile.jsD12-May-2024168 21

package.jsonD12-May-2024396 1919

README.md

1# Bluetooth
2
3### Introduction
4
5Bluetooth is a short-range wireless technology used to implement communication between fixed and mobile devices over low-cost short-distance wireless connections. This sample describes how to discover, pair, and unpair Bluetooth devices. The display effect is as follows:
6
7![](screenshots/devices/list_en.png)
8
9### Concepts
10
11Bluetooth: The Bluetooth module provides basic classic Bluetooth capabilities.
12
13### Required Permissions
14
15ohos.permission.USE_BLUETOOTH
16
17ohos.permission.LOCATION
18
19ohos.permission.DISCOVER_BLUETOOTH
20
21ohos.permission.MANAGE_BLUETOOTH
22
23ohos.permission.APPROXIMATELY_LOCATION
24
25### Usage
26
271. Start the app. If Bluetooth is enabled, the system searches for nearby devices that can be paired. If Bluetooth is not enabled, enable it.
28
292. After nearby devices are detected, select the device to pair. A dialog box is displayed. Touch **Pair** to set up a connection with this device; touch **Cancel** otherwise.
30
313. To delete a paired device, touch the device in the paired device list. A dialog box is displayed, asking you whether to disconnect from this device. Touch **OK** to disconnect from this device; touch **Cancel** otherwise.
32
33### Constraints
34
35- This sample can only be run on standard-system devices.
36
37- This sample is based on the stage model, which is supported from API version 9.
38
39- This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
40
41- The ohos.permission.MANAGE_BLUETOOTH permission used in this sample is of the system_basic level. You need to configure a signature for it. For details about the application permission level (APL), see [Permission List](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/permission-list.md).

README_zh.md

1# 蓝牙
2
3### 概要简介
4
5蓝牙技术是一种无线数据和语音通信开放的全球规范,它是基于低成本的近距离无线连接,为固定和移动设备建立通信环境的一种特殊的近距离无线技术连接。本示例实现蓝牙设备发现,配对,取消配对功能。实现效果如下:
6
7![](screenshots/devices/list.png)
8
9### 相关概念
10
11蓝牙:蓝牙模块提供了基础的传统蓝牙能力。
12
13### 相关权限
14
15蓝牙使用权限:ohos.permission.USE_BLUETOOTH
16
17位置发现权限:ohos.permission.LOCATION
18
19设备发现权限:ohos.permission.DISCOVER_BLUETOOTH
20
21蓝牙管理权限:ohos.permission.MANAGE_BLUETOOTH
22
23允许应用获取设备模糊位置信息权限:ohos.permission.APPROXIMATELY_LOCATION
24
25### 使用说明
26
271.启动应用,若蓝牙本来就打开的,系统会直接搜索周围可配对的设备,若蓝牙未打开,打开开关。
28
292.搜索到附近的设备后,选择需要配对的设备,点击该设备,会跳出匹配弹窗,若确定匹配,点击**匹配**按钮,否则点击**取消**按钮。
30
313.匹配后,若想删除匹配的设备,点击已配对的设备列表中的设备,会跳出断开连接弹窗,若确定删除该设备,点击**确定**,否则点击**取消**。
32
33### 约束与限制
34
351.本示例仅支持标准系统上运行。
36
372.本示例仅支持API9版本SDK,本示例涉及使用系统接口:cancelPairedDevice(),需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)38
393.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
40
414.本示例所配置的权限ohos.permission.MANAGE_BLUETOOTH为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2Beta/zh-cn/application-dev/security/hapsigntool-overview.md/))