Skip to content

Commit b0433ae

Browse files
committed
hw:bluetooth: Add missing header and Update documentation
Change-Id: Ia4307318648f3948ebaf59890b0e6340535c4b04 Signed-off-by: Ajay Bhargav <[email protected]>
1 parent dbe7797 commit b0433ae

File tree

2 files changed

+132
-1
lines changed

2 files changed

+132
-1
lines changed

docs/book/api/peri/bluetooth.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ and standard io operation can then be performed via system calls.
1717
API Reference
1818
-------------
1919

20-
.. .. include:: /inc/bluetooth.inc
20+
.. include:: /inc/bluetooth.inc
2121

include/hw/bluetooth.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* bluetooth.h
3+
*
4+
*/
5+
6+
#ifndef INC_HW_BLUETOOTH_H_
7+
#define INC_HW_BLUETOOTH_H_
8+
9+
/**
10+
* Maximum length for BT device name
11+
*/
12+
#define BTDEV_NAME_LEN_MAX 56 /* 18 * 3 + 2 */
13+
14+
/**
15+
* Bluetooth error code
16+
*/
17+
enum bterr_e {
18+
BT_ERR_NONE = 0, /**< No error */
19+
BT_ERR_ARG = -1, /**< Invalid argument */
20+
BT_ERR_OPFAIL = -2, /**< Fail to perform operation */
21+
BT_ERR_BUSY = -3, /**< Hardware busy */
22+
BT_ERR_NODEV = -4, /**< No device found */
23+
BT_ERR_SCAN = -5, /**< BT Scan error */
24+
BT_ERR_PAIR = -6, /**< BT Pair error */
25+
BT_ERR_TIMEOUT = -7,/**< BT operation timeout */
26+
};
27+
28+
/**
29+
* Device list selection to access driver's device list
30+
*/
31+
enum devtype_e {
32+
DEV_TYPE_SEARCH,/**< Searched device list */
33+
DEV_TYPE_PAIRED /**< Paired device list */
34+
};
35+
36+
/**
37+
* Bluetooth device information structure
38+
*/
39+
struct btdevinfo_t {
40+
char name[BTDEV_NAME_LEN_MAX]; /**< Name of device */
41+
unsigned char addr[6]; /**< Hardware address of device */
42+
};
43+
44+
/**
45+
* Initialize Bluetooth hardware
46+
* @param name [in] Name of device shown to other bluetooth device while searching
47+
* @param use_btcli [in] Bluetooth console select (1 to enable, 0 to disable).
48+
* When enabled, /dev/bthost0 device file will not be available
49+
* to the application.
50+
* @return For return value see @ref bterr_e
51+
*/
52+
int bt_device_init(const char *name, int use_btcli);
53+
54+
/**
55+
* Turn on/off bluetooth hardware. Bluetooth is enabled by default when device is initialized.
56+
* @param on_off [in] TRUE (1) to turn on or FLASE (0) to turn off
57+
* @return For return value see @ref bterr_e
58+
*/
59+
int bt_device_power(int on_off);
60+
61+
/**
62+
* Reset bluetooth hardware. Equivalent to turn off and then turn on.
63+
* @return For return value see @ref bterr_e
64+
*/
65+
int bt_device_reset(void);
66+
67+
/**
68+
* Change display name of device
69+
* @param name [in] Device name
70+
* @return For return value see @ref bterr_e
71+
*/
72+
int bt_device_setname(const char *name);
73+
74+
/**
75+
* Perform a bluetooth scan. This is a blocking function.
76+
* @param timeout [in] Timeout value in seconds
77+
* @return For return value see @ref bterr_e
78+
*/
79+
int bt_device_scan(unsigned int timeout);
80+
81+
/**
82+
* Cancel scan operation. calling this function will interrupt @ref bt_device_scan()
83+
* @return For return value see @ref bterr_e
84+
*/
85+
int bt_device_scancancel(void);
86+
87+
/**
88+
* Get device list count
89+
* @param type [in] Device list selection, see @ref devtype_e
90+
* @return On success, returns available device count in the list.
91+
* On error, negative value is returned, see @ref bterr_e
92+
*/
93+
int bt_device_getcount(int type);
94+
95+
/**
96+
* Get bluetooth device information.
97+
* This function can be called to get list of devices after a scan is performed
98+
* or to get list of paired devices.
99+
*
100+
* @param idx [in] 0 base index, referring to the list
101+
* @param type [in] Device list selection, see @ref devtype_e
102+
* @param out_devinfo [out] Device information structure to fill
103+
* @return On success, returns 0 and @a out_devinfo is updated with
104+
* device information. On failure negative value is returned
105+
* see @ref bterr_e
106+
*/
107+
int bt_device_getdevinfo(int idx, int type, struct btdevinfo_t *out_devinfo);
108+
109+
/**
110+
* Pair a device.
111+
* @param name [in] Name of device to pair with
112+
* @param passcode [in] Pair passcode/Pin. Can be NULL if auto-generated passcode
113+
* is supported by device.
114+
* @return For return value see @ref bterr_e
115+
*/
116+
int bt_device_pair(const char *name, const char *passcode);
117+
118+
/**
119+
* Unpair a device
120+
* @param name [in] Name of device to unpair
121+
* @return For return value see @ref bterr_e
122+
*/
123+
int bt_device_unpair(const char *name);
124+
125+
/**
126+
* Unpair all paired devices
127+
* @return For return value see @ref bterr_e
128+
*/
129+
int bt_device_unpairall(void);
130+
131+
#endif /* INC_HW_BLUETOOTH_H_ */

0 commit comments

Comments
 (0)