1# Bluetooth 2 3 4## Overview 5 6Provides APIs for obtaining the Bluetooth switch state. 7 8**Since**: 13 9 10 11## Summary 12 13 14### Files 15 16| Name| Description| 17| -------- | -------- | 18| [oh_bluetooth.h](oh__bluetooth_8h.md) | Defines the API for obtaining the Bluetooth switch state.<br>**File to include**: \<ConnectivityKit\/bluetooth\/oh_bluetooth.h\>| 19 20 21### Types 22 23| Name| Description| 24| -------- | -------- | 25| typedef enum [Bluetooth_SwitchState](#bluetooth_switchstate) [Bluetooth_SwitchState](#bluetooth_switchstate) | Defines an enum for Bluetooth switch states.| 26| typedef enum [Bluetooth_ResultCode](#bluetooth_resultcode) [Bluetooth_ResultCode](#bluetooth_resultcode) | Defines an enum for the error codes returned by Bluetooth APIs.| 27 28 29### Enums 30 31| Name| Description| 32| -------- | -------- | 33| [Bluetooth_SwitchState](#bluetooth_switchstate) {<br>BLUETOOTH_STATE_OFF = 0,<br>BLUETOOTH_STATE_TURNING_ON = 1,<br>BLUETOOTH_STATE_ON = 2,<br>BLUETOOTH_STATE_TURNING_OFF = 3,<br>BLUETOOTH_STATE_BLE_TURNING_ON = 4,<br>BLUETOOTH_STATE_BLE_ON = 5,<br>BLUETOOTH_STATE_BLE_TURNING_OFF = 6<br>} | Enumerates the Bluetooth switch states.| 34| [Bluetooth_ResultCode](#bluetooth_resultcode) {<br>BLUETOOTH_SUCCESS = 0,<br>BLUETOOTH_INVALID_PARAM = 401<br>} | Enumerates the error codes returned by Bluetooth APIs.| 35 36 37### Functions 38 39| Name| Description| 40| -------- | -------- | 41| [Bluetooth_ResultCode](#bluetooth_resultcode) [OH_Bluetooth_GetBluetoothSwitchState](#oh_bluetooth_getbluetoothswitchstate) ([Bluetooth_SwitchState](#bluetooth_switchstate) \*state) | Obtains the Bluetooth state.| 42 43 44## Type Description 45 46 47### Bluetooth_ResultCode 48 49``` 50typedef enum Bluetooth_ResultCode Bluetooth_ResultCode 51``` 52 53**Description** 54 55Defines an enum for the error codes returned by Bluetooth APIs. 56 57**Since**: 13 58 59 60### Bluetooth_SwitchState 61 62``` 63typedef enum Bluetooth_SwitchState Bluetooth_SwitchState 64``` 65 66**Description** 67 68Defines an enum for Bluetooth switch states. 69 70**Since**: 13 71 72 73## Enum Description 74 75 76### Bluetooth_ResultCode 77 78``` 79enum Bluetooth_ResultCode 80``` 81 82**Description** 83 84Enumerates the error codes returned by Bluetooth APIs. 85 86**Since**: 13 87 88| Value| Description| 89| -------- | -------- | 90| BLUETOOTH_SUCCESS | The operation is successful.| 91| BLUETOOTH_INVALID_PARAM | Invalid parameter. Possible causes: 1. The input parameter is a null pointer. 2. The parameter value exceeds the value range.| 92 93 94### Bluetooth_SwitchState 95 96``` 97enum Bluetooth_SwitchState 98``` 99 100**Description** 101 102Enumerates Bluetooth switch states. 103 104**Since**: 13 105 106| Value| Description| 107| -------- | -------- | 108| BLUETOOTH_STATE_OFF | Bluetooth is turned off.| 109| BLUETOOTH_STATE_TURNING_ON | Bluetooth is being turned on.| 110| BLUETOOTH_STATE_ON | Bluetooth is turned on and ready for use.| 111| BLUETOOTH_STATE_TURNING_OFF | Bluetooth is being turned off.| 112| BLUETOOTH_STATE_BLE_TURNING_ON | The BLE only mode is being turned on.| 113| BLUETOOTH_STATE_BLE_ON | The BLE only mode is turned on.| 114| BLUETOOTH_STATE_BLE_TURNING_OFF | The BLE only mode is being turned off.| 115 116 117## Function Description 118 119 120### OH_Bluetooth_GetBluetoothSwitchState() 121 122``` 123Bluetooth_ResultCode OH_Bluetooth_GetBluetoothSwitchState (Bluetooth_SwitchState * state) 124``` 125 126**Description** 127 128Obtains the Bluetooth state. 129 130**Since**: 13 131 132**Parameters** 133 134| Name| Description| 135| -------- | -------- | 136| state | Pointer to the Bluetooth state obtained. A non-null pointer must be passed in. Otherwise, an error is returned. For details, see [Bluetooth_SwitchState](#bluetooth_switchstate).| 137 138**Returns** 139 140Returns a result code. For details, see [Bluetooth_ResultCode](#bluetooth_resultcode).<br>**BLUETOOTH_SUCCESS** indicates that the operation is successful. <br>**BLUETOOTH_INVALID_PARAM** indicates that the input parameter is a null pointer. 141 142