1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2006-2007 Nokia Corporation
* Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <bluetooth/bluetooth.h>
#include <glib.h>
#define ADAPTER_INTERFACE "org.bluez.Adapter"
/* Discover types */
#define DISCOVER_TYPE_NONE 0x00
#define STD_INQUIRY 0x01
#define PERIODIC_INQUIRY 0x02
/* Actions executed after inquiry complete */
#define RESOLVE_NAME 0x10
typedef enum {
NAME_ANY,
NAME_NOT_REQUIRED, /* used by get remote name without name resolving */
NAME_REQUIRED, /* remote name needs be resolved */
NAME_REQUESTED, /* HCI remote name request was sent */
NAME_SENT /* D-Bus signal RemoteNameUpdated sent */
} name_status_t;
struct btd_adapter;
struct remote_dev_info {
bdaddr_t bdaddr;
int8_t rssi;
uint32_t class;
char *alias;
name_status_t name_status;
};
struct hci_dev {
int ignore;
uint8_t features[8];
uint8_t lmp_ver;
uint16_t lmp_subver;
uint16_t hci_rev;
uint16_t manufacturer;
uint8_t ssp_mode;
uint8_t name[248];
uint8_t class[3];
};
int adapter_start(struct btd_adapter *adapter);
int adapter_stop(struct btd_adapter *adapter);
int adapter_update(struct btd_adapter *adapter);
int adapter_get_class(struct btd_adapter *adapter, uint8_t *cls);
int adapter_set_class(struct btd_adapter *adapter, uint8_t *cls);
int adapter_update_ssp_mode(struct btd_adapter *adapter, int dd, uint8_t mode);
struct btd_device *adapter_get_device(DBusConnection *conn,
struct btd_adapter *adapter, const char *address);
struct btd_device *adapter_find_device(struct btd_adapter *adapter, const char *dest);
struct btd_device *adapter_find_connection(struct btd_adapter *adapter, uint16_t handle);
void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter,
struct btd_device *device);
struct btd_device *adapter_create_device(DBusConnection *conn,
struct btd_adapter *adapter, const char *address);
int pending_remote_name_cancel(struct btd_adapter *adapter);
void remove_pending_device(struct btd_adapter *adapter);
struct btd_adapter *adapter_create(DBusConnection *conn, int id,
gboolean devup);
void adapter_remove(struct btd_adapter *adapter);
uint16_t adapter_get_dev_id(struct btd_adapter *adapter);
const gchar *adapter_get_path(struct btd_adapter *adapter);
void adapter_get_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_set_state(struct btd_adapter *adapter, int state);
int adapter_get_state(struct btd_adapter *adapter);
struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
struct remote_dev_info *match);
int adapter_add_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int8_t rssi, uint32_t class, const char *alias,
name_status_t name_status);
int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_update_oor_devices(struct btd_adapter *adapter);
void adapter_remove_oor_device(struct btd_adapter *adapter, char *peer_addr);
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
void adapter_name_changed(struct btd_adapter *adapter, const char *name);
struct agent *adapter_get_agent(struct btd_adapter *adapter);
void adapter_add_connection(struct btd_adapter *adapter,
struct btd_device *device, uint16_t handle);
void adapter_remove_connection(struct btd_adapter *adapter,
struct btd_device *device, uint16_t handle);
gboolean adapter_has_discov_sessions(struct btd_adapter *adapter);
struct btd_adapter_driver {
const char *name;
int (*probe) (struct btd_adapter *adapter);
void (*remove) (struct btd_adapter *adapter);
};
typedef void (*service_auth_cb) (DBusError *derr, void *user_data);
int btd_register_adapter_driver(struct btd_adapter_driver *driver);
void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
const char *uuid, service_auth_cb cb, void *user_data);
int btd_cancel_authorization(const bdaddr_t *src, const bdaddr_t *dst);
const char *adapter_any_get_path(void);
const char *btd_adapter_any_request_path(void);
void btd_adapter_any_release_path(void);
gboolean adapter_is_pairable(struct btd_adapter *adapter);
|