1# Bluetooth
2
3
4## 概述
5
6提供用于查询蓝牙开关状态的功能。
7
8**起始版本:** 13
9
10
11## 汇总
12
13
14### 文件
15
16| 名称 | 描述 |
17| -------- | -------- |
18| [oh_bluetooth.h](oh__bluetooth_8h.md) | 定义查询蓝牙开关状态的接口。<br>**引用文件:** \<ConnectivityKit\/bluetooth\/oh_bluetooth.h\> |
19
20
21### 类型定义
22
23| 名称 | 描述 |
24| -------- | -------- |
25| typedef enum [Bluetooth_SwitchState](#bluetooth_switchstate) [Bluetooth_SwitchState](#bluetooth_switchstate) | 定义蓝牙开关状态的枚举值。 |
26| typedef enum [Bluetooth_ResultCode](#bluetooth_resultcode) [Bluetooth_ResultCode](#bluetooth_resultcode) | 定义蓝牙返回值的错误码。 |
27
28
29### 枚举
30
31| 名称 | 描述 |
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/>} | 定义蓝牙开关状态的枚举值。 |
34| [Bluetooth_ResultCode](#bluetooth_resultcode) {<br/>BLUETOOTH_SUCCESS = 0,<br/>BLUETOOTH_INVALID_PARAM = 401<br/>} | 定义蓝牙返回值的错误码。 |
35
36
37### 函数
38
39| 名称 | 描述 |
40| -------- | -------- |
41| [Bluetooth_ResultCode](#bluetooth_resultcode) [OH_Bluetooth_GetBluetoothSwitchState](#oh_bluetooth_getbluetoothswitchstate) ([Bluetooth_SwitchState](#bluetooth_switchstate) \*state) | 获取蓝牙开关状态。 |
42
43
44## 类型定义说明
45
46
47### Bluetooth_ResultCode
48
49```
50typedef enum Bluetooth_ResultCode Bluetooth_ResultCode
51```
52
53**描述**
54
55定义蓝牙返回值的错误码。
56
57**起始版本:** 13
58
59
60### Bluetooth_SwitchState
61
62```
63typedef enum Bluetooth_SwitchState Bluetooth_SwitchState
64```
65
66**描述**
67
68定义蓝牙开关状态的枚举值。
69
70**起始版本:** 13
71
72
73## 枚举类型说明
74
75
76### Bluetooth_ResultCode
77
78```
79enum Bluetooth_ResultCode
80```
81
82**描述**
83
84定义蓝牙返回值的错误码。
85
86**起始版本:** 13
87
88| 枚举值 | 描述 |
89| -------- | -------- |
90| BLUETOOTH_SUCCESS | 操作成功。 |
91| BLUETOOTH_INVALID_PARAM | 参数错误。可能原因:1. 输入参数为空指针;2. 参数数值超出定义范围。 |
92
93
94### Bluetooth_SwitchState
95
96```
97enum Bluetooth_SwitchState
98```
99
100**描述**
101
102定义蓝牙开关状态的枚举值。
103
104**起始版本:** 13
105
106| 枚举值 | 描述 |
107| -------- | -------- |
108| BLUETOOTH_STATE_OFF | 表示蓝牙关闭。 |
109| BLUETOOTH_STATE_TURNING_ON | 表示蓝牙打开中。 |
110| BLUETOOTH_STATE_ON | 表示蓝牙已打开,使用就绪。 |
111| BLUETOOTH_STATE_TURNING_OFF | 表示蓝牙关闭中。 |
112| BLUETOOTH_STATE_BLE_TURNING_ON | 表示蓝牙LE only模式打开中。 |
113| BLUETOOTH_STATE_BLE_ON | 表示蓝牙处于LE only模式。 |
114| BLUETOOTH_STATE_BLE_TURNING_OFF | 表示蓝牙LE only模式关闭中。 |
115
116
117## 函数说明
118
119
120### OH_Bluetooth_GetBluetoothSwitchState()
121
122```
123Bluetooth_ResultCode OH_Bluetooth_GetBluetoothSwitchState (Bluetooth_SwitchState * state)
124```
125
126**描述**
127
128获取蓝牙开关状态。
129
130**起始版本:** 13
131
132**参数:**
133
134| 名称 | 描述 |
135| -------- | -------- |
136| state | 指向接收蓝牙开关状态的枚举值的指针。 需要传入非空指针,否则将返回错误码。 详细定义请参考[Bluetooth_SwitchState](#bluetooth_switchstate)。 |
137
138**返回:**
139
140返回蓝牙开关状态函数的错误码。详细定义请参考[Bluetooth_ResultCode](#bluetooth_resultcode)。 <br/>BLUETOOTH_SUCCESS 成功获取蓝牙开关状态。 BLUETOOTH_INVALID_PARAM 输入参数为空指针。
141