• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# oh_bluetooth.h
2
3<!--Kit: Connectivity Kit-->
4<!--Subsystem: Communication-->
5<!--Owner: @enjoy_sunshine-->
6<!--Designer: @chengguohong; @tangjia15-->
7<!--Tester: @wangfeng517-->
8<!--Adviser: @zhang_yixin13-->
9
10## Overview
11
12Defines the API for obtaining the Bluetooth switch state.
13
14**File to include**: <ConnectivityKit/bluetooth/oh_bluetooth.h>
15
16**Library:** libbluetooth.so
17
18**System capability**: SystemCapability.Communication.Bluetooth.Core
19
20**Since**: 13
21
22**Related module**: [Bluetooth](capi-bluetooth.md)
23
24## Summary
25
26### Enums
27
28| Name| typedef Keyword| Description|
29| -- | -- | -- |
30| [Bluetooth_SwitchState](#bluetooth_switchstate) | Bluetooth_SwitchState | Enumerates the Bluetooth switch states.|
31| [Bluetooth_ResultCode](#bluetooth_resultcode) | Bluetooth_ResultCode | Defines the Bluetooth return value.|
32
33### Functions
34
35| Name| Description|
36| -- | -- |
37| [Bluetooth_ResultCode OH_Bluetooth_GetBluetoothSwitchState(Bluetooth_SwitchState *state)](#oh_bluetooth_getbluetoothswitchstate) | Obtains the Bluetooth state.|
38
39## Enum Description
40
41### Bluetooth_SwitchState
42
43```
44enum Bluetooth_SwitchState
45```
46
47**Description**
48
49Enumerates the Bluetooth switch states.
50
51**Since**: 13
52
53| Enum Item| Description|
54| -- | -- |
55| BLUETOOTH_STATE_OFF = 0 | Bluetooth is turned off.|
56| BLUETOOTH_STATE_TURNING_ON = 1 | Bluetooth is being turned on.|
57| BLUETOOTH_STATE_ON = 2 | Bluetooth is turned on and ready for use.|
58| BLUETOOTH_STATE_TURNING_OFF = 3 | Bluetooth is being turned off.|
59| BLUETOOTH_STATE_BLE_TURNING_ON = 4 | The BLE only mode is being turned on.|
60| BLUETOOTH_STATE_BLE_ON = 5 | The BLE only mode is turned on.|
61| BLUETOOTH_STATE_BLE_TURNING_OFF = 6 | The BLE only mode is being turned off.|
62
63### Bluetooth_ResultCode
64
65```
66enum Bluetooth_ResultCode
67```
68
69**Description**
70
71Defines the Bluetooth return value.
72
73**Since**: 13
74
75| Enum Item| Description|
76| -- | -- |
77| BLUETOOTH_SUCCESS = 0 | Operation success.|
78| BLUETOOTH_INVALID_PARAM = 401 | Invalid parameter. Possible causes: 1. The input parameter is a null pointer. 2. The parameter value exceeds the value range.|
79
80
81## Function Description
82
83### OH_Bluetooth_GetBluetoothSwitchState()
84
85```
86Bluetooth_ResultCode OH_Bluetooth_GetBluetoothSwitchState(Bluetooth_SwitchState *state)
87```
88
89**Description**
90
91Obtains the Bluetooth state.
92
93**Since**: 13
94
95
96**Parameters**
97
98| Name| Description|
99| -- | -- |
100| [Bluetooth_SwitchState](capi-oh-bluetooth-h.md#bluetooth_switchstate) *state | Pointer to the Bluetooth state obtained. A null pointer is prohibited. If a null pointer is passed in, an error is returned. For details, see [Bluetooth_SwitchState](capi-oh-bluetooth-h.md#bluetooth_switchstate).|
101
102**Returns**
103
104| Type| Description|
105| -- | -- |
106| [Bluetooth_ResultCode](capi-oh-bluetooth-h.md#bluetooth_resultcode) | Bluetooth switch state enumerated by [Bluetooth_ResultCode](capi-oh-bluetooth-h.md#bluetooth_resultcode).<br>     The value can be:<br>     [BLUETOOTH_SUCCESS](capi-oh-bluetooth-h.md#bluetooth_resultcode): The Bluetooth switch status is successfully obtained.<br>     [BLUETOOTH_INVALID_PARAM](capi-oh-bluetooth-h.md#bluetooth_resultcode): The input parameter is a null pointer.|
107