1# @ohos.bluetooth.pan (Bluetooth pan Module) 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 9 10 11## Modules to Import 12 13```js 14import pan from '@ohos.bluetooth.pan'; 15import { BusinessError } from '@ohos.base'; 16``` 17 18 19## pan.createPanProfile<a name="createPanProfile"></a> 20 21createPanProfile(): PanProfile 22 23Creates a **PanProfile** instance. 24 25**System capability**: SystemCapability.Communication.Bluetooth.Core 26 27**Return value** 28 29| Type | Description | 30| ----------------------------- | ---------- | 31| PanProfile | **PanProfile** instance created.| 32 33**Example** 34 35```js 36try { 37 let panProfile : pan.PanProfile= pan.createPanProfile(); 38 console.info('pan success'); 39} catch (err) { 40 console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); 41} 42``` 43 44 45## PanProfile 46 47Before using any API of **PanProfile**, you need to create an instance of this class by using **createPanProfile()**. 48 49 50### disconnect<a name="PanP-disconnect"></a> 51 52disconnect(deviceId: string): void 53 54Disconnects from the PAN service of a device. 55 56**System API**: This is a system API. 57 58**Required permissions**: ohos.permission.ACCESS_BLUETOOTH 59 60**System capability**: SystemCapability.Communication.Bluetooth.Core 61 62**Parameters** 63 64| Name | Type | Mandatory | Description | 65| ------ | ------ | ---- | ------- | 66| deviceId | string | Yes | Address of the remote device.| 67 68**Error codes** 69 70For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md). 71 72| ID| Error Message| 73| -------- | ---------------------------- | 74|2900001 | Service stopped. | 75|2900003 | Bluetooth switch is off. | 76|2900004 | Profile is not supported. | 77|2900099 | Operation failed. | 78 79**Example** 80 81```js 82try { 83 let panProfile: pan.PanProfile = pan.createPanProfile(); 84 panProfile.disconnect('XX:XX:XX:XX:XX:XX'); 85} catch (err) { 86 console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); 87} 88``` 89 90 91### setTethering<a name="setTethering"></a> 92 93setTethering(enable: boolean): void 94 95Sets Bluetooth tethering, which shares a mobile connection. 96 97**System API**: This is a system API. 98 99**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 100 101**System capability**: SystemCapability.Communication.Bluetooth.Core 102 103**Parameters** 104 105| Name | Type | Mandatory | Description | 106| ------ | ------ | ---- | ------- | 107| value | boolean | Yes | Whether to set tethering over a Bluetooth PAN.| 108 109**Error codes** 110 111For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md). 112 113| ID| Error Message| 114| -------- | ---------------------------- | 115|2900001 | Service stopped. | 116|2900003 | Bluetooth switch is off. | 117|2900004 | Profile is not supported. | 118|2900099 | Operation failed. | 119 120**Example** 121 122```js 123try { 124 let panProfile: pan.PanProfile = pan.createPanProfile(); 125 panProfile.setTethering(false); 126} catch (err) { 127 console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); 128} 129``` 130 131 132### isTetheringOn<a name="isTetheringOn"></a> 133 134isTetheringOn(): boolean 135 136Checks whether Bluetooth tethering is activated. 137 138**System API**: This is a system API. 139 140**Required permissions**: ohos.permission.ACCESS_BLUETOOTH 141 142**System capability**: SystemCapability.Communication.Bluetooth.Core 143 144**Return value** 145 146| Type | Description | 147| --------------------- | --------------------------------- | 148| boolean | Returns **true** if tethering is available over a Bluetooth PAN; returns **false** otherwise.| 149 150**Example** 151 152```js 153try { 154 let panProfile: pan.PanProfile = pan.createPanProfile(); 155 panProfile.isTetheringOn(); 156} catch (err) { 157 console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); 158} 159``` 160