> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Bluetooth module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
## Modules to Import
## Modules to Import
...
@@ -12,18 +12,6 @@ The Bluetooth module provides classic Bluetooth capabilities and Bluetooth Low E
...
@@ -12,18 +12,6 @@ The Bluetooth module provides classic Bluetooth capabilities and Bluetooth Low E
| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event.|
| callback | Callback<[BondStateParam](#bondstate)> | Yes | Callback invoked to return the pairing state. You need to implement this callback. |
| callback | Callback<[BondStateParam](#bondstateparam8)> | Yes | Callback invoked to return the bond state. You need to implement this callback. |
**Return value**
**Return value**
...
@@ -629,7 +617,7 @@ No value is returned.
...
@@ -629,7 +617,7 @@ No value is returned.
**Example**
**Example**
```js
```js
functiononReceiveEvent(data){// data, as the input parameter of the callback, indicates the pairing state.
functiononReceiveEvent(data){// data, as the input parameter of the callback, indicates the bond state.
console.info('pair state = '+JSON.stringify(data));
console.info('pair state = '+JSON.stringify(data));
| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event. |
| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event. |
| callback | Callback<[BondStateParam](#bondstate)> | No | Callback used to report the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
| callback | Callback<[BondStateParam](#bondstateparam8)> | No | Callback used to report the change of the Bluetooth bond state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
**Return value**
**Return value**
...
@@ -1295,7 +1283,7 @@ Obtains the connection state of the profile.
...
@@ -1295,7 +1283,7 @@ Obtains the connection state of the profile.
| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event.|
| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event.|
| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | Yes | Callback invoked to return a characteristic read request from the GATT client. |
| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | Yes | Callback invoked to return a characteristic read request event from the GATT client. |
**Return value**
**Return value**
...
@@ -1971,7 +1959,7 @@ Subscribes to the characteristic write request events.
...
@@ -1971,7 +1959,7 @@ Subscribes to the characteristic write request events.
| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event.|
| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event.|
| callback | Callback<[CharacteristicWriteReq](#descriptorwritereq)> | Yes | Callback invoked to return a characteristic write request from the GATT client. |
| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | Yes | Callback invoked to return a characteristic write request from the GATT client. |
**Return value**
**Return value**
...
@@ -2192,6 +2180,7 @@ let gattServer = bluetooth.BLE.createGattServer();
...
@@ -2192,6 +2180,7 @@ let gattServer = bluetooth.BLE.createGattServer();
Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This method can be used only after a connection is set up by calling [connect](#connect).
Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect).