1e41f4b71Sopenharmony_ci# Connectivity Kit简介
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Connectivity Kit开发概述
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci移动终端设备已经深入人民日常生活的方方面面,如连接蓝牙耳机听音乐、连接WIFI上网、使用NFC进行一碰开门等已成为终端用户日常生活中常见的行为。
6e41f4b71Sopenharmony_ci当用户处于这些丰富的使用场景中时,蓝牙提供基于蓝牙连接的基础能力,如音乐/通话/分享等,WIFI提供基础的无线连接能力,NFC提供基础的靠近刷卡和读卡能力。
7e41f4b71Sopenharmony_ci对于开发者,设计基础通信的体验服务,可以使应用的使用体验更贴近每个终端用户的日常生活。
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci### 蓝牙简介
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci蓝牙技术是一种无线通信技术,可以在短距离内传输数据。可以用于连接手机、耳机、音箱、键盘、鼠标、打印机等各种设备。特点是低功耗、低成本、简单易用。目前已经发展到了第五代,支持更高的数据传输速率和更广的覆盖范围。
12e41f4b71Sopenharmony_ci下面简介几种常见的蓝牙涉及的模块:
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci- **ACCESS接入模块**<br/>
15e41f4b71Sopenharmony_ci  蓝牙接入模块,提供了开关蓝牙以及获取蓝牙开关状态等接口功能。使用蓝牙功能需要通过该模块打开蓝牙,在蓝牙开关状态正确的条件下使用其他功能。
16e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.access API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-access.md)。
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci- **CONNECTION连接模块**<br/>
19e41f4b71Sopenharmony_ci  蓝牙连接模块,提供了设备发现、配对连接、获取本端及外设信息的接口功能。使用和外设交互的功能,需要使用该模块提供的能力和外设配对、连接成功,才能继续进行后续的数据传输等功能。
20e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.connection API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-connection.md)。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci- **BLE模块(低功耗蓝牙)**<br/>
23e41f4b71Sopenharmony_ci  BLE是Bluetooth Low Energy的缩写,意为“低功耗蓝牙”。它是一种能够在低功耗情况下进行通信的蓝牙技术,与传统蓝牙相比,BLE的功耗更低,适用于需要长时间运行的低功耗设备,如智能手表、健康监测设备、智能家居等。
24e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.ble API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-ble.md)。
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci- **SOCKET模块(串口协议)**<br/>
27e41f4b71Sopenharmony_ci  SPP是Serial Port Profile(串口协议)的缩写,是一种蓝牙协议,用于在蓝牙设备之间建立串行通信连接。通过SPP,蓝牙设备可以像使用串口一样进行数据传输,例如传输文件、文本等。
28e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.socket API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-socket.md)。
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci- **A2DP模块(高级音频分发配置文件)**<br/>
31e41f4b71Sopenharmony_ci  A2DP是Advanced Audio Distribution Profile的缩写,即高级音频分发配置文件。它是一种蓝牙协议,允许无线传输高品质音频流,例如音乐或语音通话,同时支持双向通信,因此可以用于耳机、扬声器、汽车音响等设备。
32e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.a2dp API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-a2dp.md)。
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci- **HFP模块(免提模式)**<br/>
35e41f4b71Sopenharmony_ci  HFP模块是指蓝牙耳机或车载蓝牙设备中的Hands-Free Profile,即“免提模式”。HFP允许用户通过蓝牙连接手机或其他蓝牙设备,实现免提通话和语音控制等功能。
36e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.hfp API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-hfp.md)。
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci- **HID模块(人机接口设备)**<br/>
39e41f4b71Sopenharmony_ci  HID是Human Interface Device的缩写,即人机接口设备。在蓝牙中,HID模块是一种允许用户通过蓝牙连接键盘、鼠标、游戏手柄等人机接口设备的模块。用户可以通过HID模块将这些设备连接到蓝牙主机上,实现无线控制和输入。
40e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.hid API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-hid.md)。
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci- **PAN模块(个人区域网络)**<br/>
43e41f4b71Sopenharmony_ci  PAN(Personal Area Network)是个人区域网络的缩写,是一种无线通信技术,用于将设备连接到一个小范围的网络中。例如可以将手机、电脑、打印机等设备连接到一个PAN网络中,实现文件的共享和打印。
44e41f4b71Sopenharmony_ci  详情请参考[@ohos.bluetooth.pan API参考](../reference/apis-connectivity-kit/js-apis-bluetooth-pan.md)。
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci相关开发指南可参考:[蓝牙开发指南](./bluetooth/bluetooth-overview.md)。
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci### WLAN简介
49e41f4b71Sopenharmony_ci无线局域网(Wireless Local Area Networks,WLAN),是通过无线电、红外光信号或者其他技术发送和接收数据的局域网,用户可以通过WLAN实现结点之间无物理连接的网络通讯。常用于用户携带可移动终端的办公、公众环境中。
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciWLAN系统为用户提供接入WLAN网络功能(STA模式)、点对点的数据传输功能(P2P模式)和热点分享功能(AP模式),让应用可以通过WLAN和其他设备互联互通。
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci- **STA模式**<br/>
54e41f4b71Sopenharmony_ci  STA模式即工作站模式,可以理解为某网络中的一个工作站即客户端。当某设备具备该功能时,它可以连到另外的一个路由网络中,如家用路由器,通常用于提供网络的数据上行服务。
55e41f4b71Sopenharmony_ci  详情请参考[@ohos.wifiManager API参考](../reference/apis-connectivity-kit/js-apis-wifiManager.md)。
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci- **P2P模式**<br/>
58e41f4b71Sopenharmony_ci  P2P模式也为Wi-Fi Direct;Wi-Fi Direct 是一种点对点连接技术,它可以在两台 STA 之间直接建立 TCP/IP 链接,并不需要AP的参与;其中一台STA会起到传统意义上的AP的作用,称为Group Owner(GO),另外一台station则称为Group Client(GC),像连接AP一样连接到GO。
59e41f4b71Sopenharmony_ci  详情请参考[@ohos.wifiManager API参考](../reference/apis-connectivity-kit/js-apis-wifiManager.md)。
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci- **AP模式**<br/>
62e41f4b71Sopenharmony_ci  AP模式为加入无线局域网的成员设备(即客户端)提供下行数据业务,它提供以无线方式组建无线局域网WLAN,相当际WLAN的中心设备。
63e41f4b71Sopenharmony_ci  详情请参考[@ohos.wifiManager API参考](../reference/apis-connectivity-kit/js-apis-wifiManager.md)。
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci### NFC简介
66e41f4b71Sopenharmony_ciNFC英文全称Near Field Communication,近距离无线通信。NFC服务提供NFC开关控制、NFC标签读写、NFC卡模拟等业务功能。
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci- **NFC开关**<br/>
69e41f4b71Sopenharmony_ci  NFC开关模块,提供了打开NFC和关闭NFC功能。打开或关闭NFC的应用程序,需要声明权限"ohos.permission.MANAGE_SECURE_SETTINGS",该权限只有系统应用才能声明。因此,只有系统应用才能打开或关闭NFC。
70e41f4b71Sopenharmony_ci  详情请参考[@ohos.nfc.controller API参考](../reference/apis-connectivity-kit/js-apis-nfcController.md)。
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci- **NFC标签读写**<br/>
73e41f4b71Sopenharmony_ci  NFC标签读写模块,提供了NFC标签的发现和分发给应用程序,以及应用程序通过NFC标签读写接口访问NFC标签的能力。应用程序需要按照规定的格式来声明NFC标签读写能力,只有声明后应用程序才能收到NFC标签的分发。
74e41f4b71Sopenharmony_ci  详情请参考[@ohos.nfc.tag API参考](../reference/apis-connectivity-kit/js-apis-nfcTag.md)。
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci- **NFC卡模拟**<br/>
77e41f4b71Sopenharmony_ci  NFC卡模拟模块,提供了NFC的刷卡业务,电子设备和读卡器触碰完成刷卡。应用程序需要按照规定的格式来声明NFC卡模拟能力,只有声明后应用程序才能够具备刷卡能力。
78e41f4b71Sopenharmony_ci  详情请参考[@ohos.nfc.cardEmulation API参考](../reference/apis-connectivity-kit/js-apis-cardEmulation.md)。
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci### 运作机制
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciConnectivity能力作为系统为应用提供的一种基础通信服务,需要在应用使用场景中打开相应开关/连接等处理,在业务结束时主动结束连接等。
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci### 约束与限制
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci使用设备的相关能力,需要用户主动授权打开开关。否则系统不会向三方应用提供服务。
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci### 相关实例
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci针对蓝牙相关的业务,有以下相关实例可供参考:
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci- [`bluetooth`](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Bluetooth)