1# @ohos.bluetooth.pan (Bluetooth PAN Module) (System API)
2
3The **pan** module provides APIs for accessing the Bluetooth personal area network (PAN).
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.bluetooth.pan (Bluetooth PAN Module)](js-apis-bluetooth-pan.md).
9
10
11## Modules to Import
12
13```js
14import { pan } from '@kit.ConnectivityKit';
15```
16
17## PanProfile
18
19Before using any API of **PanProfile**, you need to create an instance of this class by using **createPanProfile()**.
20
21### disconnect
22
23disconnect(deviceId: string): void
24
25Disconnects from the PAN service of a device.
26
27**System API**: This is a system API.
28
29**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
30
31**System capability**: SystemCapability.Communication.Bluetooth.Core
32
33**Parameters**
34
35| Name   | Type    | Mandatory  | Description     |
36| ------ | ------ | ---- | ------- |
37| deviceId | string | Yes   | Address of the remote device.|
38
39**Error codes**
40
41For details about the error codes, see [Bluetooth Error Codes](errorcode-bluetoothManager.md).
42
43| ID| Error Message|
44| -------- | ---------------------------- |
45|201 | Permission denied.                 |
46|202 | Non-system applications are not allowed to use system APIs. |
47|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
48|801 | Capability not supported.          |
49|2900001 | Service stopped.                         |
50|2900003 | Bluetooth disabled.                 |
51|2900004 | Profile not supported.                |
52|2900099 | Operation failed.                        |
53
54**Example**
55
56```js
57import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
58try {
59    let panProfile: pan.PanProfile = pan.createPanProfile();
60    panProfile.disconnect('XX:XX:XX:XX:XX:XX');
61} catch (err) {
62    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
63}
64```
65
66
67### setTethering
68
69setTethering(enable: boolean): void
70
71Sets Bluetooth tethering, which shares a mobile connection.
72
73**System API**: This is a system API.
74
75**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
76
77**System capability**: SystemCapability.Communication.Bluetooth.Core
78
79**Parameters**
80
81| Name   | Type    | Mandatory  | Description     |
82| ------ | ------ | ---- | ------- |
83| value | boolean | Yes   | Whether to set tethering over a Bluetooth PAN. The value **true** means to set tethering over a Bluetooth PAN; the value **false** means the opposite.|
84
85**Error codes**
86
87For details about the error codes, see [Bluetooth Error Codes](errorcode-bluetoothManager.md).
88
89| ID| Error Message|
90| -------- | ---------------------------- |
91|201 | Permission denied.                 |
92|202 | Non-system applications are not allowed to use system APIs. |
93|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
94|801 | Capability not supported.          |
95|2900001 | Service stopped.                         |
96|2900003 | Bluetooth disabled.                 |
97|2900004 | Profile not supported.                |
98|2900099 | Operation failed.                        |
99
100**Example**
101
102```js
103import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
104try {
105    let panProfile: pan.PanProfile = pan.createPanProfile();
106    panProfile.setTethering(false);
107} catch (err) {
108    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
109}
110```
111
112
113### isTetheringOn
114
115isTetheringOn(): boolean
116
117Checks whether Bluetooth tethering is activated.
118
119**System API**: This is a system API.
120
121**Required permissions**: ohos.permission.ACCESS_BLUETOOTH
122
123**System capability**: SystemCapability.Communication.Bluetooth.Core
124
125**Return value**
126
127| Type     | Description                 |
128| --------------------- | --------------------------------- |
129| boolean | Returns **true** if tethering is available over a Bluetooth PAN; returns **false** otherwise.|
130
131**Error codes**
132
133For details about the error codes, see [Bluetooth Error Codes](errorcode-bluetoothManager.md).
134
135| ID| Error Message|
136| -------- | ---------------------------- |
137|201 | Permission denied.                 |
138|202 | Non-system applications are not allowed to use system APIs. |
139|801 | Capability not supported.          |
140
141
142**Example**
143
144```js
145import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
146try {
147    let panProfile: pan.PanProfile = pan.createPanProfile();
148    panProfile.isTetheringOn();
149} catch (err) {
150    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
151}
152```
153