3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <sys/socket.h>
34 #include <bluetooth/bluetooth.h>
35 #include <bluetooth/hci.h>
36 #include <bluetooth/hci_lib.h>
38 static struct option main_options[] = {
39 { "device", 1, 0, 'i' },
43 int main(int argc, char *argv[])
45 uint8_t events[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00 };
46 struct hci_dev_info di;
47 struct hci_version ver;
50 while ((opt=getopt_long(argc, argv, "+i:", main_options, NULL)) != -1) {
53 dev = hci_devid(optarg);
55 perror("Invalid device");
62 dd = hci_open_dev(dev);
64 fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
65 dev, strerror(errno), errno);
69 if (hci_devinfo(dev, &di) < 0) {
70 fprintf(stderr, "Can't get device info for hci%d: %s (%d)\n",
71 dev, strerror(errno), errno);
76 if (hci_read_local_version(dd, &ver, 1000) < 0) {
77 fprintf(stderr, "Can't read version info for hci%d: %s (%d)\n",
78 dev, strerror(errno), errno);
85 if (ver.hci_ver > 1) {
86 if (di.features[5] & LMP_SNIFF_SUBR)
89 if (di.features[5] & LMP_PAUSE_ENC)
92 if (di.features[6] & LMP_EXT_INQ)
95 if (di.features[6] & LMP_NFLUSH_PKTS)
98 if (di.features[7] & LMP_LSTO)
101 if (di.features[6] & LMP_SIMPLE_PAIR) {
102 events[6] |= 0x01; /* IO Capability Request */
103 events[6] |= 0x02; /* IO Capability Response */
104 events[6] |= 0x04; /* User Confirmation Request */
105 events[6] |= 0x08; /* User Passkey Request */
106 events[6] |= 0x10; /* Remote OOB Data Request */
107 events[6] |= 0x20; /* Simple Pairing Complete */
108 events[7] |= 0x04; /* User Passkey Notification */
109 events[7] |= 0x08; /* Keypress Notification */
110 events[7] |= 0x10; /* Remote Host Supported
111 * Features Notification */
114 if (di.features[4] & LMP_LE)
117 if (di.features[6] & LMP_LE_BREDR)
121 printf("Setting event mask:\n");
122 printf("\thcitool cmd 0x%02x 0x%04x "
123 "0x%02x 0x%02x 0x%02x 0x%02x "
124 "0x%02x 0x%02x 0x%02x 0x%02x\n",
125 OGF_HOST_CTL, OCF_SET_EVENT_MASK,
126 events[0], events[1], events[2], events[3],
127 events[4], events[5], events[6], events[7]);