mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-30 07:34:27 +08:00
0a259dd05b
This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 97 LGPL-2.1-or-later : 38 GPL-2.0-only : 2 License: GPL-2.0-or-later tools/l2cap-tester.c tools/hcisecfilter.c tools/ciptool.c tools/btsnoop.c tools/check-selftest.c tools/btpclientctl.c tools/hci-tester.c tools/hcitool.c tools/btiotest.c tools/oobtest.c tools/btinfo.c tools/hwdb.c tools/hciattach_bcm43xx.c tools/mgmt-tester.c tools/hex2hcd.c tools/hciattach_st.c tools/smp-tester.c tools/bluetooth-player.c tools/hciattach_tialt.c tools/gap-tester.c tools/bluemoon.c tools/bneptest.c tools/gatt-service.c tools/rctest.c tools/rfcomm-tester.c tools/hcieventmask.c tools/hciattach_ti.c tools/seq2bseq.c tools/scotest.c tools/bcmfw.c tools/hciconfig.c tools/btattach.c tools/l2ping.c tools/obexctl.c tools/l2test.c tools/hciattach_intel.c tools/hciattach.h tools/create-image.c tools/bnep-tester.c tools/userchan-tester.c tools/rfcomm.c tools/btmon-logger.c tools/hcidump.c tools/rtlfw.c tools/hciattach_qualcomm.c tools/btproxy.c tools/nokfw.c tools/hciattach_ath3k.c tools/3dsp.c tools/bdaddr.c tools/sco-tester.c tools/hciattach.c tools/amptest.c tools/btgatt-server.c tools/btgatt-client.c tools/cltest.c tools/ibeacon.c tools/mcaptest.c tools/hid2hci.c tools/btmgmt.c tools/advtest.c tools/eddystone.c tools/avtest.c tools/mpris-proxy.c tools/avinfo.c tools/sdptool.c tools/btconfig.c tools/update_compids.sh tools/parser/parser.h tools/parser/obex.c tools/parser/amp.c tools/parser/sdp.c tools/parser/tcpip.c tools/parser/sap.c tools/parser/cmtp.c tools/parser/avctp.c tools/parser/lmp.c tools/parser/ppp.c tools/parser/rfcomm.h tools/parser/hci.c tools/parser/sdp.h tools/parser/parser.c tools/parser/rfcomm.c tools/parser/avdtp.c tools/parser/avrcp.c tools/parser/ericsson.c tools/parser/hcrp.c tools/parser/bpa.c tools/parser/hidp.c tools/parser/bnep.c tools/parser/capi.c tools/parser/att.c tools/parser/l2cap.c tools/parser/smp.c tools/parser/csr.c tools/parser/l2cap.h tools/parse_companies.pl License: LGPL-2.1-or-later tools/test-runner.c tools/btpclient.c tools/meshctl.c tools/mesh-cfgclient.c tools/mesh/model.h tools/mesh/util.h tools/mesh/config-model.h tools/mesh/cfgcli.h tools/mesh/mesh-db.c tools/mesh/mesh-db.h tools/mesh/keys.c tools/mesh/util.c tools/mesh/agent.h tools/mesh/remote.c tools/mesh/keys.h tools/mesh/agent.c tools/mesh/cfgcli.c tools/mesh/remote.h tools/mesh-gatt/prov.c tools/mesh-gatt/util.h tools/mesh-gatt/prov.h tools/mesh-gatt/net.c tools/mesh-gatt/util.c tools/mesh-gatt/prov-db.h tools/mesh-gatt/crypto.c tools/mesh-gatt/crypto.h tools/mesh-gatt/gatt.c tools/mesh-gatt/config-server.c tools/mesh-gatt/keys.h tools/mesh-gatt/onoff-model.c tools/mesh-gatt/net.h tools/mesh-gatt/gatt.h tools/mesh-gatt/node.c tools/mesh-gatt/config-client.c tools/mesh-gatt/mesh-net.h tools/mesh-gatt/node.h tools/mesh-gatt/onoff-model.h tools/mesh-gatt/prov-db.c License: GPL-2.0-only tools/obex-server-tool.c tools/obex-client-tool.c
118 lines
2.6 KiB
C
118 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
*
|
|
* BlueZ - Bluetooth protocol stack for Linux
|
|
*
|
|
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
|
*
|
|
*
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <getopt.h>
|
|
#include <sys/socket.h>
|
|
|
|
#include "lib/bluetooth.h"
|
|
#include "lib/hci.h"
|
|
#include "lib/hci_lib.h"
|
|
|
|
static struct option main_options[] = {
|
|
{ "device", 1, 0, 'i' },
|
|
{ 0, 0, 0, 0 }
|
|
};
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
uint8_t events[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00 };
|
|
struct hci_dev_info di;
|
|
struct hci_version ver;
|
|
int dd, opt, dev = 0;
|
|
|
|
while ((opt=getopt_long(argc, argv, "+i:", main_options, NULL)) != -1) {
|
|
switch (opt) {
|
|
case 'i':
|
|
dev = hci_devid(optarg);
|
|
if (dev < 0) {
|
|
perror("Invalid device");
|
|
exit(1);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
dd = hci_open_dev(dev);
|
|
if (dd < 0) {
|
|
fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
|
|
dev, strerror(errno), errno);
|
|
exit(1);
|
|
}
|
|
|
|
if (hci_devinfo(dev, &di) < 0) {
|
|
fprintf(stderr, "Can't get device info for hci%d: %s (%d)\n",
|
|
dev, strerror(errno), errno);
|
|
hci_close_dev(dd);
|
|
exit(1);
|
|
}
|
|
|
|
if (hci_read_local_version(dd, &ver, 1000) < 0) {
|
|
fprintf(stderr, "Can't read version info for hci%d: %s (%d)\n",
|
|
dev, strerror(errno), errno);
|
|
hci_close_dev(dd);
|
|
exit(1);
|
|
}
|
|
|
|
hci_close_dev(dd);
|
|
|
|
if (ver.hci_ver > 1) {
|
|
if (di.features[5] & LMP_SNIFF_SUBR)
|
|
events[5] |= 0x20;
|
|
|
|
if (di.features[5] & LMP_PAUSE_ENC)
|
|
events[5] |= 0x80;
|
|
|
|
if (di.features[6] & LMP_EXT_INQ)
|
|
events[5] |= 0x40;
|
|
|
|
if (di.features[6] & LMP_NFLUSH_PKTS)
|
|
events[7] |= 0x01;
|
|
|
|
if (di.features[7] & LMP_LSTO)
|
|
events[6] |= 0x80;
|
|
|
|
if (di.features[6] & LMP_SIMPLE_PAIR) {
|
|
events[6] |= 0x01; /* IO Capability Request */
|
|
events[6] |= 0x02; /* IO Capability Response */
|
|
events[6] |= 0x04; /* User Confirmation Request */
|
|
events[6] |= 0x08; /* User Passkey Request */
|
|
events[6] |= 0x10; /* Remote OOB Data Request */
|
|
events[6] |= 0x20; /* Simple Pairing Complete */
|
|
events[7] |= 0x04; /* User Passkey Notification */
|
|
events[7] |= 0x08; /* Keypress Notification */
|
|
events[7] |= 0x10; /* Remote Host Supported
|
|
* Features Notification */
|
|
}
|
|
|
|
if (di.features[4] & LMP_LE)
|
|
events[7] |= 0x20;
|
|
|
|
if (di.features[6] & LMP_LE_BREDR)
|
|
events[7] |= 0x20;
|
|
}
|
|
|
|
printf("Setting event mask:\n");
|
|
printf("\thcitool cmd 0x%02x 0x%04x "
|
|
"0x%02x 0x%02x 0x%02x 0x%02x "
|
|
"0x%02x 0x%02x 0x%02x 0x%02x\n",
|
|
OGF_HOST_CTL, OCF_SET_EVENT_MASK,
|
|
events[0], events[1], events[2], events[3],
|
|
events[4], events[5], events[6], events[7]);
|
|
|
|
return 0;
|
|
}
|